angular - 我需要在 CI 作业中缓存什么以避免每次 ngcc 重新编译?

标签 angular continuous-integration circleci angular9 angular-ivy

有了 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/

相关文章:

javascript - ModuleWithProviders<T> 需要 1 个类型的参数 - angular-autofocus-fix

javascript - 隐藏 ngx-datatable Ionic 中的列

angular - 绑定(bind)到@Output Observable 而不是回调?

Mercurial:自动标记构建

caching - 跳过缓存生成, key 的缓存已存在

javascript - 在 Angular 2 中处理来自 http.get 的成功和错误响应

Android 构建仅在 TeamCity 服务器中失败

c++ - Sonar 无法读取我的 CPPUnit 报告

linux - 为什么在 docker 容器内运行的命令不能通过 docker run 从外部运行?

ios - Circleci.yml 空依赖覆盖运行默认命令