Repository navigation
Conversation
… auto-install-peers
An importer's lockfile entry was built from every hoisted direct
dependency the manifest declared anywhere, `peerDependencies` included.
The peer hoist runs whenever a missing peer can be satisfied from a
version already resolved in the workspace, so with
`autoInstallPeers: false` a project's own optional peer became a direct
dependency of its importer as soon as a sibling project resolved a
matching version, and got linked into that project's `node_modules`.
The TypeScript CLI folds `peerDependencies` into an importer's
dependencies only under `autoInstallPeers`
(`getAllDependenciesFromManifest(manifest, { autoInstallPeers })` in
`installing/deps-resolver/src/index.ts`); peers hoisted with the setting
off never reach the importer entry and stay reachable only through the
snapshots graph. `read_manifest_specifier` now applies the same gate,
which also matches pacquet's lockfile freshness check — its peer fold is
already gated on the same setting, so the two now agree on which
importer entries a manifest is expected to have.
The hoist itself is not the divergence: both stacks hoist the optional
peer and record the resulting peer context on the dependent, verified by
running the two CLIs over the same workspace on the mocked registry.
The fix is pacquet-only; the TypeScript CLI already behaves this way and
gets a regression test for the same scenario.
Closes #13325
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Warning Review limit reached
Next review available in: 15 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change prevents optional peer dependencies from entering workspace importer lockfile entries or ChangesOptional peer importer handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant WorkspaceInstall
participant ImporterBuilder
participant Lockfile
participant NodeModules
WorkspaceInstall->>ImporterBuilder: pass autoInstallPeers=false
ImporterBuilder->>Lockfile: omit peer-only importer entry
Lockfile->>NodeModules: do not link optional peer
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix lockfile importer entries for optional peers when autoInstallPeers is false
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (3): Last reviewed commit: "test(cli): read the workspace lockfile s..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Leftover dbg!(pkg_a) in test
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/cli/tests/workspace_install.rs`:
- Around line 263-284: Extend the parity fixture across both implementations: in
pnpm/crates/cli/tests/workspace_install.rs lines 263-284, capture pacquet’s
lockfile and relevant pkg-a node_modules layout, then compare them byte-for-byte
and by importer entries/symlinks with the TypeScript pnpm baseline. In
pnpm11/installing/deps-installer/test/install/peerDependencies.ts lines
1579-1583, provide or consume the same fixture/baseline and assert the
equivalent lockfile bytes and importer-entry/link presence or absence; retain
the existing optional-peer expectations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 4f62a3b6-36b0-447d-9f79-99fd8c547d6b
📒 Files selected for processing (5)
.changeset/optional-peers-stay-out-of-importers.mdpnpm/crates/cli/tests/workspace_install.rspnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rspnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rspnpm11/installing/deps-installer/test/install/peerDependencies.ts
|
Re: Qodo's
This PR's implementation is Rust-only. The one TypeScript file it touches is a test ( The cited precedent, #13337, is a parity change: it modified the implementation on both sides ( Written by an agent (Claude Code, claude-opus-5). |
The regression tests for #13325 asserted only that the optional peer is absent from the importer, which two stacks can satisfy while still writing different lockfiles. Both now also assert the entry the scenario does produce — `1.0.0(@pnpm.e2e/[email protected])` on the dependent — so the pair pins one observable result rather than two independent absences, and each test names its counterpart. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit db5ccb9 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…eer test The importer assertions matched substrings of a hand-sliced `pnpm-lock.yaml` section, so a formatting change or an extra dependency entry could flip them either way. Read the lockfile through the typed `read_lockfile` / `importer` / `importer_version` helpers this test crate already has, which also lets the absence check cover all three importer dependency groups by key instead of by rendered text. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Qodo round 2:
Written by an agent (Claude Code, claude-opus-5). |
Thanks for the update. The changes address finding 2 with typed lockfile assertions and preserve both the importer absence check and peer-context regression coverage. Finding 1 remains open because the changeset intentionally targets only the Rust implementation and omits the |
|
Code review by qodo was updated up to the latest commit 0abcca7 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Qodo round 3 — both new findings accepted, fixed in e2a45ed.
The changeset finding stays declined for the reason given above. Written by an agent (Claude Code, claude-opus-5). |
Resolving the Astro workspace with pacquet produced a `pnpm-lock.yaml`
that differed from pnpm 11's by 306 lines. Two independent bugs account
for 143 of them.
`dedupe_injected_deps` splits a resolved package id into its name and
its `file:` payload on the first `@`. A scoped id
(`@test/pkg@file:packages/…`) starts with `@`, so the split returned the
scope tail and the `file:` strip failed — the injected workspace dep was
never recognized and stayed a `file:` snapshot where pnpm records
`link:`. Split on the whole `@file:` separator instead.
`extract_children` walked every entry of `dependencies` and
`optionalDependencies`, including the ones the manifest declares as
bundled. npm ships those inside the package's own tarball, and pnpm's
`getNonDevWantedDependencies` filters them out before resolution; the
missing filter pulled extra packages into the lockfile (`napi-wasm`
under `@parcel/watcher-wasm`, the whole `@napi-rs`/`@emnapi` set under
`@tailwindcss/oxide-wasm32-wasi`). Both spellings are honored, and
`true` means every entry of `dependencies`, matching npm. The bundled
set is computed once and shared by both `collect_deps` calls, so an
alias declared in both groups is dropped from both — upstream filters
the merged `{...optionalDependencies, ...dependencies}` map and reaches
the same result. The alias validation still runs over bundled entries
so an unusable alias is rejected either way, as it is upstream.
A third divergence from the same reproduction — a project's own
`peerDependencies` reaching its lockfile importer entry without
`autoInstallPeers` — landed separately as #13372 while this was
in review, so it is no longer part of this change.
The remaining divergences — the `parentPkgAliases` arm of upstream's
peer-shadowed-dependency omission, and local `file:*.tgz` tarballs
resolving without a manifest — are described in the issue; both need
design work beyond this change.
Related to #13334.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13372 +/- ##
=======================================
Coverage 87.21% 87.21%
=======================================
Files 536 536
Lines 92049 92059 +10
=======================================
+ Hits 80283 80293 +10
Misses 11766 11766 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Resolving the Astro workspace with pacquet produced a `pnpm-lock.yaml`
that differed from pnpm 11's by 306 lines. Two independent bugs account
for 143 of them.
`dedupe_injected_deps` splits a resolved package id into its name and
its `file:` payload on the first `@`. A scoped id
(`@test/pkg@file:packages/…`) starts with `@`, so the split returned the
scope tail and the `file:` strip failed — the injected workspace dep was
never recognized and stayed a `file:` snapshot where pnpm records
`link:`. Split on the whole `@file:` separator instead.
`extract_children` walked every entry of `dependencies` and
`optionalDependencies`, including the ones the manifest declares as
bundled. npm ships those inside the package's own tarball, and pnpm's
`getNonDevWantedDependencies` filters them out before resolution; the
missing filter pulled extra packages into the lockfile (`napi-wasm`
under `@parcel/watcher-wasm`, the whole `@napi-rs`/`@emnapi` set under
`@tailwindcss/oxide-wasm32-wasi`). Both spellings are honored, and
`true` means every entry of `dependencies`, matching npm. The bundled
set is computed once and shared by both `collect_deps` calls, so an
alias declared in both groups is dropped from both — upstream filters
the merged `{...optionalDependencies, ...dependencies}` map and reaches
the same result. The alias validation still runs over bundled entries
so an unusable alias is rejected either way, as it is upstream.
A third divergence from the same reproduction — a project's own
`peerDependencies` reaching its lockfile importer entry without
`autoInstallPeers` — landed separately as #13372 while this was
in review, so it is no longer part of this change.
The remaining divergences — the `parentPkgAliases` arm of upstream's
peer-shadowed-dependency omission, and local `file:*.tgz` tarballs
resolving without a manifest — are described in the issue; both need
design work beyond this change.
Related to #13334.
|
Correction on my previous comment: this PR merged (d17710c) about five minutes before I pushed They now live in #13378: the Written by an agent (Claude Code, claude-opus-5). |
…13378) `Path::exists` follows the link, so a dangling `peer-c` link in pkg-a's `node_modules` would have read as "not linked" and passed the check; `symlink_metadata` fails only when nothing is there at all. The importer snapshot moves from an unconditional `dbg!` into the assertion message, so it is printed when a check fails rather than on every run. Follow-up to #13372, which merged before this commit landed.
…13381) The hoist rounds ran on every install, so a missing peer that some version elsewhere in the workspace could satisfy was installed even with `autoInstallPeers: false` and `dedupePeerDependents: false` — the dependent then carried a peer context the TypeScript CLI never writes. Upstream derives one flag from the two settings — `hoistPeers = autoInstallPeers || dedupePeerDependents` in `installing/deps-resolver/src/resolveDependencyTree.ts` — and `resolveRootDependencies` returns before the hoist loop when it is false: hoisting a peer nobody asked to install only pays off if peer-suffixed variants are being collapsed. `ImporterHoistState` now carries the same derived flag and both rounds no-op when it is unset, which leaves the peer missing and the dependent's snapshot free of a peer suffix. The final peer pass is untouched, so unmet peers are still reported. Verified against the TypeScript CLI on a two-project workspace: all four `autoInstallPeers` x `dedupePeerDependents` combinations now produce byte-identical lockfiles, where the both-off combination previously diverged. Follow-up to #13372.
… auto-install-peers (pnpm#13372) An importer's lockfile entry was built from every hoisted direct dependency the manifest declared anywhere, `peerDependencies` included. The peer hoist runs whenever a missing peer can be satisfied from a version already resolved in the workspace, so with `autoInstallPeers: false` a project's own optional peer became a direct dependency of its importer as soon as a sibling project resolved a matching version, and got linked into that project's `node_modules`. The TypeScript CLI folds `peerDependencies` into an importer's dependencies only under `autoInstallPeers` (`getAllDependenciesFromManifest(manifest, { autoInstallPeers })` in `installing/deps-resolver/src/index.ts`); peers hoisted with the setting off never reach the importer entry and stay reachable only through the snapshots graph. `read_manifest_specifier` now applies the same gate, which also matches pacquet's lockfile freshness check — its peer fold is already gated on the same setting, so the two now agree on which importer entries a manifest is expected to have. The fix is pacquet-only: the TypeScript CLI already behaves this way, and gets a regression test for the same scenario. Closes pnpm#13325
Resolving the Astro workspace with pacquet produced a `pnpm-lock.yaml`
that differed from pnpm 11's by 306 lines. Two independent bugs account
for 143 of them.
`dedupe_injected_deps` splits a resolved package id into its name and
its `file:` payload on the first `@`. A scoped id
(`@test/pkg@file:packages/…`) starts with `@`, so the split returned the
scope tail and the `file:` strip failed — the injected workspace dep was
never recognized and stayed a `file:` snapshot where pnpm records
`link:`. Split on the whole `@file:` separator instead.
`extract_children` walked every entry of `dependencies` and
`optionalDependencies`, including the ones the manifest declares as
bundled. npm ships those inside the package's own tarball, and pnpm's
`getNonDevWantedDependencies` filters them out before resolution; the
missing filter pulled extra packages into the lockfile (`napi-wasm`
under `@parcel/watcher-wasm`, the whole `@napi-rs`/`@emnapi` set under
`@tailwindcss/oxide-wasm32-wasi`). Both spellings are honored, and
`true` means every entry of `dependencies`, matching npm. The bundled
set is computed once and shared by both `collect_deps` calls, so an
alias declared in both groups is dropped from both — upstream filters
the merged `{...optionalDependencies, ...dependencies}` map and reaches
the same result. The alias validation still runs over bundled entries
so an unusable alias is rejected either way, as it is upstream.
A third divergence from the same reproduction — a project's own
`peerDependencies` reaching its lockfile importer entry without
`autoInstallPeers` — landed separately as pnpm#13372 while this was
in review, so it is no longer part of this change.
The remaining divergences — the `parentPkgAliases` arm of upstream's
peer-shadowed-dependency omission, and local `file:*.tgz` tarballs
resolving without a manifest — are described in the issue; both need
design work beyond this change.
Related to pnpm#13334.
…npm#13378) `Path::exists` follows the link, so a dangling `peer-c` link in pkg-a's `node_modules` would have read as "not linked" and passed the check; `symlink_metadata` fails only when nothing is there at all. The importer snapshot moves from an unconditional `dbg!` into the assertion message, so it is printed when a check fails rather than on every run. Follow-up to pnpm#13372, which merged before this commit landed.
…npm#13381) The hoist rounds ran on every install, so a missing peer that some version elsewhere in the workspace could satisfy was installed even with `autoInstallPeers: false` and `dedupePeerDependents: false` — the dependent then carried a peer context the TypeScript CLI never writes. Upstream derives one flag from the two settings — `hoistPeers = autoInstallPeers || dedupePeerDependents` in `installing/deps-resolver/src/resolveDependencyTree.ts` — and `resolveRootDependencies` returns before the hoist loop when it is false: hoisting a peer nobody asked to install only pays off if peer-suffixed variants are being collapsed. `ImporterHoistState` now carries the same derived flag and both rounds no-op when it is unset, which leaves the peer missing and the dependent's snapshot free of a peer suffix. The final peer pass is untouched, so unmet peers are still reported. Verified against the TypeScript CLI on a two-project workspace: all four `autoInstallPeers` x `dedupePeerDependents` combinations now produce byte-identical lockfiles, where the both-off combination previously diverged. Follow-up to pnpm#13372.
Summary
With
autoInstallPeers: false, pacquet added a project's own optional peer dependencies to that project's importer entry inpnpm-lock.yaml(and linked them into itsnode_modules) as soon as some other part of the workspace resolved a matching version. Reported for vite in #13325, wherepackages/vitegainedjiti,tsxandyaml— the optional peers ofpostcss-load-configthatpackages/vitere-declares as its own optional peers.The peer hoist itself is not the divergence: both stacks hoist an optional peer into the importer's resolved direct dependencies when a satisfying version is already in scope, which is what produces the
(@pnpm.e2e/[email protected])peer context on the dependent. The difference is what reaches the lockfile importer entry. The TypeScript CLI foldspeerDependenciesinto an importer's dependencies only underautoInstallPeers(getAllDependenciesFromManifest(manifest, { autoInstallPeers })inpnpm11/installing/deps-resolver/src/index.ts), so with the setting off a hoisted peer stays reachable only through the snapshots graph. pacquet'sread_manifest_specifierconsultedpeerDependenciesunconditionally; it now applies the same gate — which also lines it up with pacquet's own lockfile freshness check, whose peer fold is already gated onauto_install_peers.Verified against the TypeScript CLI with a two-project fixture on the mocked registry: before the fix pacquet wrote
'@pnpm.e2e/peer-c': { specifier: ^1.0.0, version: 1.0.0 }intopkg-awhile pnpm v11.17.0 wrote nothing; after the fix the two lockfiles are byte-identical (modulo thesettings:block), and so ispkg-a/node_modules.autoInstallPeers: truestill materializes the peer in both stacks.Closes #13325
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
autoInstallPeers: false), optional peer dependencies are no longer added to a project’s lockfile importer or installed into itsnode_modules.#13325) across CLI and installer scenarios.