Skip to content

Commit

Permalink
fix: handle more yarn pnp load errors (#13160)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed May 13, 2023
1 parent ee80aba commit adf61d9
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/vite/src/node/packages.ts
Expand Up @@ -58,20 +58,18 @@ export function resolvePackageData(
const cacheKey = getRpdCacheKey(pkgName, basedir, preserveSymlinks)
if (packageCache?.has(cacheKey)) return packageCache.get(cacheKey)!

let pkg: string | null
try {
pkg = pnp.resolveToUnqualified(pkgName, basedir, {
const pkg = pnp.resolveToUnqualified(pkgName, basedir, {
considerBuiltins: false,
})
if (!pkg) return null

const pkgData = loadPackageData(path.join(pkg, 'package.json'))
packageCache?.set(cacheKey, pkgData)
return pkgData
} catch {
return null
}
if (!pkg) return null

const pkgData = loadPackageData(path.join(pkg, 'package.json'))
packageCache?.set(cacheKey, pkgData)

return pkgData
}

const originalBasedir = basedir
Expand Down

0 comments on commit adf61d9

Please sign in to comment.