Skip to content

Commit 801f910

Browse files
committed
fix(deps-optimization): detect yarn dependency changes correctly (#17336)
1 parent 5f10e62 commit 801f910

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
@@ -1145,28 +1145,45 @@ function isSingleDefaultExport(exports: readonly string[]) {
11451145
}
11461146

11471147
const lockfileFormats = [
1148-
// Prefer over package-lock.json as it will only be updated after `npm install` ran
11491148
{
11501149
name: '.package-lock.json',
11511150
path: 'node_modules/.package-lock.json',
11521151
checkPatches: true,
11531152
manager: 'npm',
11541153
},
1155-
{ name: 'package-lock.json', checkPatches: true, manager: 'npm' },
1156-
{ name: 'yarn.lock', checkPatches: true, manager: 'yarn' }, // Included in lockfile for v2+
1157-
// Prefer over pnpm-lock.yaml as it will only be updated after `pnpm install` ran
1154+
{
1155+
// Yarn non-PnP
1156+
name: '.yarn-state.yml',
1157+
path: 'node_modules/.yarn-state.yml',
1158+
checkPatches: false,
1159+
manager: 'yarn',
1160+
},
1161+
{
1162+
// Yarn PnP
1163+
name: 'install-state',
1164+
path: '.yarn/install-state',
1165+
checkPatches: false,
1166+
manager: 'yarn',
1167+
},
1168+
{
1169+
// yarn 1
1170+
name: '.yarn-integrity',
1171+
path: 'node_modules/.yarn-integrity',
1172+
checkPatches: true,
1173+
manager: 'yarn',
1174+
},
11581175
{
11591176
name: 'lock.yaml',
11601177
path: 'node_modules/.pnpm/lock.yaml',
1178+
// Included in lockfile
11611179
checkPatches: false,
11621180
manager: 'pnpm',
1163-
}, // Included in lockfile
1164-
{ name: 'pnpm-lock.yaml', checkPatches: false, manager: 'pnpm' }, // Included in lockfile
1165-
{ name: 'bun.lockb', checkPatches: true, manager: 'bun' },
1181+
},
1182+
{ name: 'bun.lockb', path: 'bun.lockb', checkPatches: true, manager: 'bun' },
11661183
].sort((_, { manager }) => {
11671184
return process.env.npm_config_user_agent?.startsWith(manager) ? 1 : -1
11681185
})
1169-
const lockfilePaths = lockfileFormats.map((l) => l.path ?? l.name)
1186+
const lockfilePaths = lockfileFormats.map((l) => l.path)
11701187

11711188
function getConfigHash(environment: Environment): string {
11721189
// Take config into account

0 commit comments

Comments
 (0)