Skip to content

Commit a938cf5

Browse files
committed
fix(cli): fix yarn install failure in vp create
Two issues caused yarn install to fail in CI for newly created projects: 1. In CI (CI=true), yarn Berry defaults to enableImmutableInstalls which prevents creating a new lockfile. Pass --no-frozen-lockfile to vp install since vp create always needs to generate a fresh lockfile. 2. Standalone yarn projects had no .yarnrc.yml created during migration. Without nodeLinker: node-modules, yarn 4 defaults to PnP which doesn't work with vite-plus. Now rewriteYarnrcYml() ensures nodeLinker is set and is called for standalone projects too. Also removes all yarn exclusions from the create e2e test workflow (full 12-job matrix now enabled).
1 parent 2f889e9 commit a938cf5

3 files changed

Lines changed: 25 additions & 18 deletions

File tree

.github/workflows/test-vp-create.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,6 @@ jobs:
138138
- npm
139139
- yarn
140140
- bun
141-
exclude:
142-
# FIXME: yarn install fails with absolute file: paths to tgz
143-
# https://github.com/voidzero-dev/vite-plus/issues/XXX
144-
- package-manager: yarn
145-
template:
146-
name: monorepo
147-
- package-manager: yarn
148-
template:
149-
name: application
150-
- package-manager: yarn
151-
template:
152-
name: library
153141
env:
154142
VP_OVERRIDE_PACKAGES: '{"vite":"file:${{ github.workspace }}/tmp/tgz/voidzero-dev-vite-plus-core-0.0.0.tgz","vitest":"file:${{ github.workspace }}/tmp/tgz/voidzero-dev-vite-plus-test-0.0.0.tgz","@voidzero-dev/vite-plus-core":"file:${{ github.workspace }}/tmp/tgz/voidzero-dev-vite-plus-core-0.0.0.tgz","@voidzero-dev/vite-plus-test":"file:${{ github.workspace }}/tmp/tgz/voidzero-dev-vite-plus-test-0.0.0.tgz"}'
155143
VP_VERSION: 'file:${{ github.workspace }}/tmp/tgz/vite-plus-0.0.0.tgz'

packages/cli/src/create/bin.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -804,9 +804,14 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
804804
installGitHooks(fullPath, compactOutput);
805805
}
806806
updateCreateProgress('Installing dependencies');
807-
const installSummary = await runViteInstall(fullPath, options.interactive, undefined, {
808-
silent: compactOutput,
809-
});
807+
const installSummary = await runViteInstall(
808+
fullPath,
809+
options.interactive,
810+
['--no-frozen-lockfile'],
811+
{
812+
silent: compactOutput,
813+
},
814+
);
810815
updateCreateProgress('Formatting code');
811816
await runViteFmt(fullPath, options.interactive, undefined, { silent: compactOutput });
812817
clearCreateProgress();
@@ -955,9 +960,14 @@ Use \`vp create --list\` to list all available templates, or run \`vp create --h
955960

956961
updateWorkspaceConfig(projectDir, workspaceInfo);
957962
updateCreateProgress('Installing dependencies');
958-
installSummary = await runViteInstall(workspaceInfo.rootDir, options.interactive, undefined, {
959-
silent: compactOutput,
960-
});
963+
installSummary = await runViteInstall(
964+
workspaceInfo.rootDir,
965+
options.interactive,
966+
['--no-frozen-lockfile'],
967+
{
968+
silent: compactOutput,
969+
},
970+
);
961971
updateCreateProgress('Formatting code');
962972
await runViteFmt(workspaceInfo.rootDir, options.interactive, [projectDir], {
963973
silent: compactOutput,

packages/cli/src/migration/migrator.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,11 @@ export function rewriteStandaloneProject(
810810
migratePnpmOverridesToWorkspaceYaml(projectPath, remainingPnpmOverrides);
811811
}
812812

813+
// Ensure .yarnrc.yml exists with nodeLinker for standalone yarn projects
814+
if (packageManager === PackageManager.yarn) {
815+
rewriteYarnrcYml(projectPath);
816+
}
817+
813818
// Merge extracted staged config into vite.config.ts, then remove lint-staged from package.json
814819
if (extractedStagedConfig) {
815820
if (mergeStagedConfigToViteConfig(projectPath, extractedStagedConfig, silent, report)) {
@@ -1116,6 +1121,10 @@ function rewriteYarnrcYml(projectPath: string): void {
11161121
}
11171122

11181123
editYamlFile(yarnrcYmlPath, (doc) => {
1124+
// Ensure nodeLinker is set to node-modules (yarn 4 defaults to PnP)
1125+
if (!doc.has('nodeLinker')) {
1126+
doc.set('nodeLinker', 'node-modules');
1127+
}
11191128
// catalog
11201129
rewriteCatalog(doc);
11211130
});

0 commit comments

Comments
 (0)