angular-architects / nx-ddd-plugin

Nx plugin for structuring a monorepo with domains and layers
313 stars 56 forks source link

[Question] Why disable Ivy in all tsconfig.lib.prod.json? #30

Closed HymanZHAN closed 3 years ago

HymanZHAN commented 3 years ago

Sorry if this is a dumb question. I am just getting to learn about Angular libs.

I found that if I just use the nx cli command nx g @nrwl/angular:lib ui the created library doesn't contain this tsconfig.lib.prod.json file. So my questions are:

Thanks!

pascalbe-dev commented 3 years ago

Hi, i can share my thoughts on some of your questions. Maybe it helps.

This ddd plugin makes libraries (feature, domain, ...) buildable by default. That's why you have this file for libs generated via the nx ddd plugin and not for libs generated via the nrwl angular library schematic. If you, however, do not want to have buildable libs, you can also pass the type option set to "internal" for any of the nx ddd schematics.

Regarding your last question - i do not know. The only thing I can say is that nx recommends to not enable ivy for publishable libs. See here.

I hope, this helped a bit 🤓

HymanZHAN commented 3 years ago

@pascalbe-dev Thank you! It really helps. I will sure dive deeper into the nx docs and learn more about it.

About Ivy, it's now allowed to use it in buildable libs but still not recommended in publishable ones. From Angular's doc:

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, publishing your libraries using the View Engine compiler ensures that they can be transparently consumed by both View Engine and Ivy apps.