I successfully set up a project utilizing npm workspaces and Typescript Project References, following the same structure as this example repository: https://github.com/Quramy/npm-ts-workspaces-example.
In this setup, all node_modules are stored in the root-directory/node_modules
directory, with symlinks created to the packages for direct referencing from another package.
While this configuration works well during development, I am facing challenges with deployment. How can I deploy a single workspace when all node modules are located in the root directory? The dist folders do not contain the node modules, and running npm i
installs all dependencies and creates symlinks.
What is the best way to build a single workspace that depends on specific packages and another workspace without including all dependencies from every workspace?
The project structure is as follows:
├── 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