From 87fdd2315729bcb26d59c1e3c63b4b1e37b20b96 Mon Sep 17 00:00:00 2001 From: Ajit Singh Date: Wed, 22 Apr 2020 09:21:11 +0530 Subject: [PATCH] docs: add note on publishing libraries in ivy (#36556) Libraries are still build using view engine even after Ivy being the default engine for building angular apps. Added note on why libraries are built using VE and how they will be automatically compiled in Ivy using ngcc making it compatible for both Fixes #35625 PR Close #36556 --- aio/content/guide/creating-libraries.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/aio/content/guide/creating-libraries.md b/aio/content/guide/creating-libraries.md index 69af87b377..5978092bd8 100644 --- a/aio/content/guide/creating-libraries.md +++ b/aio/content/guide/creating-libraries.md @@ -109,7 +109,9 @@ To learn more, see [Schematics Overview](guide/schematics) and [Schematics for ## Publishing your library -Use the Angular CLI and the npm package manager to build and publish your library as an npm package. It is not recommended to publish Ivy libraries to NPM repositories. Before publishing a library to NPM, build it using the `--prod` flag which will use the older compiler and runtime known as View Engine instead of Ivy. +Use the Angular CLI and the npm package manager to build and publish your library as an npm package. + +Before publishing a library to NPM, build it using the `--prod` flag which will use the older compiler and runtime known as View Engine instead of Ivy. ng build my-lib --prod @@ -119,6 +121,14 @@ npm publish If you've never published a package in npm before, you must create a user account. Read more in [Publishing npm Packages](https://docs.npmjs.com/getting-started/publishing-npm-packages). +
+ +For now, it is not recommended to publish Ivy libraries to NPM because Ivy generated code is not backward compatible with View Engine, so apps using View Engine will not be able to consume them. Furthermore, the internal Ivy instructions are not yet stable, which can potentially break consumers using a different Angular version from the one used to build the library. + +When a published library is used in an Ivy app, the Angular CLI will automatically convert it to Ivy using a tool known as the Angular compatibility compiler (`ngcc`). Thus, by publishing your libraries using the View Engine compiler ensures that they can be transparently consumed by both View Engine and Ivy apps. + +
+ {@a lib-assets} ## Managing assets in a library