gpt4 book ai didi

javascript - Angular 2 汇总 AoT 构建比普通 JiT 构建更大

转载 作者:太空狗 更新时间:2023-10-29 18:31:40 28 4
gpt4 key购买 nike

我在构建我的应用时遇到了问题。我想让他们减轻体重。我使用 angular 2 seed 作为基础。 https://github.com/mgechev/angular-seed

所以在我运行之后:

npm run build.prod 

我的 app.js 是 1.5MB

之后:

npm run build.prod.rollup.aot 

app.js 是 1.9MB

如果我只运行:

npm run build.prod.aot

它是 2.2Mb。

这对我来说完全没有意义。我无法与您分享我的应用程序,因为它是一个私有(private)项目。如果有人知道这可能是什么原因,我会很高兴。

最佳答案

尚未创建提前编译以减少代码大小。在某些情况下,编译后的代码更大,但无论如何,渲染时间会大大减慢。

如果你想减少第一个请求下载的总大小,使用延迟加载模块,但我认为情况并非如此。

参见延迟加载:https://angular-2-training-book.rangle.io/handout/modules/lazy-loading-module.html

查看服务器渲染:https://github.com/robwormald/ng-universal-demo/

关于javascript - Angular 2 汇总 AoT 构建比普通 JiT 构建更大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42644172/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com