Since I updated my Angular8 project to Angular9, I can see an extra step of compiling to esm. This makes my build take longer by 1 minute.
It looks something like this:
Compiling @angular/animations : es2015 as esm2015
Compiling @angular/cdk/keycodes : es2015 as esm2015
Compiling @angular/compiler/testing : es2015 as esm2015
Compiling @angular/core : es2015 as esm2015
Compiling @angular/cdk/collections : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
...
Anybody has an idea what is this step for? and is there any option to disable it?
This is ngcc compiling all modules into ivy compatible code.
You can't remove it because it's needed by Ivy to function. but you can do it once, which will generate files into node_modules and you won't have to do it again until adding any new dependencies or updating angular.
Add this to your package.json
scripts
section
"scripts": {
...
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points"
...
}
and then run npm install
or yarn install
to trigger the postinstall command.