feat: add pnpm lockfile v9 support - #198
Merged
Merged
Conversation
Corrects existing test fixture from lockfileVersion '9.0' to '6.0' — the fixture uses v5/v6 package key format (/name/version) which is inconsistent with a v9 declaration. Adds a new test covering pnpm lockfile v9 format: snapshots section, name@version keys, scoped packages, dev flag, transitive paths, and peer-dep suffix stripping.
pnpm v9 changed two things that broke the parser: package keys moved
from /name/version to name@version format, and the dependency graph
moved from the packages section to a new snapshots section.
Adds version detection at parse entry — major >= 9 routes to loadV9,
everything else to loadLegacy (existing logic, extracted verbatim).
loadV9 reads snapshots for the dependency graph and dev flags.
parsePnpmPackageKeyV9 handles name@version keys using lastIndexOf('@')
to correctly split scoped packages and strip peer-dep suffixes.
normalizePnpmDepRefV9 generates name@version graph keys.
Both BFS loops now track visited keys rather than key+path combinations,
reducing complexity from exponential to O(V+E) and preventing infinite
traversal through circular dependencies present in real-world monorepos.
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.
Summary
lockfileVersion: '9.0') — the default since pnpm v8.6.0 (September 2023)lockfileVersion: '9.0'while using v5/v6 package keysRoot cause
pnpm v9 introduced two breaking changes to the lockfile format:
/name/versiontoname@versionpackagessection to a newsnapshotssectionThe parser only handled the v5/v6 format, so all packages were silently skipped on v9 lockfiles.
Changes
src/parsers/pnpm-lock.tsloadFromPnpmLockdetectslockfileVersionand routes major ≥ 9 toloadV9, otherwise toloadLegacyloadLegacy— existing logic extracted verbatim, zero behavior changeloadV9— readssnapshots, usesname@versionkeys throughoutparsePnpmPackageKeyV9— splits keys usinglastIndexOf('@')for correct scoped package handling, strips peer-dep suffixesnormalizePnpmDepRefV9— generatesname@versiongraph keystests/parsers.test.tslockfileVersion: '9.0'→'6.0'Verification
Tested against the Analog monorepo (
pnpm-lock.yaml, 3367 packages, lockfileVersion 9.0):Closes #194