Skip to content

Commit 65bcccf

Browse files
authored
fix: don't check .yarn/patches for computing dependencies hash (#11168)
1 parent 5170e44 commit 65bcccf

File tree

1 file changed

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

1 file changed

+8
-9
lines changed

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

+8-9
Original file line numberDiff line numberDiff line change
@@ -1043,10 +1043,10 @@ function isSingleDefaultExport(exports: readonly string[]) {
10431043
}
10441044

10451045
const lockfileFormats = [
1046-
{ name: 'package-lock.json', patchesDirs: ['patches'] }, // Default of https://github.com/ds300/patch-package
1047-
{ name: 'yarn.lock', patchesDirs: ['patches', '.yarn/patches'] }, // .yarn/patches for v2+
1048-
{ name: 'pnpm-lock.yaml', patchesDirs: [] }, // Included in lockfile
1049-
{ name: 'bun.lockb', patchesDirs: ['patches'] },
1046+
{ name: 'package-lock.json', checkPatches: true },
1047+
{ name: 'yarn.lock', checkPatches: true }, // Included in lockfile for v2+
1048+
{ name: 'pnpm-lock.yaml', checkPatches: false }, // Included in lockfile
1049+
{ name: 'bun.lockb', checkPatches: true },
10501050
]
10511051

10521052
export function getDepHash(config: ResolvedConfig, ssr: boolean): string {
@@ -1058,17 +1058,16 @@ export function getDepHash(config: ResolvedConfig, ssr: boolean): string {
10581058
let content = lockfilePath ? fs.readFileSync(lockfilePath, 'utf-8') : ''
10591059
if (lockfilePath) {
10601060
const lockfileName = path.basename(lockfilePath)
1061-
const { patchesDirs } = lockfileFormats.find(
1061+
const { checkPatches } = lockfileFormats.find(
10621062
(f) => f.name === lockfileName,
10631063
)!
1064-
const dependenciesRoot = path.dirname(lockfilePath)
1065-
for (const patchesDir of patchesDirs) {
1066-
const fullPath = path.join(dependenciesRoot, patchesDir)
1064+
if (checkPatches) {
1065+
// Default of https://github.com/ds300/patch-package
1066+
const fullPath = path.join(path.dirname(lockfilePath), 'patches')
10671067
if (fs.existsSync(fullPath)) {
10681068
const stats = fs.statSync(fullPath)
10691069
if (stats.isDirectory()) {
10701070
content += stats.mtimeMs.toString()
1071-
break
10721071
}
10731072
}
10741073
}

0 commit comments

Comments
 (0)