fix: rebuild should not fail if an index file is not found in the store (#9788)

This commit is contained in:
Zoltan Kochan
2025-07-23 11:48:46 +02:00
committed by GitHub
parent cefe4bf174
commit 15ba5ab931
2 changed files with 17 additions and 7 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/plugin-commands-rebuild": patch
---
Rebuild should not fail if it cannot find an index file in the store for the built package.

View File

@@ -345,13 +345,18 @@ async function _rebuild (
const pkgId = `${pkgInfo.name}@${pkgInfo.version}`
if (opts.skipIfHasSideEffectsCache && resolution.integrity) {
const filesIndexFile = getIndexFilePathInCafs(opts.storeDir, resolution.integrity!.toString(), pkgId)
const pkgFilesIndex = await loadJsonFile<PackageFilesIndex>(filesIndexFile)
sideEffectsCacheKey = calcDepState(depGraph, depsStateCache, depPath, {
includeDepGraphHash: true,
})
if (pkgFilesIndex.sideEffects?.[sideEffectsCacheKey]) {
pkgsThatWereRebuilt.add(depPath)
return
let pkgFilesIndex: PackageFilesIndex | undefined
try {
pkgFilesIndex = await loadJsonFile<PackageFilesIndex>(filesIndexFile)
} catch {}
if (pkgFilesIndex) {
sideEffectsCacheKey = calcDepState(depGraph, depsStateCache, depPath, {
includeDepGraphHash: true,
})
if (pkgFilesIndex.sideEffects?.[sideEffectsCacheKey]) {
pkgsThatWereRebuilt.add(depPath)
return
}
}
}
let requiresBuild = true