Update to Angular 4.0.0
Angular 4.0.0 has now been released http://angularjs.blogspot.com.au/2017/03/angular-400-now-available.html with some good improvements
I mean everything is basically working, you could start using it and building your app, any updates that come from now on won't be touching the Client or Server folders, they will be build system (webpack etc) updates, so you could just as easily pull down latest, and port your app over (or follow commits)to get the latest bundling updates / chunking updates etc. I need to fix these and add DLL chunking to improve build performance and HMR speed.
Maybe wait a few days so I can get the vendor chunking / CSS extraction / any other things like that out of the way. Otherwise you could always use get going and fix up webpack however you'd like!
- All SEO and HttpTransfer (server -> client) is finished.
- Title, meta even link (canonical, hreflang, etc) are finished.
- You have your separate Browser and Server NgModules. App.module is where you'll import almost everything.
- HttpTransfer is included and functioning, you use it when you want an http call to not get re-ran during the client render. (No flicker this way, only use it for important GETs)
- At the moment there is still redundant main.server and main.server.aot files, but once a PR goes into ngtools/webpack, it'll handle the AoT one automatically.
- There are things documented in HomeController that you can see how the server rendering gets started, and also how we are transferring things.
- We have ORIGIN_URL and REQUEST tokens now. (Remember the server doesn't know relative paths anymore). You can't just don't http.get('/API/whatever') so ORIGIN_URL is there to inject and use for when you have your API in the same project (such as these repos)
Plenty of other things
- I'm waiting to merge and publish to npm the ng-aspnetcore-engine into Universal (https://github.com/angular/universal/pull/682) which will replace the temp one find inside the project)
You can see a Readme here on how everything works now: https://github.com/MarkPieszak/universal/blob/54dec51f09fa0f13743fe92bd822866fff1267e1/modules/aspnetcore-engine/README.md I'm sure I'll be updating it more soon as well.
@SteveSandersonMS maybe you have some time this week, and we can go over everything together, see if there's any other way from the .NET side we could improve the developer experience here? I'll shoot you an email.
Hi @MarkPieszak
Great, great news... and wonderful explanation...
Thank you so much for your great work...
@MarkPieszak Hi Mark, it seems https://github.com/angular/universal/pull/682 was merged, do you plan to update the code accordingly? We are struggling with HMR rebuild speed at the moment, it takes 20 sec, do you think the above might help?
@MarkPieszak - I'm guessing you are aware, but Angular 4.1.0 is out now as well - http://angularjs.blogspot.com/2017/04/angular-410-now-available.html
Any status updates? Thanks for all your work on the project!
Hi @MarkPieszak. Do you perhaps have an ETA for when your changes will be merged? Thanks!
Knowing ETA is super important for planing the production, please share your roadmap,
many thanks,
Finding this thread is a life saver. Thanks so much all, been tearing my hair out for the past 3 hours trying to upgrade the template. Being an Angular noob wasn't helping either.
It's great to see this discussion and especially @MarkPieszak's progress with the update. Hopefully this is something we can proceed with pretty soon.
I think the most stable way for us to proceed with the changes is incrementally. Rather than making a massive set of dramatic changes all at once (e.g., all the stuff in @MarkPieszak's repo), I'd like to start with the minimal set of changes needed to make Angular 4 work correctly on both server and client, without necessarily adding new features such as the SEO stuff or AoT compilation. Then, we can add the new functionality piecemeal. In the meantime, people can get on with updating their existing apps to Angular 4 without having to wait for every last detail about how the new stuff will work. Hope that sounds OK to everyone!
I'm about to post a pull request that includes what I think is a minimal set of changes needed for Angular 4. Hopefully I'll also be able to put a prerelease version of generator-aspnetcore-spa onto NPM so that people can easily try it out without having to build the repo from sources.
THAT WOULD BE FANTASTIC! Thank you!
Thanks!
PR at https://github.com/aspnet/JavaScriptServices/pull/930
That plan sounds perfect!
@philip-reed If you only do client-side rendering, updating the version number is just about all you have to do (haven't checked exactly though). However, if you do server-side rendering, there's far more to it - Angular's approach to server-side rendering is completely different in version 4. In that case you'll have to look at the diffs in this PR and make a corresponding set of changes. But note this is still something we're working on, so don't go ahead yet unless you're willing to debug any problems on your own.
@philip-reed: @SteveSandersonMS is correct, you can upgrade the current template to Angular 4 if you're only doing client side rendering. I've used the Angular 2 template and removed all the server configuration for it along with the server side prerendering and been able to upgrade to Angular 4. However, I had to add some polyfills in that were being taken care of by some of the angular 2 packages. It's possible, but not without some work and debugging.
Please see #930 for instructions on how to try the Angular 4 version of the template.
@AmrineA: Would you mind posting details of what stuff we need to remove for serverside rendering to help with the transition to angular 4? I started a new thread here in #938
@Vx2gas I posted the changes and steps I found in my project from comparing the commits. You can ask me any questions in the other thread if you run into issues.
When I upgrade to angular4 I get the following error when I webpack:
> WARNING in ./~/@angular/core/@angular/core.es5.js
> 5877:15-36 Critical dependency: the request of a dependency is an expression
Any fixes?
Update: Was fixed in a follow-up here: #938
This is now done and is released in package version 0.9.2.
There are still some other Angular 4 updates we want to do later (e.g., AoT, cleaning up error handling), but you can go ahead and use it now.
I just pulled down the latest ones and I'm getting an error in vendor.js.
