0

I am using the TS paths approach to include the shared folder in my API project.

Here's a piece of my API's tsconfig.json file:

enter image description here

The challenge here is that the shared folder has its own dependencies and package.json

The overall project structure looks like this:

api/
   .../package.json
shared/
   .../package.json

When compiling API, my dist folder includes the shared folder definitions, but it ignores the node_modules therefore fails during runtime.

enter image description here

Question: How can I tell tsc compiler to include node_modules into dist/shared?

Or should I create a post-compile step to manually copy it? (doesn't sound clean)

inside
  • 3,047
  • 10
  • 49
  • 75
  • I suppose you should turn `shared` folder into package and add it as a local package into your package.json. – Anatoly Nov 21 '20 at 17:53
  • And of course you should build it every time it changed – Anatoly Nov 21 '20 at 17:54
  • sounds like a lot of additional manual steps to have it as a standalone package? is there an easier approach? – inside Nov 21 '20 at 17:55
  • Also, with the approach, you're suggesting, I'll need to do `npm install` every time I make changes to `shared` package? – inside Nov 21 '20 at 18:08
  • Something like this, yes. `Node_modules` folder for this module does not change automatically if you change a content of `shared` module. So after some changes You should manually do `npm install/update` in the `shared` folder, right? – Anatoly Nov 21 '20 at 18:11

0 Answers0