packwise-skills 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursorrules +23 -23
- package/CLAUDE.md +25 -25
- package/README.md +327 -295
- package/audit.md +224 -224
- package/bin/packwise.js +216 -155
- package/install.sh +89 -0
- package/package.json +32 -31
- package/skill.md +719 -719
- package/sub-skills/ai/local-llm.md +183 -183
- package/sub-skills/ai/python-ml.md +164 -164
- package/sub-skills/backend/go-server.md +184 -184
- package/sub-skills/backend/java-spring.md +241 -241
- package/sub-skills/backend/node-server.md +164 -164
- package/sub-skills/backend/php-laravel.md +175 -175
- package/sub-skills/backend/python-server.md +164 -164
- package/sub-skills/backend/rust-backend.md +118 -118
- package/sub-skills/cli/python-cli.md +236 -236
- package/sub-skills/cli/sdk-library.md +497 -497
- package/sub-skills/cloud/ci-cd-pipelines.md +350 -350
- package/sub-skills/cloud/docker.md +191 -191
- package/sub-skills/cloud/kubernetes.md +277 -277
- package/sub-skills/cloud/payment-integration.md +307 -307
- package/sub-skills/cross-platform/multiplatform.md +252 -252
- package/sub-skills/desktop/electron.md +783 -783
- package/sub-skills/desktop/game-dev.md +443 -443
- package/sub-skills/desktop/native-app.md +123 -123
- package/sub-skills/desktop/scenarios.md +443 -443
- package/sub-skills/desktop/smart-platforms.md +324 -324
- package/sub-skills/desktop/tauri.md +428 -428
- package/sub-skills/desktop/vr-ar.md +252 -252
- package/sub-skills/desktop/web-to-desktop.md +153 -153
- package/sub-skills/embedded/car-infotainment.md +129 -129
- package/sub-skills/embedded/esp32.md +184 -184
- package/sub-skills/embedded/ros.md +150 -150
- package/sub-skills/embedded/stm32.md +160 -160
- package/sub-skills/mobile/android.md +322 -322
- package/sub-skills/mobile/capacitor.md +232 -232
- package/sub-skills/mobile/flutter-mobile.md +138 -138
- package/sub-skills/mobile/harmonyos.md +150 -150
- package/sub-skills/mobile/ios.md +245 -245
- package/sub-skills/mobile/react-native.md +443 -443
- package/sub-skills/mobile/wearables.md +230 -230
- package/sub-skills/plugins/browser-extension.md +308 -308
- package/sub-skills/plugins/jetbrains-plugin.md +226 -226
- package/sub-skills/plugins/vscode-extension.md +204 -204
- package/sub-skills/security/security-tools.md +174 -174
- package/sub-skills/web/monorepo.md +274 -274
- package/sub-skills/web/pwa.md +220 -220
- package/sub-skills/web/serverless-edge.md +295 -295
- package/sub-skills/web/spa.md +266 -266
- package/sub-skills/web/ssr.md +228 -228
- package/sub-skills/web/wasm.md +243 -243
|
@@ -1,274 +1,274 @@
|
|
|
1
|
-
# Monorepo Build Sub-Skill
|
|
2
|
-
|
|
3
|
-
Manage and build multi-package projects using monorepo tools.
|
|
4
|
-
|
|
5
|
-
**Current version**: Turborepo 2.x / pnpm 9.x / Nx 20.x (2025-2026)
|
|
6
|
-
|
|
7
|
-
## When to Use
|
|
8
|
-
|
|
9
|
-
- Multiple related packages/apps in one repository
|
|
10
|
-
- Shared code (UI components, utilities, types) across projects
|
|
11
|
-
- Need coordinated builds with dependency-aware caching
|
|
12
|
-
- Want atomic commits across packages
|
|
13
|
-
|
|
14
|
-
## Tool Comparison
|
|
15
|
-
|
|
16
|
-
| Feature | Turborepo 2.x | Nx 20.x | pnpm Workspaces |
|
|
17
|
-
|---------|--------------|---------|-----------------|
|
|
18
|
-
| Approach | Build orchestrator | Full dev platform | Package manager feature |
|
|
19
|
-
| Caching | Local + Remote | Local + Remote (Nx Cloud) | Not built-in |
|
|
20
|
-
| Language support | Any | JS/TS, Go, Java, .NET | JS/TS only |
|
|
21
|
-
| Learning curve | Low | Medium | Lowest |
|
|
22
|
-
| Task runner | Built-in (turbo.json) | Built-in (project.json) | Use with Turborepo/Nx |
|
|
23
|
-
| Affected detection | Yes | Yes (more granular) | No |
|
|
24
|
-
| Plugin ecosystem | Smaller | Large (generators, executors) | N/A |
|
|
25
|
-
| Best for | JS/TS monorepos, simplicity | Large teams, polyglot monorepos | Package management only |
|
|
26
|
-
|
|
27
|
-
## pnpm Workspaces (Foundation)
|
|
28
|
-
|
|
29
|
-
Most JS/TS monorepos use pnpm as the package manager regardless of build tool.
|
|
30
|
-
|
|
31
|
-
```bash
|
|
32
|
-
# Install pnpm
|
|
33
|
-
npm install -g pnpm@latest
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
```yaml
|
|
37
|
-
# pnpm-workspace.yaml (project root)
|
|
38
|
-
packages:
|
|
39
|
-
- "apps/*"
|
|
40
|
-
- "packages/*"
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
my-monorepo/
|
|
45
|
-
├── apps/
|
|
46
|
-
│ ├── web/ # Frontend app
|
|
47
|
-
│ ├── admin/ # Admin dashboard
|
|
48
|
-
│ └── api/ # Backend API
|
|
49
|
-
├── packages/
|
|
50
|
-
│ ├── ui/ # Shared UI components
|
|
51
|
-
│ ├── utils/ # Shared utilities
|
|
52
|
-
│ ├── tsconfig/ # Shared TypeScript configs
|
|
53
|
-
│ └── eslint-config/ # Shared ESLint configs
|
|
54
|
-
├── pnpm-workspace.yaml
|
|
55
|
-
├── pnpm-lock.yaml
|
|
56
|
-
└── package.json
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
```json
|
|
60
|
-
// Root package.json
|
|
61
|
-
{
|
|
62
|
-
"name": "my-monorepo",
|
|
63
|
-
"private": true,
|
|
64
|
-
"scripts": {
|
|
65
|
-
"build": "turbo run build",
|
|
66
|
-
"dev": "turbo run dev",
|
|
67
|
-
"lint": "turbo run lint",
|
|
68
|
-
"test": "turbo run test"
|
|
69
|
-
},
|
|
70
|
-
"devDependencies": {
|
|
71
|
-
"turbo": "^2.3.0"
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
```json
|
|
77
|
-
// apps/web/package.json — use workspace: protocol for internal deps
|
|
78
|
-
{
|
|
79
|
-
"name": "@myrepo/web",
|
|
80
|
-
"dependencies": {
|
|
81
|
-
"@myrepo/ui": "workspace:*",
|
|
82
|
-
"@myrepo/utils": "workspace:*"
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Turborepo
|
|
88
|
-
|
|
89
|
-
### Configuration
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
// turbo.json
|
|
93
|
-
{
|
|
94
|
-
"$schema": "https://turbo.build/schema.json",
|
|
95
|
-
"tasks": {
|
|
96
|
-
"build": {
|
|
97
|
-
"dependsOn": ["^build"],
|
|
98
|
-
"outputs": ["dist/**", ".next/**", "build/**"],
|
|
99
|
-
"cache": true
|
|
100
|
-
},
|
|
101
|
-
"dev": {
|
|
102
|
-
"cache": false,
|
|
103
|
-
"persistent": true
|
|
104
|
-
},
|
|
105
|
-
"lint": {
|
|
106
|
-
"dependsOn": ["^build"]
|
|
107
|
-
},
|
|
108
|
-
"test": {
|
|
109
|
-
"dependsOn": ["build"],
|
|
110
|
-
"outputs": ["coverage/**"]
|
|
111
|
-
},
|
|
112
|
-
"clean": {
|
|
113
|
-
"cache": false
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### Build Commands
|
|
120
|
-
|
|
121
|
-
```bash
|
|
122
|
-
# Build all packages in dependency order
|
|
123
|
-
turbo run build
|
|
124
|
-
|
|
125
|
-
# Build only packages affected by changes
|
|
126
|
-
turbo run build --filter=...[HEAD^1]
|
|
127
|
-
|
|
128
|
-
# Build specific package and its dependencies
|
|
129
|
-
turbo run build --filter=@myrepo/web...
|
|
130
|
-
|
|
131
|
-
# Build with remote caching (Vercel)
|
|
132
|
-
turbo run build --team=myteam --token=$TURBO_TOKEN
|
|
133
|
-
|
|
134
|
-
# Dry run (show execution plan without building)
|
|
135
|
-
turbo run build --dry-run
|
|
136
|
-
|
|
137
|
-
# Run multiple tasks
|
|
138
|
-
turbo run build lint test
|
|
139
|
-
|
|
140
|
-
# Clear cache
|
|
141
|
-
turbo run clean
|
|
142
|
-
turbo prune # Remove unused cache entries
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Remote Caching
|
|
146
|
-
|
|
147
|
-
```bash
|
|
148
|
-
# Link to Vercel remote cache
|
|
149
|
-
npx turbo login
|
|
150
|
-
npx turbo link
|
|
151
|
-
|
|
152
|
-
# Or self-hosted: set TURBO_API and TURBO_TOKEN
|
|
153
|
-
export TURBO_API=https://my-cache-server.com
|
|
154
|
-
export TURBO_TOKEN=my-token
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Nx
|
|
158
|
-
|
|
159
|
-
### Setup
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
# Add Nx to existing monorepo
|
|
163
|
-
npx nx init
|
|
164
|
-
|
|
165
|
-
# Or create new Nx workspace
|
|
166
|
-
npx create-nx-workspace my-monorepo --preset=ts
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Configuration
|
|
170
|
-
|
|
171
|
-
```json
|
|
172
|
-
// nx.json
|
|
173
|
-
{
|
|
174
|
-
"tasksRunnerOptions": {
|
|
175
|
-
"default": {
|
|
176
|
-
"runner": "nx/tasks-runners/default",
|
|
177
|
-
"options": {
|
|
178
|
-
"cacheableOperations": ["build", "test", "lint"]
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
},
|
|
182
|
-
"targetDefaults": {
|
|
183
|
-
"build": {
|
|
184
|
-
"dependsOn": ["^build"],
|
|
185
|
-
"outputs": ["{projectRoot}/dist"]
|
|
186
|
-
},
|
|
187
|
-
"test": {
|
|
188
|
-
"dependsOn": ["build"]
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
```json
|
|
195
|
-
// apps/web/project.json
|
|
196
|
-
{
|
|
197
|
-
"name": "web",
|
|
198
|
-
"sourceRoot": "apps/web/src",
|
|
199
|
-
"targets": {
|
|
200
|
-
"build": {
|
|
201
|
-
"executor": "@nx/vite:build",
|
|
202
|
-
"outputs": ["{options.outputPath}"],
|
|
203
|
-
"options": {
|
|
204
|
-
"outputPath": "dist/apps/web"
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
"dev": {
|
|
208
|
-
"executor": "@nx/vite:dev-server"
|
|
209
|
-
},
|
|
210
|
-
"test": {
|
|
211
|
-
"executor": "@nx/vite:test"
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
### Build Commands
|
|
218
|
-
|
|
219
|
-
```bash
|
|
220
|
-
# Build all
|
|
221
|
-
npx nx run-many -t build
|
|
222
|
-
|
|
223
|
-
# Build affected only (compares with main branch)
|
|
224
|
-
npx nx affected -t build
|
|
225
|
-
|
|
226
|
-
# Build specific project
|
|
227
|
-
npx nx build web
|
|
228
|
-
|
|
229
|
-
# Graph visualization
|
|
230
|
-
npx nx graph
|
|
231
|
-
|
|
232
|
-
# Remote cache (Nx Cloud)
|
|
233
|
-
npx nx connect-to-nx-cloud
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
## CI/CD — GitHub Actions (Turborepo)
|
|
237
|
-
|
|
238
|
-
```yaml
|
|
239
|
-
name: Monorepo Build
|
|
240
|
-
on:
|
|
241
|
-
push:
|
|
242
|
-
branches: [main]
|
|
243
|
-
pull_request:
|
|
244
|
-
|
|
245
|
-
jobs:
|
|
246
|
-
build:
|
|
247
|
-
runs-on: ubuntu-latest
|
|
248
|
-
steps:
|
|
249
|
-
- uses: actions/checkout@v4
|
|
250
|
-
with:
|
|
251
|
-
fetch-depth: 2 # Needed for affected detection
|
|
252
|
-
- uses: actions/setup-node@v4
|
|
253
|
-
with:
|
|
254
|
-
node-version: '22'
|
|
255
|
-
- run: npm install -g pnpm
|
|
256
|
-
- run: pnpm install --frozen-lockfile
|
|
257
|
-
- run: pnpm turbo run build lint test
|
|
258
|
-
env:
|
|
259
|
-
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
260
|
-
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
## Common Pitfalls
|
|
264
|
-
|
|
265
|
-
| Issue | Fix |
|
|
266
|
-
|-------|-----|
|
|
267
|
-
| `workspace:*` dependency not resolved | Ensure `pnpm-workspace.yaml` includes the package's directory |
|
|
268
|
-
| Circular dependency between packages | Restructure; extract shared code to a third package |
|
|
269
|
-
| Cache hit but stale output | `turbo run build --force` to bypass cache |
|
|
270
|
-
| `turbo` not found | Add to root `devDependencies` or install globally |
|
|
271
|
-
| Nx graph shows wrong dependencies | Check `import` paths; ensure `tsconfig.json` paths are correct |
|
|
272
|
-
| Phantom dependencies | pnpm prevents this by default; don't use `shamefully-hoist` |
|
|
273
|
-
| Type errors across packages | Use `workspace:*` + TypeScript project references |
|
|
274
|
-
| `pnpm install` fails with lockfile conflicts | Use `--frozen-lockfile` in CI; regenerate with `pnpm install --lockfile-only` |
|
|
1
|
+
# Monorepo Build Sub-Skill
|
|
2
|
+
|
|
3
|
+
Manage and build multi-package projects using monorepo tools.
|
|
4
|
+
|
|
5
|
+
**Current version**: Turborepo 2.x / pnpm 9.x / Nx 20.x (2025-2026)
|
|
6
|
+
|
|
7
|
+
## When to Use
|
|
8
|
+
|
|
9
|
+
- Multiple related packages/apps in one repository
|
|
10
|
+
- Shared code (UI components, utilities, types) across projects
|
|
11
|
+
- Need coordinated builds with dependency-aware caching
|
|
12
|
+
- Want atomic commits across packages
|
|
13
|
+
|
|
14
|
+
## Tool Comparison
|
|
15
|
+
|
|
16
|
+
| Feature | Turborepo 2.x | Nx 20.x | pnpm Workspaces |
|
|
17
|
+
|---------|--------------|---------|-----------------|
|
|
18
|
+
| Approach | Build orchestrator | Full dev platform | Package manager feature |
|
|
19
|
+
| Caching | Local + Remote | Local + Remote (Nx Cloud) | Not built-in |
|
|
20
|
+
| Language support | Any | JS/TS, Go, Java, .NET | JS/TS only |
|
|
21
|
+
| Learning curve | Low | Medium | Lowest |
|
|
22
|
+
| Task runner | Built-in (turbo.json) | Built-in (project.json) | Use with Turborepo/Nx |
|
|
23
|
+
| Affected detection | Yes | Yes (more granular) | No |
|
|
24
|
+
| Plugin ecosystem | Smaller | Large (generators, executors) | N/A |
|
|
25
|
+
| Best for | JS/TS monorepos, simplicity | Large teams, polyglot monorepos | Package management only |
|
|
26
|
+
|
|
27
|
+
## pnpm Workspaces (Foundation)
|
|
28
|
+
|
|
29
|
+
Most JS/TS monorepos use pnpm as the package manager regardless of build tool.
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Install pnpm
|
|
33
|
+
npm install -g pnpm@latest
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
# pnpm-workspace.yaml (project root)
|
|
38
|
+
packages:
|
|
39
|
+
- "apps/*"
|
|
40
|
+
- "packages/*"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
my-monorepo/
|
|
45
|
+
├── apps/
|
|
46
|
+
│ ├── web/ # Frontend app
|
|
47
|
+
│ ├── admin/ # Admin dashboard
|
|
48
|
+
│ └── api/ # Backend API
|
|
49
|
+
├── packages/
|
|
50
|
+
│ ├── ui/ # Shared UI components
|
|
51
|
+
│ ├── utils/ # Shared utilities
|
|
52
|
+
│ ├── tsconfig/ # Shared TypeScript configs
|
|
53
|
+
│ └── eslint-config/ # Shared ESLint configs
|
|
54
|
+
├── pnpm-workspace.yaml
|
|
55
|
+
├── pnpm-lock.yaml
|
|
56
|
+
└── package.json
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
// Root package.json
|
|
61
|
+
{
|
|
62
|
+
"name": "my-monorepo",
|
|
63
|
+
"private": true,
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "turbo run build",
|
|
66
|
+
"dev": "turbo run dev",
|
|
67
|
+
"lint": "turbo run lint",
|
|
68
|
+
"test": "turbo run test"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"turbo": "^2.3.0"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
// apps/web/package.json — use workspace: protocol for internal deps
|
|
78
|
+
{
|
|
79
|
+
"name": "@myrepo/web",
|
|
80
|
+
"dependencies": {
|
|
81
|
+
"@myrepo/ui": "workspace:*",
|
|
82
|
+
"@myrepo/utils": "workspace:*"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Turborepo
|
|
88
|
+
|
|
89
|
+
### Configuration
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
// turbo.json
|
|
93
|
+
{
|
|
94
|
+
"$schema": "https://turbo.build/schema.json",
|
|
95
|
+
"tasks": {
|
|
96
|
+
"build": {
|
|
97
|
+
"dependsOn": ["^build"],
|
|
98
|
+
"outputs": ["dist/**", ".next/**", "build/**"],
|
|
99
|
+
"cache": true
|
|
100
|
+
},
|
|
101
|
+
"dev": {
|
|
102
|
+
"cache": false,
|
|
103
|
+
"persistent": true
|
|
104
|
+
},
|
|
105
|
+
"lint": {
|
|
106
|
+
"dependsOn": ["^build"]
|
|
107
|
+
},
|
|
108
|
+
"test": {
|
|
109
|
+
"dependsOn": ["build"],
|
|
110
|
+
"outputs": ["coverage/**"]
|
|
111
|
+
},
|
|
112
|
+
"clean": {
|
|
113
|
+
"cache": false
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Build Commands
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# Build all packages in dependency order
|
|
123
|
+
turbo run build
|
|
124
|
+
|
|
125
|
+
# Build only packages affected by changes
|
|
126
|
+
turbo run build --filter=...[HEAD^1]
|
|
127
|
+
|
|
128
|
+
# Build specific package and its dependencies
|
|
129
|
+
turbo run build --filter=@myrepo/web...
|
|
130
|
+
|
|
131
|
+
# Build with remote caching (Vercel)
|
|
132
|
+
turbo run build --team=myteam --token=$TURBO_TOKEN
|
|
133
|
+
|
|
134
|
+
# Dry run (show execution plan without building)
|
|
135
|
+
turbo run build --dry-run
|
|
136
|
+
|
|
137
|
+
# Run multiple tasks
|
|
138
|
+
turbo run build lint test
|
|
139
|
+
|
|
140
|
+
# Clear cache
|
|
141
|
+
turbo run clean
|
|
142
|
+
turbo prune # Remove unused cache entries
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Remote Caching
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
# Link to Vercel remote cache
|
|
149
|
+
npx turbo login
|
|
150
|
+
npx turbo link
|
|
151
|
+
|
|
152
|
+
# Or self-hosted: set TURBO_API and TURBO_TOKEN
|
|
153
|
+
export TURBO_API=https://my-cache-server.com
|
|
154
|
+
export TURBO_TOKEN=my-token
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Nx
|
|
158
|
+
|
|
159
|
+
### Setup
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Add Nx to existing monorepo
|
|
163
|
+
npx nx init
|
|
164
|
+
|
|
165
|
+
# Or create new Nx workspace
|
|
166
|
+
npx create-nx-workspace my-monorepo --preset=ts
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Configuration
|
|
170
|
+
|
|
171
|
+
```json
|
|
172
|
+
// nx.json
|
|
173
|
+
{
|
|
174
|
+
"tasksRunnerOptions": {
|
|
175
|
+
"default": {
|
|
176
|
+
"runner": "nx/tasks-runners/default",
|
|
177
|
+
"options": {
|
|
178
|
+
"cacheableOperations": ["build", "test", "lint"]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"targetDefaults": {
|
|
183
|
+
"build": {
|
|
184
|
+
"dependsOn": ["^build"],
|
|
185
|
+
"outputs": ["{projectRoot}/dist"]
|
|
186
|
+
},
|
|
187
|
+
"test": {
|
|
188
|
+
"dependsOn": ["build"]
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```json
|
|
195
|
+
// apps/web/project.json
|
|
196
|
+
{
|
|
197
|
+
"name": "web",
|
|
198
|
+
"sourceRoot": "apps/web/src",
|
|
199
|
+
"targets": {
|
|
200
|
+
"build": {
|
|
201
|
+
"executor": "@nx/vite:build",
|
|
202
|
+
"outputs": ["{options.outputPath}"],
|
|
203
|
+
"options": {
|
|
204
|
+
"outputPath": "dist/apps/web"
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
"dev": {
|
|
208
|
+
"executor": "@nx/vite:dev-server"
|
|
209
|
+
},
|
|
210
|
+
"test": {
|
|
211
|
+
"executor": "@nx/vite:test"
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Build Commands
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Build all
|
|
221
|
+
npx nx run-many -t build
|
|
222
|
+
|
|
223
|
+
# Build affected only (compares with main branch)
|
|
224
|
+
npx nx affected -t build
|
|
225
|
+
|
|
226
|
+
# Build specific project
|
|
227
|
+
npx nx build web
|
|
228
|
+
|
|
229
|
+
# Graph visualization
|
|
230
|
+
npx nx graph
|
|
231
|
+
|
|
232
|
+
# Remote cache (Nx Cloud)
|
|
233
|
+
npx nx connect-to-nx-cloud
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## CI/CD — GitHub Actions (Turborepo)
|
|
237
|
+
|
|
238
|
+
```yaml
|
|
239
|
+
name: Monorepo Build
|
|
240
|
+
on:
|
|
241
|
+
push:
|
|
242
|
+
branches: [main]
|
|
243
|
+
pull_request:
|
|
244
|
+
|
|
245
|
+
jobs:
|
|
246
|
+
build:
|
|
247
|
+
runs-on: ubuntu-latest
|
|
248
|
+
steps:
|
|
249
|
+
- uses: actions/checkout@v4
|
|
250
|
+
with:
|
|
251
|
+
fetch-depth: 2 # Needed for affected detection
|
|
252
|
+
- uses: actions/setup-node@v4
|
|
253
|
+
with:
|
|
254
|
+
node-version: '22'
|
|
255
|
+
- run: npm install -g pnpm
|
|
256
|
+
- run: pnpm install --frozen-lockfile
|
|
257
|
+
- run: pnpm turbo run build lint test
|
|
258
|
+
env:
|
|
259
|
+
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
260
|
+
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Common Pitfalls
|
|
264
|
+
|
|
265
|
+
| Issue | Fix |
|
|
266
|
+
|-------|-----|
|
|
267
|
+
| `workspace:*` dependency not resolved | Ensure `pnpm-workspace.yaml` includes the package's directory |
|
|
268
|
+
| Circular dependency between packages | Restructure; extract shared code to a third package |
|
|
269
|
+
| Cache hit but stale output | `turbo run build --force` to bypass cache |
|
|
270
|
+
| `turbo` not found | Add to root `devDependencies` or install globally |
|
|
271
|
+
| Nx graph shows wrong dependencies | Check `import` paths; ensure `tsconfig.json` paths are correct |
|
|
272
|
+
| Phantom dependencies | pnpm prevents this by default; don't use `shamefully-hoist` |
|
|
273
|
+
| Type errors across packages | Use `workspace:*` + TypeScript project references |
|
|
274
|
+
| `pnpm install` fails with lockfile conflicts | Use `--frozen-lockfile` in CI; regenerate with `pnpm install --lockfile-only` |
|