简体   繁体   English

Angular 2 AOT vs JIT

[英]Angular 2 AOT vs JIT

I was just reading Angular 2 AOT documentation and a few questions poped up 我刚刚阅读了Angular 2 AOT文档,并提出了一些问题

  1. The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. 文档明显倾向于AOT优于JIT,并提到了关于AOT如何更好的所有好东西。 If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot 如果是这种情况,为什么AOT不是默认构建而不是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? ng build --prod --aot是否足以忽略所有这些设置?

  1. The documentation clearly favours AOT over JIT and mentioned all the good stuff about how AOT is better. 文档明显倾向于AOT优于JIT,并提到了关于AOT如何更好的所有好东西。 If that is the case why wouldn't AOT be the default build rather than doing ng build --prod --aot 如果是这种情况,为什么AOT不是默认构建而不是ng build --prod --aot

AoT is the default for -prod as of beta 28. AoT是beta 28的-prod的默认值。

It's still NOT the default for dev build. 它仍然不是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 . 请注意,编写本文时Angular CLI的当前版本是beta.29,并且包名称已从angular-cli更改为@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? ng build --prod --aot是否足以忽略所有这些设置?

Yes! 是!

And you can just ng build -prod if you are using the latest version of the CLI. 如果您使用的是最新版本的CLI,则可以ng build -prod

As part of angular-cli, you should have the required NPM dependencies to compile using AOT. 作为angular-cli的一部分,您应该使用AOT编译所需的NPM依赖项。 It seems as though AOT will be enabled if targeting prod in the very near future . 不久的将来,如果定位prod似乎将启用AOT。 It was accidentally enabled by default in an earlier version of angular-cli and that caused a few headaches. 默认情况下 ,它在早期版本的angular-cli中被意外启用 ,这引起了一些麻烦。

Running ng build --prod --aot=true will work on a brand new angular-cli application without additional configuration or setup. 运行ng build --prod --aot=true将适用于全新的angular-cli应用程序,无需额外配置或设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM