Angular 2 AOT vs JIT

2019-01-28 05:15发布

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?

2条回答
劳资没心,怎么记你
2楼-- · 2019-01-28 05:47

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.

查看更多
迷人小祖宗
3楼-- · 2019-01-28 06:01
  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.

查看更多
登录 后发表回答