Loading...
Loading...
Create and manage PNPM workspaces following Constructive standards. Use when asked to "create a monorepo", "set up a workspace", "configure pnpm", or when starting a new TypeScript/JavaScript project with multiple packages.
npx skill4agent add constructive-io/constructive-skills pnpm-workspacemy-workspace/
├── .eslintrc.json
├── .gitignore
├── .prettierrc.json
├── lerna.json
├── package.json
├── packages/
│ ├── package-a/
│ │ ├── package.json
│ │ ├── src/
│ │ └── tsconfig.json
│ └── package-b/
│ ├── package.json
│ ├── src/
│ └── tsconfig.json
├── pnpm-lock.yaml
├── pnpm-workspace.yaml
└── tsconfig.jsonpackages:
- 'packages/*'packages:
- 'packages/*'
- 'apps/*'
- 'libs/*'{
"name": "my-workspace",
"version": "0.0.1",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/org/my-workspace"
},
"license": "MIT",
"publishConfig": {
"access": "restricted"
},
"scripts": {
"build": "pnpm -r run build",
"clean": "pnpm -r run clean",
"test": "pnpm -r run test",
"lint": "pnpm -r run lint",
"deps": "pnpm up -r -i -L"
},
"devDependencies": {
"@types/jest": "^30.0.0",
"@types/node": "^22.10.2",
"@typescript-eslint/eslint-plugin": "^8.53.1",
"@typescript-eslint/parser": "^8.53.1",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"jest": "^30.2.0",
"lerna": "^8.2.4",
"prettier": "^3.8.0",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"typescript": "^5.6.3"
}
}private: truepnpm -rdeps{
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"version": "independent",
"npmClient": "pnpm",
"registry": "https://registry.npmjs.org",
"command": {
"create": {
"homepage": "https://github.com/org/my-workspace",
"license": "MIT",
"access": "restricted"
},
"publish": {
"allowBranch": "main",
"message": "chore(release): publish",
"conventionalCommits": true
}
}
}"version": "independent""version": "0.0.1"{
"name": "my-package",
"version": "0.1.0",
"description": "Package description",
"author": "Constructive <developers@constructive.io>",
"main": "index.js",
"module": "esm/index.js",
"types": "index.d.ts",
"homepage": "https://github.com/org/my-workspace",
"license": "MIT",
"publishConfig": {
"access": "public",
"directory": "dist"
},
"repository": {
"type": "git",
"url": "https://github.com/org/my-workspace"
},
"scripts": {
"clean": "makage clean",
"build": "makage build",
"lint": "eslint . --fix",
"test": "jest"
},
"devDependencies": {
"makage": "0.1.10"
}
}publishConfig.directory: "dist"mainmoduleworkspace:*{
"dependencies": {
"my-other-package": "workspace:*"
}
}workspace:*| Command | Description |
|---|---|
| Install all dependencies |
| Build all packages |
| Test all packages |
| Build specific package |
| Interactive dependency update |
| Version packages |
| Publish packages |
# Create package directory
mkdir -p packages/my-new-package/src
# Initialize package.json
cd packages/my-new-package
pnpm init{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"declaration": true,
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true
}
}{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"]
}| Aspect | PNPM Workspace | PGPM Workspace |
|---|---|---|
| Purpose | TypeScript/JS packages | SQL database modules |
| Config | pnpm-workspace.yaml | pnpm-workspace.yaml + pgpm.json |
| Build | makage build | pgpm package |
| Output | dist/ folder | SQL bundles |
| Registry | npm | npm (for @pgpm/* packages) |
workspace:*pnpm-publishingpgpm-workspacepgpm-publishing