JavaScriptServices icon indicating copy to clipboard operation
JavaScriptServices copied to clipboard

Update to Angular 4.0.0

Open ghost opened this issue 9 years ago • 91 comments

Angular 4.0.0 has now been released http://angularjs.blogspot.com.au/2017/03/angular-400-now-available.html with some good improvements

ghost avatar Mar 25 '17 00:03 ghost

Still a few things to work out in the integration, but here's what I have so far with .NET and Angular 4. I've started work in this repo (https://github.com/MarkPieszak/aspnetcore-angular2-universal) for now, but imagine it'll get into here soon enough

MarkPieszak avatar Mar 25 '17 03:03 MarkPieszak

Wow! Thanks @MarkPieszak Wrongly assumed it was essentially a package update, with v2 to v4 meant to be basically non breaking

ghost avatar Mar 25 '17 04:03 ghost

Yeah it's quite a bit more, also starting the process differently (now in the Controller) so that we can give .NET the other essential SEO data.

Of course, if you don't care about server rendering, you can just shut it off and update to 4.0 real easily :)

MarkPieszak avatar Mar 25 '17 04:03 MarkPieszak

Fantastic! Just had to change the port number in fetchdata.components.ts from http://localhost:5000/api/test/users to http://localhost:1780/api/test/users to get the fetch-data sample working.

peterdobson avatar Mar 25 '17 07:03 peterdobson

Yes so that eventually that'll be set dynamically from the server wth DI, going into Angular, just one of the improvements needed! URLs must be absolute on the server, previously we patched them for you in Universal.

MarkPieszak avatar Mar 25 '17 13:03 MarkPieszak

After upgrading to Ang4 i get this error hile runnign webpack on webpack.config file:

ERROR in [at-loader] ./node_modules/angular2-universal/node_modules/angular2-platform-node/node-platform.d.ts:1:10
    TS2305: Module '"C:/Projects/EYC/Solutions/Anticipate/src/Eyc.Solutions.Anticipate.Ui.Web.2/node_modules/@angular/platform-browser/platform-browser"' has no exported member 'AnimationDriver'.

Any idea? Than kyou.

skorunka avatar Mar 25 '17 14:03 skorunka

You actually can't just update the current project here to Angular4 my apologies. It takes re shifting and removing a lot a lot of things, pull down that branch I pointed to @skorunka and try to port your app to it.

Honestly though I'd suggest waiting a little bit until it's more cleaned up!

MarkPieszak avatar Mar 25 '17 19:03 MarkPieszak

@MarkPieszak No worries, I understand. Thank you for advice, i will give it a try.

skorunka avatar Mar 27 '17 09:03 skorunka

AOT

@starquake , sorry. AOT = ahead-of-time https://angular.cn/docs/ts/latest/guide/glossary.html We all expect officially asp net core angular upgrade to 4.0!

seven1986 avatar Mar 28 '17 06:03 seven1986

@seven1986 I'm sorry, what does 'AOT' mean?

starquake avatar Mar 28 '17 07:03 starquake

@MarkPieszak Will you let us know here when you've done?

michelebombardi avatar Mar 28 '17 11:03 michelebombardi

@MarkPieszak For angular 4 branch you pointed is still using es6-shim. Is there any plan to update it to core-js?

ns8482e avatar Mar 28 '17 15:03 ns8482e

Sure, I'll ping everyone when it's all finished. @bm-software Yes there's a lot that needs to be updated along with core-js, such as AoT etc.

For now that branch is bare bones but sometime in the next few days I'm hoping I can find a good bunch of hours where I can focus on it and get it into Masters with everyone fixed up in it.

MarkPieszak avatar Mar 28 '17 19:03 MarkPieszak

@MarkPieszak You are our hero!

skorunka avatar Mar 29 '17 09:03 skorunka

@starquake , Ahead of time compilation. I'm a noob, but essentially precompiling the entire angular app before even hosting on a server. It increases performance since the angular compiler no longer needs to render the templates. It also offers a feature called tree-shaking that reduces the size of bundles since the UI is rendered during compilation and things not used are not included.

ghost avatar Mar 29 '17 21:03 ghost

@MarkPieszak do you plan to include angular-cli into the template? If so, are you going to use AoT and other functionality from angular-cli? I'm asking because angular2 template had some custom functionality which is now supported by official angular-cli

zihotki avatar Mar 30 '17 20:03 zihotki

The problem is that because we are trying to do server side pre-rendering, this breaks away from the use-case of the CLI. The CLI is helpful if you just want a normal client side application and your Rest API is a separate all together entity. Here, the goal is to unify them and .NET be aware of the application as well as aid in serializing it to a string (thus giving us the Prerender ability, since that's only available through Node, and Steve created an incredibly easy way to invoke node within .net core)

AoT will definitely be a part of the template as well, I haven't talked with @SteveSandersonMS yet about the plans for having it here as well, but once I clean a few things up i could make a PR to include it Steve?

At the end of the day the only thing we'll be missing compared to the CLI is the generators, but you could write those in just about any scripting language, even something as easy as Gulp if you wanted to write one.

MarkPieszak avatar Mar 31 '17 06:03 MarkPieszak

I'm trying to rapidly update my vs2015 project to use it with vs2017 but I'm getting the following errors: nr9we

Is there a quick fix for that? The project structure is the default one with ClientApp folder inside the project root folder

michelebombardi avatar Mar 31 '17 12:03 michelebombardi

For me actually the most missing feature in JSS is ability to use generators. It's possible to quickly create some custom generators but they will need to be updated to reflect changes in cli, etc. So if it's possible to reuse at least generators parts that would be great even if we will miss such things like 'ng serve'.

zihotki avatar Mar 31 '17 12:03 zihotki

Any updates ?

AndeyR avatar Apr 04 '17 10:04 AndeyR