I am confused how to create deployable Typescript applications in a monorepo. I have a yarn workspace monorepo that is using yarn PnP (which removes node_modules
). It generated .pnp.cjs
, .pnp.loader.mjs
and .yarn/cache
(which contains all the dependencies zipped up).
I am using the latest yarn version v4.2.2
My monorepo structure is:
.yarn
/cache
.pnp.cjs
.yarn.lock
package.json
apps
/app1
package.json
/app2
package.json
packages
/app1
package.json
When building the application, I am using compiling TS into the individual app dist
folders that can be deployed. However, what I am confused about is how would it contain the dependencies?
I have tried copying the root .pnp.cjs
and .yarn/cache
into the dist
. Still when trying to start the application node index.js
– none of the dependencies can be found. Am I missing a crucial step to ensure dependencies are available in the built dist
?
Locally, the dependencies can be found and the apps run fine. Any tips would be greatly appreciated.