mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-21 05:02:30 -04:00
The inherit/synthesize logic for peer-variant snapshots (which legally omit `resolution` because they inherit it from the base entry) was previously inlined in `buildGraphFromPackages` and `createDeployFiles`. Auditing every caller of `pkgSnapshotToResolution` surfaced four more iteration sites that dereference `pkgSnapshot.resolution` directly on a raw `lockfile.packages` entry and therefore had the same latent crash: - `lockfileToHoistedDepGraph` — `pnpm install --node-linker=hoisted` - `collectSbomComponents` — `pnpm sbom` - `getPkgInfo` — `pnpm list` / tree view - (graph-builder + createDeployFiles, already fixed inline) Extract the inherit/synthesize logic into a new exported helper in `@pnpm/lockfile.utils` and call it at every iteration site. Downstream code paths — `pkgSnapshotToResolution`, `convertPackageSnapshot`, `'directory' in resolution`, `'integrity' in resolution` — now all see a fully-formed snapshot regardless of which command entered the loop. The synthesize-from-`file:` fallback (covers pruned lockfiles, e.g. `turbo prune --docker` keeping only the variant entry) is now documented in the helper to discourage future readers from widening it to other `file:` shapes (`file:./local-tarball.tgz` etc., which reach a different code path). Unit tests for the helper added in `lockfile/utils/test/`. The existing fixture-based regression test in `installing/deps-restorer/test/index.ts` continues to cover the install-path end-to-end.