Angular 2 AOT 与 JIT [英] Angular 2 AOT vs JIT

查看:25
本文介绍了Angular 2 AOT 与 JIT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在阅读 Angular 2 AOT 文档和出现了几个问题

  1. 该文档显然更倾向于 AOT 而不是 JIT,并提到了所有关于 AOT 如何更好的好东西.如果是这种情况,为什么 AOT 不是默认构建,而是执行 ng build --prod --aot

  2. 文档详细介绍了如何设置它.ng build --prod --aot 是否足以忽略所有这些设置?

解决方案

  1. 该文档显然更倾向于 AOT,而不是 JIT,并提到了关于 AOT 如何更好的所有好东西.如果是这种情况,为什么 AOT 不是默认构建,而是执行 ng build --prod --aot

AoT 是 -prod 自 beta 28 的默认设置.

它仍然不是开发构建的默认设置.为什么?因为编译需要更长的时间,而且在开发中你需要快速的反馈.

请注意,撰写本文时 Angular CLI 的当前版本是 beta.29,并且包名已从 angular-cli 更改为 @angular/cli.

<块引用>

  1. 文档详细介绍了如何设置它.ng build --prod --aot 是否足以忽略所有这些设置?

是的!

如果您使用的是最新版本的 CLI,您只需 ng build -prod.

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?

解决方案

  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.

这篇关于Angular 2 AOT 与 JIT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆