fix(pnpm): merge colliding peer-suffixed v9 snapshot keys#1724
Draft
zlav wants to merge 1 commit into
Draft
Conversation
In pnpm v9, snapshot keys carry a peer-dependency suffix that is stripped so they can be looked up against the (unsuffixed) packages section. A package installed under multiple peer variants yields several snapshot keys that collapse to the same stripped key; the previous `HashMap.mapKeys` collapse was last-wins and silently dropped all but one variant's dependency list. Edges living only on a dropped variant disappeared, so dev-only transitives lost their dev path and were reported as production. Collapse with `HashMap.fromListWith (<>)` instead, unioning the colliding entries' dependency lists so no edges are lost. v5/v6/v7 paths are unaffected (only the v9 snapshots decoder changes). Adds a v9 regression fixture + spec where a dev dependency is present under two peer-suffixed snapshot keys with distinct children. Refs: ANE-2852 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Merge (instead of last-wins overwrite) pnpm v9 snapshot entries whose peer-suffixed keys collapse to the same key, so dev-only transitives stop leaking as production.
Overview
packagessection.HashMap.mapKeys withoutPeerDepSuffixcollapse was last-wins, silently dropping all but one variant's dependency list.HashMap.fromListWith (<>), unioning colliding entries' dependency lists. Only the v9 snapshots decoder changes; v5/v6/v7 paths untouched.Acceptance criteria
devDependencyreachable only via a dropped peer variant (and its transitives) is classifiedEnvDevelopment/ filtered, not production.Testing plan
test/Pnpm/testdata/pnpm-9-peer-collision/pnpm-lock.yaml: a dev dep under two peer-suffixed snapshot keys with distinct children.cabal test unit-tests --match "Pnpm.PnpmLock"→ 26/26 pass.Confidence / for reviewer
pnpm-lock.yaml. Reviewer should confirm against the actual lockfile (the leaking edge could be a genuine prod path rather than a collision) and watch for v6/v7 regressions.Why not to merge this
(<>)concatenates dep-pair lists, so duplicate(name, rev)pairs across variants are kept; harmless (edges are idempotent) but slightly larger intermediate lists.peerDependenciesranges indeepDependenciesas a possible spurious prod→dev bridge; deliberately left out to keep this surgical.References