Skip to content

Commit 922463a

Browse files
committed
fix(migration): overwrite workspace yaml overrides and handle force-mode vite-plus
Always overwrite pnpm-workspace.yaml overrides when migrating from package.json, since the package.json value was the effective one (pnpm ignores workspace overrides when pnpm.overrides exists). Also write the vite-plus override to pnpm-workspace.yaml in force mode for standalone projects without existing pnpm config.
1 parent 4a56523 commit 922463a

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

  • packages/cli
    • snap-tests-global/migration-monorepo-pnpm-overrides-dependency-selector
    • src/migration

packages/cli/snap-tests-global/migration-monorepo-pnpm-overrides-dependency-selector/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ catalog:
4545

4646
overrides:
4747
'@vitejs/plugin-react>vite': 'npm:vite@<semver>'
48-
'supertest>superagent': '9.0.2'
48+
'supertest>superagent': <semver>
4949
vite: 'catalog:'
5050
vitest: 'catalog:'
5151
react-click-away-listener>react: <semver>

packages/cli/src/migration/migrator.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,13 @@ export function rewriteStandaloneProject(
730730
usePnpmWorkspaceYaml = !pkg.pnpm;
731731
if (usePnpmWorkspaceYaml) {
732732
rewritePnpmWorkspaceYaml(projectPath);
733+
// In force-override mode, also override vite-plus itself so transitive
734+
// deps resolve to the local tgz instead of the published version.
735+
if (isForceOverrideMode() && !VITE_PLUS_VERSION.startsWith('file:')) {
736+
migratePnpmOverridesToWorkspaceYaml(projectPath, {
737+
[VITE_PLUS_NAME]: VITE_PLUS_VERSION,
738+
});
739+
}
733740
}
734741
const overrideKeys = Object.keys(VITE_PLUS_OVERRIDE_PACKAGES);
735742
if (!usePnpmWorkspaceYaml) {
@@ -1056,9 +1063,9 @@ function migratePnpmOverridesToWorkspaceYaml(
10561063
const pnpmWorkspaceYamlPath = path.join(projectPath, 'pnpm-workspace.yaml');
10571064
editYamlFile(pnpmWorkspaceYamlPath, (doc) => {
10581065
for (const [key, value] of Object.entries(overrides)) {
1059-
if (!doc.hasIn(['overrides', key])) {
1060-
doc.setIn(['overrides', scalarString(key)], scalarString(value));
1061-
}
1066+
// Always overwrite: package.json value was the effective one before migration
1067+
// (pnpm ignores workspace overrides when pnpm.overrides exists in package.json)
1068+
doc.setIn(['overrides', scalarString(key)], scalarString(value));
10621069
}
10631070
});
10641071
}

0 commit comments

Comments
 (0)