nest icon indicating copy to clipboard operation
nest copied to clipboard

Library asset generation in Monorepo mode

Open sykorax opened this issue 3 years ago • 0 comments

Is there an existing issue that is already proposing this?

  • [X] I have searched the existing issues

Is your feature request related to a problem? Please describe it

I work on a project which has several entry apps and lots of (commonly used) libraries. Some of those libraries have their own static assets such as proto descriptors for gRPC clients. The stub generation happens outside of the project and the proto files are being shipped into their "location" right into their related libraries.

As i have read the official documentation, building apps will result a merged bundle single file, including all the necessary transpiled library codes in itself. I was expecting Nest to be able to find out which assets must be presented in the dist based on this behavior, but seems it doesn't. The only way to make this work is if i build both app and the libraries as well. My only concern is administration and further stuff to remember. Now we can imagine how much extra time it might require to remember which app is using which libraries, so that we also have to maintain some kind of "dependency tree" for ourselves, just because of the assets are located in their own libraries.

Source structure example:

├─ apps
│  └ api
└─ libs
   â”” auth
     â”” assets
       â”” auth.proto

Build the app:

nest build api

Dist folder result example (auth.proto is missing):

├─ dist
   â”” api
     â”” main.js

More details: I am using webpack. I have tried to make sourceRoot to have the value of the project root path, but didn't help.

Describe the solution you'd like

Probably the most user-friendly approach would be if we place an assets array into a library level definition in the nest-cli.json and building any application would realize that whenever some of its dependent modules have their assets it would also build(?) or copy(?) the files.

Teachability, documentation, adoption, migration strategy

What is the motivation / use case for changing the behavior?

Make library-level asset management and building easier, especially in more complex / bigger projects.

sykorax avatar Aug 10 '22 00:08 sykorax