Using Angular Library
Environment: angular v8.2; node.js v12
You can create an Angular library within an existing application. e.g. lib name is
ng generate library my-lib`
ng build my-lib
Ivy applications can be built with libraries that were created with the View Engine compiler. This compatibility is provided by a tool known as the Angular compatibility compiler (ngcc). CLI commands run ngcc as needed when performing an Angular build.
In version 9, the server builder which is used for App shell and Angular Universal has the bundleDependencies option enabled by default. If you opt-out of bundling dependencies you will need to run the standalone Angular compatibility compiler (ngcc). This is needed because otherwise Node will be unable to resolve the Ivy version of the packages.
You can run ngcc after each installation of node_modules by adding a postinstall npm script
The postinstall script will run on every installation of node_modules, including those performed by ng update and ng add.
Don’t use –create-ivy-entry-points as this will cause Node not to resolve the Ivy version of the packages correctly.