DEV Community

Cover image for Angular 13+ libraries migration Ivy partial lerna/Nx build parallel problem
Safwen FELLI
Safwen FELLI

Posted on

Angular 13+ libraries migration Ivy partial lerna/Nx build parallel problem

If you are moving to Angular 13+ and you are stick with building your parallel libraries locally or in the CI within a monorepo using lerna/Nx, you are in the right why to fix that.

 ❌ Another process, with id XXXXX, is currently running ngcc
Enter fullscreen mode Exit fullscreen mode

Steep 1

Check if you got in the tsconfig.lib.prod file the partial compilation mode under angularComplierOptions after running the ng update cmd like so :

"angularCompilerOptions": {
   "compilationMode": "partial"
}
Enter fullscreen mode Exit fullscreen mode

And remove the enableIvy from the config is enabled by default

Steep 2

In the main workspace package.json file you need to add the postinstall script like so:

"scripts": {
    "postinstall": "ngcc --properties es2015 browser module main",
}
Enter fullscreen mode Exit fullscreen mode

Or you can also add options :

"postinstall": "ngcc --properties es2015 es5 browser module main --first-only --create-ivy-entry-points"
Enter fullscreen mode Exit fullscreen mode

If no properties flag is given, ngcc will process all package formats (fesm2015, fesm5, es2015, esm2015, esm5, main, module), which may not be what's desired.

The flag first-only tells ngcc to process the first property it finds in package.json, otherwise it'll process all entries listed above.

The create-ivy-entry-points will tell ngcc to create new properties for the Ivy generated entry, instead of overwriting the previous one.

And it will be compiling with Angular sources in Ivy partial compilation mode.

⚠️ Note: You need to respect the peerDependencies to install correctly the dependencies if it's not work try this

npm i --legacy-peer-deps
Enter fullscreen mode Exit fullscreen mode

Hope this help you in the Angular 13+ migration 🎉

Top comments (0)