I have a NestJS Monorepo app I created using the nest CLI. Its a main app and I created a library called "common".
I would like to package the library up and distribute it within my company but when I do, it won't compile correctly.
I tried running nest build common but that just ended with a dist/libs/common/index.js with only about 100 lines in it. Nothing in that webpack file looks remotely like my library code.
What am I doing wrong? Building the overall app works fine. I just can't figure out how to get the individual library to build.
No, not this way.
The approach with existing Nest CLI monorepo is to have a code repository with all the shared libraries and applications in it, where libraries are supposed to be published with the applications; not individually to any registry. The libraries are bundled with the application in one file.
You can have multiple apps though, which can use these libraries as required, and published individually.
For example: if you have myApp1 and myApp2, specify the app name with yarn build, and webpack will create one single file with all the dependencies in it.
Something like yarn build myApp1 or yarn build myApp2
If you check the dist (build) folder, and the individual application build file in their subfolders. Webpack bundles everything in one file.
Use specialized tools for that:
These are more efficient when managing complex projects. Here you have all the fancy features you need, like caching, version control etc. and lighting fast speed!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With