angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Support for AoT compilation

Open elvirdolic opened this issue 10 years ago • 41 comments

Are there any plans to support AoT compilation in angular-cli?

elvirdolic avatar Aug 17 '16 20:08 elvirdolic

@elvirdolic i believe AoT compilation is a perquisite to declaring an 1.0 release. So while it is not there right now it will be there as we approach an official release of angular2

deebloo avatar Aug 17 '16 23:08 deebloo

We definitely plan on having it, but I don't have a timeline to give. It's a big thing on our radar though.

filipesilva avatar Aug 23 '16 02:08 filipesilva

@elvirdolic just an fyi I have gotten an angular-cli build working with AOT compilation so it is possible to roll it yourself for now if you want to play around with it.

deebloo avatar Aug 28 '16 02:08 deebloo

@deebloo please provide us the steps to make AOT on cli webpack

aminebizid avatar Aug 28 '16 17:08 aminebizid

@deebloo it would be very useful to me too, and I am sure also to other people. Thanks!

razvanmitre avatar Sep 04 '16 00:09 razvanmitre

Any luck with AOT? We're using Angular2 in production, is there a hack to make it work with [email protected]?

monfa-red avatar Sep 15 '16 20:09 monfa-red

Yeah also interested. Is this possible with the "old" systemjs angular-cli? As I can't upgrade to webpack due to some other issues.

ghost avatar Sep 15 '16 20:09 ghost

This repo provides some hacks. Check it out

https://github.com/brandonroberts/router-cli-aot/blob/master/README.md

elvirdolic avatar Sep 15 '16 20:09 elvirdolic

@elvirdolic this is not webpack

aminebizid avatar Sep 18 '16 09:09 aminebizid

I've just played with angular-cli all day and I must say that it is AWESOME 💯 ! But I miss the AoT compilation thu. Is there any progress? When can I expect a working prototype? Is it a matter of days or rather weeks? Thanks for your answer.

castamir avatar Oct 01 '16 20:10 castamir

Yes in the latest version you can try ng build --prod --aot. But its not officially described in the docs.

elvirdolic avatar Oct 02 '16 07:10 elvirdolic

@elvirdolic 👍

I have a question... what is actually happen, when I add --aot flag? In angular.io docs, there is a tutorial for AoT compilation that includes 2 changes, one in tsconfig (for ngc) and second in main.ts (replace platform-browser-dynamic with platform-browser). If I do these changes, build with --aot stop working. If I keep them without any change, --aot works but I think that it still keeps platform-browser-dynamic in the bundle and loads JiT... isn't it?

edit: and if changes in tsconfig.json and main.ts are required, how can I change config for dev and production to use e.g. main.ts or main.aot.ts respectively?

castamir avatar Oct 02 '16 09:10 castamir

I think you don't have to change anything. This is the magic of angular-cli you don't have to worry about that. Use the flag and the rest will be done in the background. Aot is still in WIP. Lets wait for a official relase statement maybe there is some config change required.

elvirdolic avatar Oct 02 '16 09:10 elvirdolic

i am sorry but what is AoT?

k1ng440 avatar Oct 02 '16 20:10 k1ng440

@elvirdolic: correct, there is NO config change needed for AoT, and we're making sure that it's backward compatible with your project. Some extreme cases might confuse our tooling so it will error out, but this should only happen if do strange things (such as declaring your classes but exporting them by another name, for example). If you follow the blueprints, and even if you do some code yourself, it should work just fine.

@k1ng440: AoT is ahead-of-time compilation. Look up "Angular 2 AoT" on youtube to see what's it about.

hansl avatar Oct 02 '16 20:10 hansl

@hansl is this feature usuable? Should I expect to run ng serve --aot and all is working? Or should I do something else?

jordic avatar Oct 03 '16 05:10 jordic

@jordic ng build --prod --aot and ng serve --prod --aot works in beta.16, but there are still some issues to solve (like infinite server rebuild in ng serve --aot in development mode)

castamir avatar Oct 03 '16 07:10 castamir

@castamir didn't see the note the mention about infinite rebuild, was too excited about having AOT. Here is the issue for anyone curious https://github.com/angular/angular-cli/issues/2418

zackarychapple avatar Oct 04 '16 21:10 zackarychapple

@castamir not works aot with lazy routes

delagen avatar Oct 05 '16 04:10 delagen

Ok @castamir. Not sure if this is the place to ask this, but when I launch ng serve --aot I've got this error:

Error encountered resolving symbol values statically. Reference to a non-exported function (position 17:10 in the original .ts file), resolving symbol MemoryBoardComponent

Are there any step I missed, or there is something in my codebase not properly defined/structured? May someone give and advice?

jordic avatar Oct 05 '16 04:10 jordic