Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 AOT vs JIT

I was just reading Angular 2 AOT documentation and a few questions poped up

  1. The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot

  2. The documentation goes through in detail about how to set it up. Would ng build --prod --aot be good enough to ignore all those setup?

like image 373
user172902 Avatar asked Dec 18 '22 10:12

user172902


2 Answers

  1. The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot

AoT is the default for -prod as of beta 28.

It's still NOT the default for dev build. Why? Because it takes longer time to compile and in dev you want fast feedback.

Note that the current version of the Angular CLI at the time of writing is beta.29, and the package name has changed from angular-cli to @angular/cli.

  1. The documentation goes through in detail about how to set it up. Would ng build --prod --aot be good enough to ignore all those setup?

Yes!

And you can just ng build -prod if you are using the latest version of the CLI.

like image 193
Meligy Avatar answered Dec 28 '22 09:12

Meligy


As part of angular-cli, you should have the required NPM dependencies to compile using AOT. It seems as though AOT will be enabled if targeting prod in the very near future. It was accidentally enabled by default in an earlier version of angular-cli and that caused a few headaches.

Running ng build --prod --aot=true will work on a brand new angular-cli application without additional configuration or setup.

like image 42
silencedmessage Avatar answered Dec 28 '22 11:12

silencedmessage