简体   繁体   中英

Is it a bad idea to build monorepo Angular9 libraries with Ivy enabled

By default, when creating an Angular9 (currently RC) library, the library is built with Ivy being disabled in production mode. This makes some sense since publishing libraries compiled for Ivy is not (yet) supported.

In my case however I have a monorepo project and we use libraries to organize our code. The libraries are never pushed to NPM and only used for building the main application in a multi-step build process. Building the libraries with Ivy disabled means that the main application build first has to go over all of those libraries and invoke the NGCC to generate the Ivy-versions of the code which seems horribly inefficient and just plain weird.

The question is: is it a bad idea to just enable Ivy for the production builds of those libraries? And if so, why? What potential problems could pop up?

The reason why Google does not yet recommend publishing Ivy libraries is because developers can opt-out of Ivy still. Once they finalize and move everyone to the new build system in angular 10, then they will likely revisit their support of Ivy in published libraries.

I'd say, if you using Ivy throughout the entire project and not providing them to someone who would be turning Ivy off, then set the libs to Ivy. Like you said, it is a bit inefficient as it has to convert the libraries up to Ivy. Google doesn't recommend publishing. Doesn't say they don't recommend using Ivy libraries.

I used https://indepth.dev/the-angular-ivy-guide-for-library-authors/ to fuel my answer. I needed to understand why Google recommended against publishing Ivy libs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM