So to reiterate what's the goal, in your NX monorepo, you want to have the following:
my-angular
app
my-nestjs
app
shared
lib
- some other libs.
IMO, to get to that point, you have two options, each with some upsides and downsides.
I'd try solution 1 only in case your existing projects are very simple. Otherwise, solution 2 has a better chance to work out well without significant complications.
Solution 1:
Try to do the straightforward thing, which might be quicker, but might also cause you to unknowingly generate a mess that will not actually work because of unexpected or poorly understood problems/interactions between your first and second app. Which you will then have to spend time to resolve.
Set up a new, fresh NX monorepo: https://nx.dev/recipes/adopting-nx/manual#exploring-your-workspace
Manually copypaste your Angular app to the apps
directory and hook it up to NX: https://nx.dev/recipes/angular/migration/angular-manual
Manually copypaste your Nest app and hook it up to NX (in whatever way it needs to be, rougly described here: https://nx.dev/recipes/adopting-nx/manual#configuration-files). Because that's your second app in the monorepo, it'll require more attention - you'll need to ensure it's supported by NX without breaking the first app, and uses correct versions of packages it needs.
Create a new shared
NX library and reuse it between your apps.
Solution 1a:
If your Angular app is up to date and uses Angular CLI, you can replace steps 1 and 2 with:
- Migrate your Angular app to an NX monorepo using the official conversion tools: https://nx.dev/recipes/angular/migration/angular
This might make the process a bit simpler, though it also gives you less control and a worse learning experience.
Solution 2:
Take the time to do things slowly and carefully, which will also give you more space to understand what NX is and how it actually works.
Migrate your Angular app to an NX monorepo. Split its code to libs and organize them correctly.
Migrate your Nest app to a separate NX monorepo. Split its code to libs and organize them correctly.
Merge those two NX monorepos and resolve any remaining conflicts between CI/CD flows, package versions, etc.
Create a new shared
NX library and reuse it between your apps.
This will be probably longer, but will also give you a better understanding of how each of your apps functions within NX, and how it should be integrated with NX, before you stick them together in a single NX repo that has to support them both.
(As a sidenote, I just want you to know, I was in a similar situation with little to none NX knowledge and only one app to handle, and it wasn't easy. NX is not very beginner-friendly and you will usually not find tutorials and docs that will perfectly cover your use cases. There's plenty of problems to solve, and at many points you will have to make do with the existing docs and the existing scarce examples. If you are deterred at this point at the beginning already, I advise you and/or your company to consider carefully what you want to achieve using NX, and if you're willing to go through a demanding integration process to get it. NX is very worth the effort in some cases, but in some it's not and it's wiser to recognize that before you're too invested.)