I created a project using npm workspaces and Typescript Project References pretty much exactly like this example repo: https://github.com/Quramy/npm-ts-workspaces-example.
This setup keeps all node_modules in the root-directory/node_modules and creates symlinks in the root-directory/node_modules folder to the packages so that they can be directly referenced from another package.
For development this works fine, but I'm stuck at the deployment. How would I deploy a single workspace if all node modules are in the root? The dist folders do not contain the node modules and npm i installs all dependencies and creates all symlinks.
How can I create a build for a single workspace which depends on packages and another workspace without including all dependencies from all workspaces?
The Structure looks as following:
├── node_modules/
├── package-lock.json
├── package.json
├── packages
│ ├── package-1
│ │ ├── dist
│ │ │ ├── helper.d.ts
│ │ │ ├── helper.js
│ │ │ ├── helper.js.map
│ │ │ ├── main.d.ts
│ │ │ ├── main.js
│ │ │ └── main.js.map
│ │ ├── package.json
│ │ ├── src
│ │ │ ├── helper.ts
│ │ │ └── main.ts
│ │ └── tsconfig.json
│ └── package-2
│ ├── dist
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ └── index.js.map
│ ├── package.json
│ ├── src
│ │ └── index.ts
│ └── tsconfig.json
├── tsconfig.build.json
└── tsconfig.json