I have pnpm monorepo and it works perfectly for local build and development server using build for app. For development, I am using
pnpm --filter=@ap/auth-service --prod deploy @prod/auth-service
pnpm --filter=@ap/order-service --prod deploy @prod/order-service
folder structure
root
├── package.json // Root level dependency
├── pnpm-workspace.yaml // pnpm workspace configuration
├── packages // Packages folder containing shared, server, and services
│ ├── shared // Shared resources, if any
│ ├── server // Server related resources, if any
│ └── services // Common services folder
└── apps // Separate apps folder
├── auth-service
│ ├── package.json // Service specific dependency -> @ap/auth-service
│ ├── tsconfig // TypeScript configuration for auth-service
│ └── src // Source code for auth-service
└── order-service
├── package.json // Service specific dependency -> @ap/order-service
├── tsconfig // TypeScript configuration for order-service
└── src // Source code for order-service
pnpm workspace.yaml
packages:
- 'packages/*'
- 'apps/*'
The build fodler dist file is taking the reference from the actual working package directory insted of build fodler, how can I use product ready build for pnpm monorepo which has local worsspace dependency
package.json
I tried pnpm deploy command which I assume is taking the local tsconfig for build
tsconfig.json
{
"compilerOptions": {
"strictNullChecks": false,
"downlevelIteration": true,
"removeComments": true,
"strictPropertyInitialization": false,
"declarationMap": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": false,
"skipLibCheck": true,
"declaration": true,
"target": "ES2021",
"lib": ["ES2021", "dom"],
"types": [
"node",
"jest"
],
"sourceMap": true,
"noUnusedLocals": false,
"emitDecoratorMetadata": true,
"moduleResolution": "node",
"typeRoots": ["./node_modules/@types"],
"suppressImplicitAnyIndexErrors": false,
"module": "commonjs",
"outDir": "./build",
"baseUrl": ".",
"paths": {
"@user-module/*": ["src/module/user/*"],
"@anc-module/*": ["src/module/organization/*"],
"@product-module/*": ["src/module/auth/*"],
"@config/*": ["src/config/*"],
"@shared/*": ["src/shared/*"]
}
},
"include": ["."],
"exclude": ["build", "node_modules", "coverage"]
}
HOw this pnpm deploy comand is taking build command of the package and using tsconfig , if I use build command directly using thus
rimraf ./build && npx tsc
This also produce same result build as this command
pnpm –filter=@sn/auth-service –prod deploy @prod/auth-service
After build I run the pnpm install command inside the deployed folder @prod/auth-service, which I assume should install all the dependency for the auth service in node_module, which I can see is in the node_module as
@ap/shared @ap/service @ap/server
I am not able to use the build fodler indepepdenclty with node modules as the imports are still reffering to the original package code instead of node+modules which should be isntalled from the
package.json
{
"scripts": {
"start:dev": "NODE_ENV=development&&nodemon",
"start": "NODE_ENV=production&& node build/src/index.js",
"build": "rimraf ./build && npx tsc",
"test": "NODE_ENV=development jest"
},
"dependencies": {
"@sinclair/typebox": "^0.31.17",
"@ap/server": "workspace:^",
"@ap/service": "workspace:^",
"@ap/shared": "workspace:^",
"dotenv": "^16.0.3",
},
}