Repository navigation
fix(resolving-deps-resolver): hoist peers against the workspace root's deps - #13343
Conversation
…s deps
`resolvePeersFromWorkspaceRoot` is meant to let any project satisfy a
missing peer from the workspace root's dependencies. The picker was fed
`self.direct` — the deps of whichever importer was being resolved — so a
project that didn't declare the peer itself saw no candidate and resolved
a second copy from the registry. The field doc said as much
("Single-importer pacquet treats the importer as the root"), left over
from before the multi-importer orchestrator existed.
`resolve_workspace` now builds the root importer's list once, after the
phase-1 init barrier, and shares it with every importer's hoist rounds;
computing it once also matches pnpm, where the root's own hoisted peers
never become root-dep candidates for the importers hoisted after it. An
importer set without the root leaves the list empty, mirroring pnpm's
absent-root-importer case.
`build_workspace_root_deps` also needed pnpm's two specifier sources to
be of any use: the resolver reports `normalized_bare_specifier` only for
specs that needed normalizing, so a plain "19.2.0" arrived as `None` and
the picker skipped the root dep entirely. Fall back to the declared
specifier, and include deps the resolver couldn't name at resolution
time (git / tarball / local), matching `getHoistableRootDeps`.
Separately, `get_hoistable_optional_peers` now checks ranges with plain
semver instead of the prerelease-tolerant helper, matching the bare
`semver.satisfies` in `getHoistableOptionalPeers`. A prerelease is not a
stand-in for a range that didn't ask for one: `ts-jest` declares
`@jest/transform` and `jest-util` as optional peers with
`^29.0.0 || ^30.0.0`, and a jest 30 prerelease elsewhere in the graph
was binding them to `30.0.0-alpha.6` while `jest` itself stayed on 29.
Both were found resolving vercel/next.js, whose `overrides` pin `react`
to one canary build: pnpm 12 produced a second `[email protected]` and paired
it with the canary `react-dom`, violating that package's exact peer pin.
The remaining required-peer prerelease divergence is #13341.
Refs #13320
The `resolve_peers_from_workspace_root` doc linked to `ImporterHoistState::set_workspace_root_deps`, which is `pub(crate)`, so rustdoc rejected a public item pointing at a private one under `RUSTDOCFLAGS=-D warnings`. Point at `resolve_workspace` instead — it is the public entry point that supplies the root's deps, which is what a reader of the option needs to know. Also replace a Unicode ellipsis in the `wanted_specifier_by_alias` doc with ASCII, per `perfectionist::unicode-ellipsis-in-docs`. Both are caught by the `pre-push` hook rather than by `just ready`.
|
Warning Review limit reached
Next review available in: 8 seconds 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 (7)
📝 WalkthroughWalkthroughChangesPeer hoisting corrections
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant WorkspaceResolver
participant ImporterHoistState
participant PeerHoister
WorkspaceResolver->>ImporterHoistState: derive root direct dependencies
WorkspaceResolver->>ImporterHoistState: share workspace_root_deps
ImporterHoistState->>PeerHoister: hoist required peers using stored root deps
PeerHoister-->>ImporterHoistState: select root-provided peer version
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 peer hoisting to use workspace-root deps and strict optional-peer semver
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Micro-Benchmark ResultsLinux |
The new comments claimed the shared root-dep list is empty for a filtered install. It isn't: the install layer builds `importer_manifests` from `selection.all_projects`, so every workspace project — the root included — reaches `resolve_workspace` whether or not `--filter` narrowed what gets written. The empty fallback covers an importer set with no root at all, which is also what pnpm's unchecked `importers[rootImporterIndex]` lookup degrades to.
Confidence Score: 3/5This PR is not yet safe to merge because aliased root dependencies can still lose their canonical package identity and fail to provide peers across importers. The attempted identity fix depends on Files Needing Attention: pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs Reviews (4): Last reviewed commit: "docs(resolving-deps-resolver): let the t..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13343 +/- ##
==========================================
+ Coverage 87.04% 87.06% +0.01%
==========================================
Files 532 535 +3
Lines 91589 91884 +295
==========================================
+ Hits 79723 79996 +273
- Misses 11866 11888 +22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.changeset/peer-hoist-reads-workspace-root-deps.md (1)
1-11: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSplit into two changesets — one logical change per changeset.
The frontmatter/package choice (
pacquet: patch, nopnpm) is correct for a Rust-only fix. However, the body itself enumerates "Two fixes to peer hoisting" that are unrelated bugs (workspace-root dependency matching vs. optional-peer prerelease strictness). Per the review guide's one-logical-change-per-changeset rule, these should be two separate changeset files so each fix has its own changelog entry and bump.As per path instructions, "If user-visible behavior changed, ensure a changeset exists and is accurate; follow the one logical change per changeset rule."
🤖 Prompt for 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. In @.changeset/peer-hoist-reads-workspace-root-deps.md around lines 1 - 11, Split the changeset’s “Two fixes to peer hoisting” into two separate changeset files: one describing workspace-root dependency matching and one describing optional-peer prerelease range enforcement. Preserve the existing pacquet patch frontmatter for each file, and give each fix its own focused changelog entry.Source: Path instructions
pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs (1)
162-173: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winHoist range parsing out of the per-version loop.
rangesis invariant across theselectorsloop, butrange.parse::<Range>()re-parses every range string for every candidate version. Parse once perpeer_nameand reuse.♻️ Proposed refactor
for (peer_name, ranges) in all_missing_optional_peers { let Some(selectors) = all_preferred_versions.get(peer_name) else { continue }; + let Ok(parsed_ranges) = + ranges.iter().map(|range| range.parse::<Range>()).collect::<Result<Vec<_>, _>>() + else { + continue; + }; let mut max_satisfying_version: Option<Version> = None; for (version_str, entry) in selectors { ... let Ok(version) = version_str.parse::<Version>() else { continue }; - if !ranges - .iter() - .all(|range| range.parse::<Range>().is_ok_and(|parsed| parsed.satisfies(&version))) - { + if !parsed_ranges.iter().all(|parsed| parsed.satisfies(&version)) { continue; }As per path instructions, "performance second—avoid extra hot-path work in resolver/hoisting loops."
🤖 Prompt for 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. In `@pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs` around lines 162 - 173, Parse all entries in ranges once before the selectors/per-version loop for each peer_name, store the successfully parsed Range values or the resulting invalid state, and reuse them in the strict prerelease compatibility check. Update the condition around parsed.satisfies(&version) to avoid calling range.parse::<Range>() for each candidate version while preserving the existing behavior for invalid ranges.Source: Path instructions
🤖 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.
Nitpick comments:
In @.changeset/peer-hoist-reads-workspace-root-deps.md:
- Around line 1-11: Split the changeset’s “Two fixes to peer hoisting” into two
separate changeset files: one describing workspace-root dependency matching and
one describing optional-peer prerelease range enforcement. Preserve the existing
pacquet patch frontmatter for each file, and give each fix its own focused
changelog entry.
In `@pnpm/crates/resolving-deps-resolver/src/hoist_peers.rs`:
- Around line 162-173: Parse all entries in ranges once before the
selectors/per-version loop for each peer_name, store the successfully parsed
Range values or the resulting invalid state, and reuse them in the strict
prerelease compatibility check. Update the condition around
parsed.satisfies(&version) to avoid calling range.parse::<Range>() for each
candidate version while preserving the existing behavior for invalid ranges.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 140ffc08-b106-4b3f-b3f6-2f1ca9be0dc4
📒 Files selected for processing (7)
.changeset/peer-hoist-reads-workspace-root-deps.mdpnpm/crates/resolving-deps-resolver/src/hoist_peers.rspnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rspnpm/crates/resolving-deps-resolver/src/resolve_importer.rspnpm/crates/resolving-deps-resolver/src/resolve_workspace.rspnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.6083106423599998,
"stddev": 0.17510884675285984,
"median": 2.65357597726,
"user": 1.5492072199999998,
"system": 1.3072948000000002,
"min": 2.37455780226,
"max": 2.81669234426,
"times": [
2.79366459926,
2.42330947126,
2.37455780226,
2.8113698872599997,
2.6603411652599998,
2.3957231642599996,
2.67289313526,
2.81669234426,
2.64681078926,
2.48774406526
]
},
{
"command": "pacquet@main",
"mean": 2.60269222596,
"stddev": 0.1590040262716171,
"median": 2.63345508926,
"user": 1.5564852199999997,
"system": 1.2789442000000002,
"min": 2.3974736272599997,
"max": 2.80350666326,
"times": [
2.7693675822599997,
2.39961053626,
2.70387566526,
2.3974736272599997,
2.7368168432599997,
2.51301380926,
2.56303451326,
2.80350666326,
2.70448246026,
2.4357405592599997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5285854117600002,
"stddev": 0.12385586040507172,
"median": 1.5309569232600002,
"user": 1.0666534199999997,
"system": 1.1534630000000001,
"min": 1.35303725426,
"max": 1.6828799862600001,
"times": [
1.36590926026,
1.4823348872600002,
1.6823440202600002,
1.62571019926,
1.5137923582600001,
1.4137920752600002,
1.6179325882600002,
1.54812148826,
1.35303725426,
1.6828799862600001
]
},
{
"command": "pnpr@main",
"mean": 1.47639371836,
"stddev": 0.1647420432584678,
"median": 1.3903641907600002,
"user": 1.05049182,
"system": 1.1201190000000003,
"min": 1.35337160026,
"max": 1.80563790026,
"times": [
1.80563790026,
1.38657347426,
1.7315993092600002,
1.3941549072600001,
1.36186044526,
1.3681685482600001,
1.35337160026,
1.43003673826,
1.5486621522600001,
1.38387210826
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25929840628,
"stddev": 0.005891407615713493,
"median": 0.25856139058000005,
"user": 0.20576378,
"system": 0.5442762799999998,
"min": 0.24716059358,
"max": 0.26865918358,
"times": [
0.25822031058,
0.25786950258,
0.25890247058000004,
0.25599306258000004,
0.26865918358,
0.25786038558,
0.26598467658,
0.26333309258000004,
0.25900078458000003,
0.24716059358
]
},
{
"command": "pacquet@main",
"mean": 0.25823384558,
"stddev": 0.0036169356567114473,
"median": 0.25709654708,
"user": 0.20497378,
"system": 0.54829168,
"min": 0.25276814258,
"max": 0.26333293058,
"times": [
0.25809879158000004,
0.26333293058,
0.25609430258,
0.25276814258,
0.26143413858000003,
0.25487111658,
0.26185248458,
0.25607164958,
0.25598832258000004,
0.26182657658
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27452019258,
"stddev": 0.005102417253160948,
"median": 0.27585239658000005,
"user": 0.20216837999999995,
"system": 0.5565167799999999,
"min": 0.26618025258,
"max": 0.27960260158,
"times": [
0.27572173158,
0.27843882858,
0.26718706158,
0.27516172058,
0.27863210158,
0.26618025258,
0.26921702958,
0.27960260158,
0.27598306158,
0.27907753658
]
},
{
"command": "pnpr@main",
"mean": 0.27210190818,
"stddev": 0.0054823866620347965,
"median": 0.27289608108,
"user": 0.22311737999999998,
"system": 0.53256818,
"min": 0.26327349858000004,
"max": 0.27867124458000003,
"times": [
0.27743781058,
0.27726574758,
0.26327349858000004,
0.27867124458000003,
0.27207650358,
0.27581185158,
0.27371565858,
0.27082378358000003,
0.26522689458000004,
0.26671608858
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.77548688732,
"stddev": 0.015733715972184432,
"median": 2.77182208222,
"user": 1.6770056199999999,
"system": 1.3589731400000002,
"min": 2.75900813422,
"max": 2.80409662422,
"times": [
2.7994576332200003,
2.7690849172200003,
2.75900813422,
2.76212436922,
2.77455924722,
2.7831323772200003,
2.80409662422,
2.76244342022,
2.77614591722,
2.76481623322
]
},
{
"command": "pacquet@main",
"mean": 2.76899744242,
"stddev": 0.020958197993800606,
"median": 2.76382250822,
"user": 1.6428493199999998,
"system": 1.3214772399999997,
"min": 2.7396541982200002,
"max": 2.8118351502200003,
"times": [
2.8118351502200003,
2.7894171342200003,
2.75964723522,
2.74822773222,
2.78104186022,
2.7396541982200002,
2.7735416012200003,
2.76298255222,
2.76466246422,
2.7589644962200004
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5691270637200003,
"stddev": 0.1325700432068971,
"median": 1.52139721672,
"user": 0.99835662,
"system": 1.2233228399999998,
"min": 1.4594873532200001,
"max": 1.8572986952200001,
"times": [
1.4594873532200001,
1.46826978422,
1.6298500112200003,
1.5192047072200001,
1.7203906372200002,
1.4695682922200002,
1.46092469922,
1.5826867312200001,
1.8572986952200001,
1.52358972622
]
},
{
"command": "pnpr@main",
"mean": 1.50735592312,
"stddev": 0.13987031500315797,
"median": 1.45503846472,
"user": 1.0042584199999998,
"system": 1.1801632399999997,
"min": 1.4235951422200002,
"max": 1.87576349922,
"times": [
1.4358177582200002,
1.45821998622,
1.46339477222,
1.60922014922,
1.47714288922,
1.87576349922,
1.44997763622,
1.4235951422200002,
1.4518569432200001,
1.42857045522
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5912106543000001,
"stddev": 0.017778711520689335,
"median": 0.5930408989,
"user": 0.70880146,
"system": 0.6880293,
"min": 0.5692096659,
"max": 0.6197833629,
"times": [
0.6012415959,
0.5881477859,
0.6005151029,
0.5979340119000001,
0.6097590609,
0.6197833629,
0.5694666979,
0.5697198929,
0.5863293659000001,
0.5692096659
]
},
{
"command": "pacquet@main",
"mean": 0.5813338671,
"stddev": 0.020654960815233648,
"median": 0.5795167079000001,
"user": 0.6850136599999999,
"system": 0.6771957999999999,
"min": 0.5482315579,
"max": 0.6085207789,
"times": [
0.5482315579,
0.5605376999,
0.5619478839000001,
0.5776064449,
0.5814269709000001,
0.6085207789,
0.6081044679000001,
0.5966582999,
0.5951994829,
0.5751050839
]
},
{
"command": "pnpr@HEAD",
"mean": 0.3080604715,
"stddev": 0.008129087173836464,
"median": 0.3099473449,
"user": 0.19051785999999998,
"system": 0.5473629999999998,
"min": 0.2966833149,
"max": 0.3207679409,
"times": [
0.3019121929,
0.3104901129,
0.3157217159,
0.3207679409,
0.3146912739,
0.3114266889,
0.3094045769,
0.2979784739,
0.2966833149,
0.3015284239
]
},
{
"command": "pnpr@main",
"mean": 0.3057180546,
"stddev": 0.008708408726627384,
"median": 0.30437386040000003,
"user": 0.19889905999999996,
"system": 0.5389698999999999,
"min": 0.2925867699,
"max": 0.3239291109,
"times": [
0.3239291109,
0.3026116639,
0.2985036389,
0.3051441749,
0.3036035459,
0.3121258419,
0.3117013049,
0.2999415269,
0.2925867699,
0.3070329679
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.90595493558,
"stddev": 0.010407899397435744,
"median": 1.9079260792800001,
"user": 0.9418970199999999,
"system": 0.7573024599999998,
"min": 1.88726633128,
"max": 1.92105137328,
"times": [
1.91042612428,
1.8963832332800001,
1.90453811928,
1.91574733428,
1.92105137328,
1.88726633128,
1.9054260342800002,
1.9112268352800001,
1.8950708102800002,
1.91241316028
]
},
{
"command": "pacquet@main",
"mean": 1.8998030719800003,
"stddev": 0.011295542952924297,
"median": 1.89809957028,
"user": 0.9141751199999998,
"system": 0.77224106,
"min": 1.88469077928,
"max": 1.91739062828,
"times": [
1.91739062828,
1.9068795302800001,
1.9100171352800002,
1.91178358028,
1.8948536132800002,
1.89165896128,
1.8924928352800001,
1.90134552728,
1.88469077928,
1.8869181292800001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30941421588000007,
"stddev": 0.0060236130383600475,
"median": 0.30878610978,
"user": 0.19249162,
"system": 0.55367306,
"min": 0.29788203028,
"max": 0.31895400928,
"times": [
0.31020843228,
0.30804781928,
0.30513955428,
0.31047421028,
0.29788203028,
0.31895400928,
0.30855053228,
0.31817662028,
0.30768726328,
0.30902168728
]
},
{
"command": "pnpr@main",
"mean": 0.30435015428000006,
"stddev": 0.008030403921684517,
"median": 0.30208238878,
"user": 0.20014852,
"system": 0.52842966,
"min": 0.29455585928,
"max": 0.32110145728,
"times": [
0.29455585928,
0.30741559428,
0.30933110728,
0.31136124628,
0.30004604928,
0.30054045628,
0.29802302428,
0.29750242728,
0.32110145728,
0.30362432128
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.36066094170000007,
"stddev": 0.007175114127795322,
"median": 0.35894997390000005,
"user": 0.3581003399999999,
"system": 0.04986728,
"min": 0.35322279040000004,
"max": 0.37939803240000003,
"times": [
0.35322279040000004,
0.35735959040000004,
0.3626702734,
0.35831361040000004,
0.3627310174,
0.3568539114,
0.3597868044,
0.3566870494,
0.3595863374,
0.37939803240000003
]
},
{
"command": "pacquet@main",
"mean": 0.3584066589,
"stddev": 0.007826609257762773,
"median": 0.3579526784,
"user": 0.35098253999999995,
"system": 0.05636728,
"min": 0.3481851704,
"max": 0.37388476940000004,
"times": [
0.3613745924,
0.35453076440000003,
0.3481851704,
0.3539450954,
0.37388476940000004,
0.3528365664,
0.3502170424,
0.3630399064,
0.36382295540000004,
0.3622297264
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08694687294545456,
"stddev": 0.001407621298332183,
"median": 0.08708309840000002,
"user": 0.021265643030303025,
"system": 0.008639042424242425,
"min": 0.0837417294,
"max": 0.09033949540000001,
"times": [
0.08460833640000001,
0.0854456454,
0.08769454540000002,
0.08478374440000001,
0.08896132140000002,
0.08732709540000001,
0.08690684740000001,
0.09033949540000001,
0.08739644640000001,
0.08615709140000001,
0.08627295740000002,
0.0837417294,
0.08672455440000001,
0.08421460640000002,
0.0889274074,
0.08543751140000001,
0.08675408040000002,
0.08709903840000001,
0.08656348240000002,
0.08812183740000001,
0.08719094940000001,
0.08664624940000001,
0.08771201740000001,
0.08696968540000001,
0.08769256040000001,
0.08708309840000002,
0.08797189540000001,
0.08640993640000001,
0.08872783240000001,
0.08711679040000002,
0.08677576240000001,
0.08834791040000001,
0.08712434540000001
]
},
{
"command": "pnpr@main",
"mean": 0.08727912509696972,
"stddev": 0.0013756504745851023,
"median": 0.08723963240000002,
"user": 0.019348097575757568,
"system": 0.010511016969696968,
"min": 0.08293650940000001,
"max": 0.09011424440000002,
"times": [
0.0865900534,
0.08720425540000001,
0.0867483004,
0.08698051440000001,
0.08731559440000002,
0.08674138640000001,
0.08799522940000001,
0.08686265340000002,
0.08629047140000001,
0.0878499664,
0.08773724540000001,
0.08723963240000002,
0.08762442240000001,
0.08761138040000001,
0.08665747940000001,
0.08844463240000001,
0.08585901140000002,
0.09011424440000002,
0.08598999640000002,
0.08965508240000002,
0.08293650940000001,
0.08971349340000001,
0.08718652140000001,
0.08928144240000001,
0.08542718140000001,
0.08605658240000001,
0.08807406740000001,
0.08698889040000002,
0.0875228734,
0.08770204840000001,
0.08581599140000001,
0.08788338840000001,
0.08811058640000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.5684311406600004,
"stddev": 0.18420619732072963,
"median": 4.47643089056,
"user": 1.7186855399999998,
"system": 1.3915841800000002,
"min": 4.42426982706,
"max": 4.88688314606,
"times": [
4.52975982606,
4.88688314606,
4.47694222506,
4.42640918906,
4.43044371806,
4.79217580406,
4.47591955606,
4.42426982706,
4.43364280006,
4.80786531506
]
},
{
"command": "pacquet@main",
"mean": 4.55508626356,
"stddev": 0.12221232578932759,
"median": 4.53487258356,
"user": 1.70282424,
"system": 1.40170838,
"min": 4.43218436306,
"max": 4.83340494506,
"times": [
4.83340494506,
4.60656315006,
4.43218436306,
4.51089758706,
4.54384191606,
4.45054456506,
4.65715342506,
4.43292376506,
4.52590325106,
4.55744566806
]
},
{
"command": "pnpr@HEAD",
"mean": 3.50814166396,
"stddev": 0.059986157080731406,
"median": 3.48334564556,
"user": 1.2111172399999997,
"system": 1.2131207800000001,
"min": 3.44941184006,
"max": 3.62484348906,
"times": [
3.54434295606,
3.47465840706,
3.49203288406,
3.45328343506,
3.45711613406,
3.62484348906,
3.44941184006,
3.53012179506,
3.58145034606,
3.47415535306
]
},
{
"command": "pnpr@main",
"mean": 3.5297990327599997,
"stddev": 0.10380668883729854,
"median": 3.48905366956,
"user": 1.1734773400000003,
"system": 1.2447521799999999,
"min": 3.44477291706,
"max": 3.78258796306,
"times": [
3.44477291706,
3.48231205606,
3.49579528306,
3.62181513606,
3.5684803930599998,
3.46435354406,
3.46727134806,
3.78258796306,
3.47258679006,
3.49801489706
]
}
]
} |
…ifest Review follow-ups on the workspace-root peer-hoist fix. The picker matches a root dep by alias *and* by real package name, and `build_workspace_root_deps` dropped every dep whose name the resolver couldn't report. Local, tarball and directory resolutions all leave `name_ver` unset — `ResolveResult::name_ver`'s own doc nominates the fetched manifest as the canonical name for exactly those protocols — so read it from there, the same fallback `deprecated_pkg_name_ver` already uses. A git resolution reports no manifest until after the fetch, which is past the point the picker runs, so those stay matched by alias alone. Naming those resolutions has a consequence of its own: it would let a `link:` / `file:` / `workspace:` specifier become a candidate, and such a specifier resolves against the consuming project's directory, so handing the root's copy to another importer would reach a different path or nothing at all. Every candidate specifier now passes through `cross_importer_specifier`, which rejects that prefix set — the same one `project_relative_cache_scope` uses to decide a resolution is project-scoped. Local resolutions were never candidates before this series, since they always report `name_ver: None`, so the gate restores that invariant rather than narrowing anything that used to work. Also parse each optional peer's ranges once instead of once per candidate version, and split the changeset in two so each fix carries its own release note. Related to #13320.
|
| Project | pnpm's project |
| Branch | pr/13343 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,459.49 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 297.88 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 296.68 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 83.74 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,353.04 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,449.41 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 266.18 ms |
|
Both applied in Split the changeset. Done — Hoist range parsing out of the per-version loop. Done, as proposed. Worth noting for the record that the rewrite is behavior-preserving including for invalid input: previously an unparseable range made Written by an agent (Claude Code, claude-opus-5). |
|
Thanks — two of the three are valid and fixed in 1. Historical comment in test — fixedRight, and it's a repo convention I should have caught myself: /// workspace: if the picker were sourced from the hoisting importer, it
/// would find no candidate there and resolve a second `react` from the
/// range.
2. Root spec resolved wrong dir — valid, fixed with your option 2Confirmed reachable, and I took the conservative option: a One correction to the analysis, which narrows where this actually bit: the local resolver sets Test: 3.
|
`project_relative_cache_scope` is a private function in a private module, so the link had nothing to resolve to and `Rust CI / Doc` failed it under `-D rustdoc::broken-intra-doc-links`. Name it in backticks instead — the reference is for a reader following the convention across the two call sites, not a navigable API link.
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…s deps (pnpm#13343) `resolvePeersFromWorkspaceRoot` is meant to let any project satisfy a missing peer from the workspace root's dependencies. The picker was fed `self.direct` — the deps of whichever importer was being resolved — so a project that didn't declare the peer itself saw no candidate and resolved a second copy from the registry. The field doc said as much ("Single-importer pacquet treats the importer as the root"), left over from before the multi-importer orchestrator existed. `resolve_workspace` now builds the root importer's list once, after the phase-1 init barrier, and shares it with every importer's hoist rounds; computing it once also matches pnpm, where the root's own hoisted peers never become root-dep candidates for the importers hoisted after it. An importer set without the root leaves the list empty, mirroring pnpm's absent-root-importer case. `build_workspace_root_deps` also needed pnpm's two specifier sources to be of any use: the resolver reports `normalized_bare_specifier` only for specs that needed normalizing, so a plain "19.2.0" arrived as `None` and the picker skipped the root dep entirely. Fall back to the declared specifier, and include deps the resolver couldn't name at resolution time (git / tarball / local), matching `getHoistableRootDeps`. Separately, `get_hoistable_optional_peers` now checks ranges with plain semver instead of the prerelease-tolerant helper, matching the bare `semver.satisfies` in `getHoistableOptionalPeers`. A prerelease is not a stand-in for a range that didn't ask for one: `ts-jest` declares `@jest/transform` and `jest-util` as optional peers with `^29.0.0 || ^30.0.0`, and a jest 30 prerelease elsewhere in the graph was binding them to `30.0.0-alpha.6` while `jest` itself stayed on 29. Both were found resolving vercel/next.js, whose `overrides` pin `react` to one canary build: pnpm 12 produced a second `[email protected]` and paired it with the canary `react-dom`, violating that package's exact peer pin. The remaining required-peer prerelease divergence is pnpm#13341. Related to pnpm#13320.
Summary
Two peer-resolution defects found while validating vercel/next.js for #13305. Both are pacquet-only divergences from the TypeScript CLI —
hoist_peers.rsis otherwise a faithful port ofhoistPeers/getHoistableOptionalPeers, so there is no counterpart TypeScript change to land alongside this.1.
resolvePeersFromWorkspaceRootread the wrong importer's dependencies. The hoist picker was fedself.direct— the deps of whichever importer was being resolved — instead of the workspace root's. A project that doesn't declare the peer itself therefore saw no candidate and resolved a second copy from the registry. The field doc admitted it ("Single-importer pacquet treats the importer as the root"), left over from before the multi-importer orchestrator existed;WorkspaceResolveOptionsalready documented the intended behavior correctly.In next.js, whose
overridespinreact/react-dom/react-is/schedulerto one canary build,bench/heavy-npm-deps(which declares@mantine/core,lucide-react,nextand noreact) pulled in a second[email protected]and bound the canaryreact-domto it — violating that package's exact peer pinreact: 19.3.0-canary-28cd4bb0-20260723, which is the runtime-breaking combination the pin exists to prevent. 38 references in the resolved lockfile, zero in pnpm 11's.2. The optional-peer picker accepted prereleases the declared range rejects.
get_hoistable_optional_peersused the prerelease-tolerant helper where the TypeScript counterpart uses a baresemver.satisfies.ts-jestdeclares@jest/transformandjest-utilas optional peers with^29.0.0 || ^30.0.0; with a jest 30 prerelease elsewhere in the graph (dragged in byoverrides: { jest-snapshot: 30.0.0-alpha.6 }) they bound to30.0.0-alpha.6— outside the declared range under strict semver — whilejestitself stayed on 29.7.0.Effect on the next.js lockfile
Full re-resolution, both stacks run back to back on the same tree:
pnpm-lock.yamldiff vs pnpm 11[email protected][email protected]referencests-jestpeer suffixThe remaining 445 lines are a separate, unrelated
resolve_peersprovider-selection difference aroundpostcss, discussed on #13320; nothing is violated on either side there and it is not touched here.Not in this PR
Required-peer prerelease leniency —
hoist_peersis lenient in a different way togetHoistableOptionalPeers: pacquet strips the prerelease tag and retries against the base version, while TypeScript passesincludePrerelease: true, which does not lower the range's bound. The two agree when the prerelease sits inside the range's span and disagree at the lower bound. Not implicated in any repository validated so far, and the Rustnode-semvercrate exposes noincludePrerelease, so it needs real semver work. Filed as pnpm 12 auto-installs a required peer as a prerelease its declared range rejects (base-strip vs includePrerelease) #13341.An aliased git workspace-root dependency still can't satisfy a peer by its real package name. A git resolution reports neither
name_vernor a manifest before the hoist loop runs, so it is matched by alias only. Pre-existing — the previous code skipped such deps entirely, matching neither — and a missed deduplication rather than an incorrect graph. Filed as An aliased git workspace-root dependency can't satisfy a peer by its real package name #13351.Related to #13320, found via #13305.
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.Rust-only: both defects are pacquet diverging from TypeScript behavior that
is already correct, so the TypeScript CLI needs no change.
pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
non_root_importer_hoists_the_root_importers_peer_providercovers theworkspace-root sourcing; it was verified to fail against the old behavior
(
["18.3.1", "19.2.0"]where["19.2.0"]is expected). The optional-peer testthat asserted the prerelease was accepted is inverted, plus a new case for a
prerelease inside the range's span, which is the shape next.js hits and which
a lower-bound check alone would miss.
No user-facing docs change; the stale
resolve_peers_from_workspace_rootfield doc that described the bug is corrected.
Verification
just readygreen: 7020 tests passed, 0 failures;cargo clippy --all-targets --workspace -D warningsclean;typos,cargo fmt,cargo checkclean. Pre-push gates run locally too: workspacecargo docwithRUSTDOCFLAGS=-D warnings, andcargo dylint --allclean. next.js frozen install re-checked after the change — exit 0, lockfile not rewritten, 3619 packages.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