angular-architects / nx-ddd-plugin

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

Feature Request > generate non-publishable libraries #9

Closed pascalbe-dev closed 4 years ago

pascalbe-dev commented 4 years ago

When I use the nx-ddd-plugin to scaffold a domain library + a feature library, the libraries are always added as publishable libraries (with extra package.json + build target in angular.json, etc.) without the option to make it non publishable (if I didn't miss something).

This has the following drawbacks:

  1. a lot of boilerplate --> often you do not need a library to be publishable and this adds a lot of boilerplate code within the library folder and the angular.json
  2. This nx Issue makes the build target fail for the publishable feature library. Currently we are manually removing the build target from the angular.json to make nx affected:build work. This ofc is an annoying workaround.

Reproduction steps

--> Errors appear (like within the previously noted nx github issue)

Further notes:

The option to have a publishable lib should at least be avoidable by providing a flag. By looking at the source code, I recognized, that you call the nrwl angular lib schematic without any kind of publishable flag. Since publishable is defaulted to false within the nrwl angular lib schematic, I'm quite confused about the nx-ddd-plugin creating publishable libs.

manfredsteyer commented 4 years ago

Hi Pascal,

yes, you are right. It currently always creates publishable libs. In the future, when the issue is solved you are pointing to, there will be a difference b/w publishable and buildable libs. Then, we can move to buildable libs by default. Also, we can provide a way to opt-out of it.

I'd love to work with you on this. Feel free to send a PR.

pascalbe-dev commented 4 years ago

Sounds good. I'd be glad to support here. My suggestion would be to add one more option for now to skip building a lib, which would default to false. This allows to opt out of building and resolve the current issue on nx side for now. When nx makes the distinction b/w buildable and publishable, we could add another option to make libs publishable. This could default to false aswell.

In the end, incremental builds would work by default, but we also have the option to

I'll have a look into it and will prepare a PR.

manfredsteyer commented 4 years ago

Sounds great.

What do you think about --type internal|publishable|buildable defaulting to publishable?

pascalbe-dev commented 4 years ago

Sure, that would work aswell. I'm just wondering if publishable would really be the most common use case and should be default. I would expect buildable to be most commonly used when its ready from nx side. Both defaults would be fine for though.