Skip to content

Commit adf61d9

Browse files
authored
fix: handle more yarn pnp load errors (#13160)
1 parent ee80aba commit adf61d9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

packages/vite/src/node/packages.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,18 @@ export function resolvePackageData(
5858
const cacheKey = getRpdCacheKey(pkgName, basedir, preserveSymlinks)
5959
if (packageCache?.has(cacheKey)) return packageCache.get(cacheKey)!
6060

61-
let pkg: string | null
6261
try {
63-
pkg = pnp.resolveToUnqualified(pkgName, basedir, {
62+
const pkg = pnp.resolveToUnqualified(pkgName, basedir, {
6463
considerBuiltins: false,
6564
})
65+
if (!pkg) return null
66+
67+
const pkgData = loadPackageData(path.join(pkg, 'package.json'))
68+
packageCache?.set(cacheKey, pkgData)
69+
return pkgData
6670
} catch {
6771
return null
6872
}
69-
if (!pkg) return null
70-
71-
const pkgData = loadPackageData(path.join(pkg, 'package.json'))
72-
packageCache?.set(cacheKey, pkgData)
73-
74-
return pkgData
7573
}
7674

7775
const originalBasedir = basedir

0 commit comments

Comments
 (0)