有了 Angular 9 和它的新编译引擎 IVY,我的 CI 构建时间大大增加了。这当然是因为ngcc
在许多模块上运行。
例如
Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
...
我以为
ngcc
将编译后的库缓存在 node_modules
中, 但我的 node_modules
缓存在我的 CI 作业中,并且仍在进行编译,所以不可能。我应该缓存什么路径以避免使用
ngcc
重新编译所有模块在每个构建上?
最佳答案
更新 1:
硬编码 Ivy entry
积分已 Removed 如果您使用的是最新版本,则来自 Angular 构建,它以前是 & wrongly hardcoded
里面 Angular init TS github code link
现在/最新你可以做
ngcc --properties es2015 browser module main
仅适用于旧版本,请参阅更新 1 了解较新版本
ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points
或者像你们一样在
package.json
内构建{ "scripts": { "postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points" } }
一些引用配置Travis to
# custom caching for .travis.yml
install:
- npm ci
# keep the npm cache around to speed up installs
cache:
directories:
- "$HOME/.npm"
# you can add other
选项 2:
使用 yarn 或 pnpm 更快
pnpm install
// or
yarn install
// or
npm install --prefer-offline --no-audit
关于angular - 我需要在 CI 作业中缓存什么以避免每次 ngcc 重新编译?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60535901/