Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do I need to cache in my CI job to avoid ngcc recompiling each time?

With angular 9 and it's new compilation engine IVY, my CI build times have increased substantially. This is of course is because ngcc is ran on many modules.

e.g.

Compiling @angular/core : es2015 as esm2015  Compiling @angular/common : es2015 as esm2015  ... 

I thought ngcc cached the compiled libs in node_modules, but my node_modules is cached on my CI job and there is still compilation occuring, so it can't be.

What path should I cache to avoid recompiling all modules with ngcc on each build?

like image 226
Maxime Dupré Avatar asked Mar 04 '20 22:03

Maxime Dupré


People also ask

Is Ngcc required?

So yes, running ngcc is still required, since there is no ivy compliant library out there yet.

What is the use of Ngcc in angular?

ngcc (which stands for Angular compatibility compiler) is designed to process code coming from NPM and produce the equivalent Ivy version, as if the code was compiled with ngtsc .

What is Ngcc?

Definition: NGCC is an advanced power generation technology which allows to improve the fuel efficiency of natural gas. Most new gas power plants in North America and Europe are of this type.


1 Answers

UPDATE 1:

Hard coded Ivy entry points have been Removed from the angular build if you are using latest, it was previously & wrongly hardcoded inside Angular init TS github code link

Now/latest you can just do

ngcc --properties es2015 browser module main



For older versions only, please see Update 1 for newer versions

ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points

Or as par of you build inside package.json

{     "scripts": {         "postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"   } } 

Some ref configure 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  

Option 2: Much faster with yarn or pnpm

pnpm install // or yarn install // or npm install --prefer-offline --no-audit 
like image 135
Transformer Avatar answered Oct 01 '22 00:10

Transformer