Skip to content

Commit 4d98aae

Browse files
committed
docs(rfc): update migration RFC for pnpm config location logic
1 parent 57558e2 commit 4d98aae

1 file changed

Lines changed: 36 additions & 8 deletions

File tree

rfcs/migration-command.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ When transitioning to Vite+, projects typically use standalone tools like vite,
3232

3333
-**Dependencies**: vite, vitest, oxlint, oxfmt → vite-plus
3434
-**Overrides**: Force vite → vite-plus (for all dependencies)
35-
- pnpm: Writes `overrides`, `peerDependencyRules`, and `catalog` to `pnpm-workspace.yaml`
35+
- pnpm (no existing `pnpm` config): Writes `overrides`, `peerDependencyRules`, and `catalog` to `pnpm-workspace.yaml`
36+
- pnpm (existing `pnpm` config): Adds `pnpm.overrides` and `pnpm.peerDependencyRules` in `package.json`
3637
- npm/bun: Adds `overrides.vite` mapping in `package.json`
3738
- yarn: Adds `resolutions.vite` mapping in `package.json`
3839
- **Benefit**: Code keeps `import from 'vite'` - automatically resolves to vite-plus
@@ -212,7 +213,7 @@ Wrote agent instructions to AGENTS.md
212213
}
213214
```
214215

215-
**After (pnpm) -- `package.json`:**
216+
**After (pnpm, no existing `pnpm` config) -- `package.json`:**
216217

217218
```json
218219
{
@@ -221,15 +222,16 @@ Wrote agent instructions to AGENTS.md
221222
"react": "^18.2.0"
222223
},
223224
"devDependencies": {
224-
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
225-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
226-
"@vitejs/plugin-react": "^4.2.0"
225+
"vite": "catalog:",
226+
"vitest": "catalog:",
227+
"@vitejs/plugin-react": "^4.2.0",
228+
"vite-plus": "catalog:"
227229
},
228230
"packageManager": "pnpm@<semver>"
229231
}
230232
```
231233

232-
**After (pnpm) -- `pnpm-workspace.yaml`:**
234+
**After (pnpm, no existing `pnpm` config) -- `pnpm-workspace.yaml`:**
233235

234236
```yaml
235237
catalog:
@@ -248,10 +250,36 @@ peerDependencyRules:
248250
vitest: '*'
249251
```
250252
253+
**After (pnpm, existing `pnpm` config) -- `package.json`:**
254+
255+
Projects that already have a `pnpm` field in `package.json` (e.g., with `overrides` or `onlyBuiltDependencies`) keep using `package.json` for pnpm config:
256+
257+
```json
258+
{
259+
"name": "my-package",
260+
"devDependencies": {
261+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
262+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest",
263+
"vite-plus": "latest"
264+
},
265+
"pnpm": {
266+
"overrides": {
267+
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
268+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
269+
},
270+
"peerDependencyRules": {
271+
"allowAny": ["vite", "vitest"],
272+
"allowedVersions": { "vite": "*", "vitest": "*" }
273+
}
274+
}
275+
}
276+
```
277+
251278
**Important**:
252279

253280
- `overrides.vite` ensures any dependency requiring `vite` gets `vite-plus` instead
254-
- For pnpm, all overrides and peerDependencyRules are written to `pnpm-workspace.yaml` (both standalone and monorepo projects)
281+
- For pnpm without existing config, overrides and peerDependencyRules are written to `pnpm-workspace.yaml`
282+
- For pnpm with existing `pnpm` config in `package.json`, the existing location is respected
255283
- rewrite `import from 'vite'` to `import from 'vite-plus'`
256284
- rewrite `import from 'vite/{name}'` to `import from 'vite-plus/{name}'`, e.g.: `import from 'vite/module-runner'` to `import from 'vite-plus/module-runner'`
257285
- rewrite `import from 'vitest'` to `import from 'vite-plus/test'`
@@ -468,7 +496,7 @@ export default defineConfig({
468496

469497
### for pnpm
470498

471-
pnpm overrides, peerDependencyRules, and catalog are written to `pnpm-workspace.yaml` for both standalone and monorepo projects.
499+
For monorepo projects and standalone projects without existing `pnpm` config in `package.json`, overrides, peerDependencyRules, and catalog are written to `pnpm-workspace.yaml`. Projects with existing `pnpm` config in `package.json` keep using `package.json`.
472500

473501
`pnpm-workspace.yaml`
474502

0 commit comments

Comments
 (0)