Angular 2 AOT vs JIT

陌路散爱 提交于 2019-11-29 14:34:50
  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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!