Skip to content

Commit a3fec97

Browse files
committed
fix(deps-optimization): detect yarn dependency changes correctly (#17336)
1 parent e60a6af commit a3fec97

File tree

1 file changed

+25
-8
lines changed
  • packages/vite/src/node/optimizer

1 file changed

+25
-8
lines changed

packages/vite/src/node/optimizer/index.ts

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,28 +1150,45 @@ function isSingleDefaultExport(exports: readonly string[]) {
11501150
}
11511151

11521152
const lockfileFormats = [
1153-
// Prefer over package-lock.json as it will only be updated after `npm install` ran
11541153
{
11551154
name: '.package-lock.json',
11561155
path: 'node_modules/.package-lock.json',
11571156
checkPatches: true,
11581157
manager: 'npm',
11591158
},
1160-
{ name: 'package-lock.json', checkPatches: true, manager: 'npm' },
1161-
{ name: 'yarn.lock', checkPatches: true, manager: 'yarn' }, // Included in lockfile for v2+
1162-
// Prefer over pnpm-lock.yaml as it will only be updated after `pnpm install` ran
1159+
{
1160+
// Yarn non-PnP
1161+
name: '.yarn-state.yml',
1162+
path: 'node_modules/.yarn-state.yml',
1163+
checkPatches: false,
1164+
manager: 'yarn',
1165+
},
1166+
{
1167+
// Yarn PnP
1168+
name: 'install-state',
1169+
path: '.yarn/install-state',
1170+
checkPatches: false,
1171+
manager: 'yarn',
1172+
},
1173+
{
1174+
// yarn 1
1175+
name: '.yarn-integrity',
1176+
path: 'node_modules/.yarn-integrity',
1177+
checkPatches: true,
1178+
manager: 'yarn',
1179+
},
11631180
{
11641181
name: 'lock.yaml',
11651182
path: 'node_modules/.pnpm/lock.yaml',
1183+
// Included in lockfile
11661184
checkPatches: false,
11671185
manager: 'pnpm',
1168-
}, // Included in lockfile
1169-
{ name: 'pnpm-lock.yaml', checkPatches: false, manager: 'pnpm' }, // Included in lockfile
1170-
{ name: 'bun.lockb', checkPatches: true, manager: 'bun' },
1186+
},
1187+
{ name: 'bun.lockb', path: 'bun.lockb', checkPatches: true, manager: 'bun' },
11711188
].sort((_, { manager }) => {
11721189
return process.env.npm_config_user_agent?.startsWith(manager) ? 1 : -1
11731190
})
1174-
const lockfilePaths = lockfileFormats.map((l) => l.path ?? l.name)
1191+
const lockfilePaths = lockfileFormats.map((l) => l.path)
11751192

11761193
function getConfigHash(environment: Environment): string {
11771194
// Take config into account

0 commit comments

Comments
 (0)