Repository navigation
feat(peers): accept scheme-carrying specifiers in peerDependencies - #13110
Conversation
peerDependencies previously rejected any value that was not a semver range or a `workspace:`/`catalog:` spec with ERR_PNPM_INVALID_PEER_DEPENDENCY_SPECIFICATION. This blocked named-registry specifiers (`<registry>:<version>`), which are otherwise usable in dependencies/devDependencies (#13095). Accept any specifier that carries a scheme (named-registry, `npm:`, `file:`, git/URL). During resolution the peer is matched against the semver range the specifier carries — `work:5.x.x` is checked as `5.x.x`, `npm:bar@^5` as `^5` — or against `*` when it carries no version, while the original specifier still selects the package to auto-install. The install source was already preserved in both stacks, so only the validator and the satisfaction check needed to change: a new shared `getPeerVersionRange` helper extracts the comparable range at the match sites, and `isAcceptablePeerSpec` relaxes validation while still rejecting bare `name@version` typos. The same change lands in the Rust port: a shared `peer_range` module in resolving-resolver-base (which also absorbs the two duplicated `is_valid_peer_range` copies), the resolve_peers satisfaction check, and the `pnpm peers` command. Because the Rust peer path reuses one field for both the hoist source and the unmet-peer display, an unmet named-registry peer's warning shows the raw specifier there rather than the extracted range; resolution behavior is identical. Closes #13095.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughPeer dependency handling now accepts scheme-bearing specifiers, derives comparable semver ranges for matching, preserves invalid bare ChangesPeer Scheme Support
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Manifest as peerDependencies manifest
participant Validator as validatePeerDependencies
participant RangeHelper as getPeerVersionRange
participant Resolver as peer resolver
participant Hoister as hoistPeers
Manifest->>Validator: scheme-bearing peer specifier
Validator->>RangeHelper: normalize accepted specifier
RangeHelper->>Resolver: semver-comparable range
Resolver->>Hoister: raw specifier and normalized wanted range
Hoister->>Resolver: satisfying preferred peer or raw specifier
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 QodoAccept scheme-carrying peerDependency specifiers (named registry, npm:, file/git/URL)
AI Description
Diagram
High-Level Assessment
Files changed (21)
|
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pnpm/crates/cli/src/cli_args/peers.rs (1)
256-317: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winPreserve the original peer specifier for
wanted_rangein warnings.The CLI peer inspection logic overwrites the raw peer specifier with the normalized range (e.g., yielding
^5instead ofnpm:bar@^5). Consequently, the unmet-peer warnings display the normalized string rather than the original user-supplied specifier. As per path instructions, Pacquet must maintain strict behavioral parity with the TypeScript CLI for any user-visible behavior, including unmet-peer warning text.Both of these sites share this root cause and should split the range into a matching range and a satisfiability range, identical to the approach used in
resolve_peers.rs:
pnpm/crates/cli/src/cli_args/peers.rs#L256-L317: Incheck_linked_package_peers, retain the original specifier (stripping onlyworkspace:) forwanted_rangeand use the normalized range solely for thesatisfiescheck.pnpm/crates/cli/src/cli_args/peers.rs#L404-L471: Apply the same separation inwalk_snapshot.🛠️ Proposed fixes for both sites
For
check_linked_package_peers(around line 256):- for (peer_name, peer_range_val) in peer_deps { - let Some(peer_range) = peer_range_val.as_str() else { continue }; - let peer_range = get_peer_version_range(peer_range); + for (peer_name, peer_range_val) in peer_deps { + let Some(raw_peer_range) = peer_range_val.as_str() else { continue }; + let range_for_match = raw_peer_range.strip_prefix("workspace:").unwrap_or(raw_peer_range); + let range_for_satisfies = get_peer_version_range(raw_peer_range); let is_optional = manifest .value() .get("peerDependenciesMeta") .and_then(|meta_map| meta_map.get(peer_name)) .and_then(|peer_meta| peer_meta.get("optional")) .and_then(serde_json::Value::as_bool) .unwrap_or(false); let Ok(peer_pkg_name) = peer_name.parse::<PkgName>() else { continue }; let resolved_ref = importer .dependencies .as_ref() .and_then(|deps| deps.get(&peer_pkg_name)) .or_else(|| { importer.dev_dependencies.as_ref().and_then(|deps| deps.get(&peer_pkg_name)) }) .or_else(|| { importer.optional_dependencies.as_ref().and_then(|deps| deps.get(&peer_pkg_name)) }); match resolved_ref { Some(spec) => { if let Some(ver_peer) = spec.version.ver_peer() { let version_str = ver_peer.version().to_string(); - if !satisfies(&version_str, &peer_range) { + if !satisfies(&version_str, &range_for_satisfies) { issues.bad.entry(peer_name.clone()).or_default().push(BadPeerIssue { parents: current_parents.clone(), optional: is_optional, - wanted_range: peer_range.clone(), + wanted_range: range_for_match.to_string(), found_version: version_str, resolved_from: Vec::new(), }); } } else if let Some(link_target) = spec.version.as_link_target() { let found_version = resolve_link_version(&importer_dir, lockfile_dir, link_target) .unwrap_or_else(|| format!("link:{link_target}")); - if !satisfies(&found_version, &peer_range) { + if !satisfies(&found_version, &range_for_satisfies) { issues.bad.entry(peer_name.clone()).or_default().push(BadPeerIssue { parents: current_parents.clone(), optional: is_optional, - wanted_range: peer_range.clone(), + wanted_range: range_for_match.to_string(), found_version, resolved_from: Vec::new(), }); } } } None => { if !is_optional { issues.missing.entry(peer_name.clone()).or_default().push(MissingPeerIssue { parents: current_parents.clone(), optional: is_optional, - wanted_range: peer_range.clone(), + wanted_range: range_for_match.to_string(), }); } } } }For
walk_snapshot(around line 404):- for (peer_name, peer_range) in peers { - let peer_range = get_peer_version_range(peer_range); + for (peer_name, raw_peer_range) in peers { + let range_for_match = raw_peer_range.strip_prefix("workspace:").unwrap_or(raw_peer_range); + let range_for_satisfies = get_peer_version_range(raw_peer_range); let is_optional = meta .peer_dependencies_meta .as_ref() .and_then(|meta_map| meta_map.get(peer_name)) .is_some_and(|peer_meta| peer_meta.optional); let Ok(peer_pkg_name) = peer_name.parse::<PkgName>() else { continue }; let resolved_ref = snapshot.and_then(|snapshot_entry| { snapshot_entry .dependencies .as_ref() .and_then(|deps| deps.get(&peer_pkg_name)) .or_else(|| { snapshot_entry .optional_dependencies .as_ref() .and_then(|deps| deps.get(&peer_pkg_name)) }) }); match resolved_ref { Some(dep_ref) => { if let Some(ver_peer) = dep_ref.ver_peer() { let version_str = ver_peer.version().to_string(); - if !satisfies(&version_str, &peer_range) { + if !satisfies(&version_str, &range_for_satisfies) { issues.bad.entry(peer_name.clone()).or_default().push( BadPeerIssue { parents: current_parents.clone(), optional: is_optional, - wanted_range: peer_range.clone(), + wanted_range: range_for_match.to_string(), found_version: version_str, resolved_from: Vec::new(), }, ); } } else if let Some(link_target) = dep_ref.as_link_target() { let found_version = resolve_link_version(lockfile_dir, lockfile_dir, link_target) .unwrap_or_else(|| format!("link:{link_target}")); - if !satisfies(&found_version, &peer_range) { + if !satisfies(&found_version, &range_for_satisfies) { issues.bad.entry(peer_name.clone()).or_default().push( BadPeerIssue { parents: current_parents.clone(), optional: is_optional, - wanted_range: peer_range.clone(), + wanted_range: range_for_match.to_string(), found_version, resolved_from: Vec::new(), }, ); } } } None => { if !is_optional { issues.missing.entry(peer_name.clone()).or_default().push( MissingPeerIssue { parents: current_parents.clone(), optional: is_optional, - wanted_range: peer_range.clone(), + wanted_range: range_for_match.to_string(), }, ); } } } }🤖 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/cli/src/cli_args/peers.rs` around lines 256 - 317, The peer inspection logic must preserve the original user-supplied specifier for warning fields while using a normalized range only for satisfaction checks. In check_linked_package_peers at pnpm/crates/cli/src/cli_args/peers.rs#L256-L317, retain the specifier after stripping only workspace: for wanted_range and create a separate normalized range for satisfies; apply the same separation in walk_snapshot at pnpm/crates/cli/src/cli_args/peers.rs#L404-L471.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.
Outside diff comments:
In `@pnpm/crates/cli/src/cli_args/peers.rs`:
- Around line 256-317: The peer inspection logic must preserve the original
user-supplied specifier for warning fields while using a normalized range only
for satisfaction checks. In check_linked_package_peers at
pnpm/crates/cli/src/cli_args/peers.rs#L256-L317, retain the specifier after
stripping only workspace: for wanted_range and create a separate normalized
range for satisfies; apply the same separation in walk_snapshot at
pnpm/crates/cli/src/cli_args/peers.rs#L404-L471.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b62a4fc7-b86f-45cb-944b-6963745399ba
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.lock,!Cargo.lockpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!pnpm-lock.yaml
📒 Files selected for processing (20)
.changeset/peer-scheme-specifiers.mdpnpm/crates/cli/src/cli_args/peers.rspnpm/crates/package-manager/src/overrides.rspnpm/crates/package-manager/src/update_project_manifest_object.rspnpm/crates/resolving-deps-resolver/src/resolve_peers.rspnpm/crates/resolving-deps-resolver/src/resolve_peers/tests.rspnpm/crates/resolving-resolver-base/Cargo.tomlpnpm/crates/resolving-resolver-base/src/lib.rspnpm/crates/resolving-resolver-base/src/peer_range.rspnpm/crates/resolving-resolver-base/src/peer_range/tests.rspnpm11/deps/inspection/peers-checker/package.jsonpnpm11/deps/inspection/peers-checker/src/checkPeerDependencies.tspnpm11/deps/inspection/peers-checker/tsconfig.jsonpnpm11/deps/peer-range/src/index.tspnpm11/installing/deps-installer/test/install/autoInstallPeers.tspnpm11/installing/deps-installer/test/install/validatePeerDependencies.tspnpm11/installing/deps-resolver/src/resolvePeers.tspnpm11/installing/deps-resolver/src/validatePeerDependencies.tspnpm11/installing/deps-resolver/test/getPeerVersionRange.test.tspnpm11/installing/deps-resolver/test/validatePeerDependencies.test.ts
Confidence Score: 5/5Safe to merge — additive change guarded by a well-tested shared helper in both stacks. The core logic is encapsulated in a single helper mirrored identically in TypeScript and Rust. Every peer-matching site routes through it consistently. No existing behaviour is broken. No files require special attention. Reviews (3): Last reviewed commit: "fix(peers): reduce a merged union of sch..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13110 +/- ##
=======================================
Coverage 85.48% 85.48%
=======================================
Files 502 503 +1
Lines 80820 80888 +68
=======================================
+ Hits 69092 69151 +59
- Misses 11728 11737 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
PR Code Suggestions ✨Latest suggestions up to 3bc9685 Warning
Previous suggestionsSuggestions up to commit 2ea26bb
Suggestions up to commit 26ef5fd
|
||||||||||||||||||||||||||||||||||||||||
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7323579811400003,
"stddev": 0.12094310857902475,
"median": 2.7550466186400002,
"user": 2.4666629599999994,
"system": 1.9128493199999999,
"min": 2.54704546114,
"max": 2.88742354314,
"times": [
2.8672931311400003,
2.78515477714,
2.61179278814,
2.88742354314,
2.7552903731400002,
2.68445953714,
2.54704546114,
2.58513455914,
2.75480286414,
2.8451827771400002
]
},
{
"command": "pacquet@main",
"mean": 2.68466768454,
"stddev": 0.17677081895958813,
"median": 2.61804698714,
"user": 2.29580916,
"system": 1.8055637199999999,
"min": 2.51586238914,
"max": 2.9533006531400003,
"times": [
2.9533006531400003,
2.51908780114,
2.51586238914,
2.58274106814,
2.72348029014,
2.54429872514,
2.86839718914,
2.54308272314,
2.6533529061400003,
2.9430731001400003
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6210008470400001,
"stddev": 0.16621795408106185,
"median": 1.59434122814,
"user": 1.5767195599999995,
"system": 1.6445133199999997,
"min": 1.43268348114,
"max": 1.9600089251400001,
"times": [
1.43268348114,
1.9600089251400001,
1.71671503814,
1.7826681311400001,
1.62803048414,
1.46612863014,
1.45607221014,
1.66467692114,
1.56065197214,
1.54237267714
]
},
{
"command": "pnpr@main",
"mean": 1.63420046934,
"stddev": 0.1822356050670201,
"median": 1.68988286814,
"user": 1.4266048599999999,
"system": 1.37799382,
"min": 1.4024194091400002,
"max": 1.85002986014,
"times": [
1.4163978941400002,
1.81852330114,
1.49561994914,
1.85002986014,
1.68643032014,
1.69333541614,
1.4024194091400002,
1.8378849881400001,
1.71591365514,
1.42544990014
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.30173176148,
"stddev": 0.015350514274628822,
"median": 0.30552118818,
"user": 0.26298538,
"system": 0.6208575,
"min": 0.26572955168,
"max": 0.31684042468,
"times": [
0.31684042468,
0.30615229768,
0.31615489368000005,
0.30489007868,
0.30898428668000005,
0.31190698568,
0.29463032968,
0.30260336868000004,
0.28942539768000003,
0.26572955168
]
},
{
"command": "pacquet@main",
"mean": 0.28861584858,
"stddev": 0.009601838659003077,
"median": 0.28477771768000004,
"user": 0.24138527999999998,
"system": 0.5852305,
"min": 0.28004315268,
"max": 0.30600043168,
"times": [
0.28162257068,
0.28690391568,
0.28125014868000003,
0.28265151968,
0.29780355168000006,
0.30600043168,
0.30155843868000004,
0.28093839168,
0.28004315268,
0.28738636468
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30243794458,
"stddev": 0.009723863868651438,
"median": 0.30203067418,
"user": 0.25773308,
"system": 0.5743026999999999,
"min": 0.28843811768000005,
"max": 0.31752134768,
"times": [
0.31752134768,
0.30683050668,
0.31195679868000004,
0.31020196068000006,
0.29716832268000004,
0.30795034768,
0.29723084168,
0.29092339268,
0.29615780968000005,
0.28843811768000005
]
},
{
"command": "pnpr@main",
"mean": 0.28970980318000006,
"stddev": 0.011252056757960484,
"median": 0.29445082618,
"user": 0.24959188000000002,
"system": 0.5600362999999999,
"min": 0.27427263568000004,
"max": 0.30259337868,
"times": [
0.27635981968,
0.29276147668,
0.30259337868,
0.30061146368,
0.29863686268,
0.28366195368,
0.29614017568,
0.27498235268000004,
0.27427263568000004,
0.29707791268000006
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.89851813904,
"stddev": 0.04021406533951971,
"median": 2.88802505594,
"user": 2.10983884,
"system": 1.5897243199999997,
"min": 2.84902992694,
"max": 2.98500222594,
"times": [
2.90761096794,
2.84902992694,
2.91645871594,
2.88242646694,
2.8847200009400003,
2.9344531749400002,
2.8913301109400003,
2.98500222594,
2.88210379794,
2.8520460019400002
]
},
{
"command": "pacquet@main",
"mean": 2.98629923334,
"stddev": 0.15567761848592124,
"median": 2.98591780744,
"user": 2.3097749399999996,
"system": 1.70723992,
"min": 2.78964424194,
"max": 3.2498694249400004,
"times": [
3.1549083699400002,
3.2498694249400004,
3.11794859094,
2.9620041449400003,
2.99556898894,
2.9998628429400003,
2.78964424194,
2.80944770894,
2.8074713939400002,
2.97626662594
]
},
{
"command": "pnpr@HEAD",
"mean": 1.66908488734,
"stddev": 0.12415861924768427,
"median": 1.69744235044,
"user": 1.3066591399999998,
"system": 1.3429772199999999,
"min": 1.48635564294,
"max": 1.8508218649400001,
"times": [
1.8508218649400001,
1.76360985894,
1.57786007994,
1.72931567794,
1.48635564294,
1.53133971394,
1.7994546229400001,
1.5572067109399998,
1.72332918494,
1.67155551594
]
},
{
"command": "pnpr@main",
"mean": 1.63330220454,
"stddev": 0.1449010918200467,
"median": 1.5872186744399999,
"user": 1.24594414,
"system": 1.3549614199999997,
"min": 1.42509074494,
"max": 1.83447911094,
"times": [
1.59621126994,
1.50051134594,
1.57822607894,
1.80701929094,
1.51689530694,
1.72834214394,
1.42509074494,
1.55657292494,
1.78967382794,
1.83447911094
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.67702776856,
"stddev": 0.036729111896296324,
"median": 0.67278727656,
"user": 0.8509315200000002,
"system": 0.7284222400000001,
"min": 0.6134421665600001,
"max": 0.75451508556,
"times": [
0.65765819956,
0.65263596256,
0.69456268056,
0.75451508556,
0.66523893956,
0.69570666856,
0.66576106256,
0.6134421665600001,
0.69094342956,
0.67981349056
]
},
{
"command": "pacquet@main",
"mean": 0.72957220936,
"stddev": 0.061305232194072704,
"median": 0.71559986856,
"user": 0.93170202,
"system": 0.7680675399999999,
"min": 0.64759637356,
"max": 0.8216620705600001,
"times": [
0.66008524556,
0.74839129256,
0.81310476056,
0.69202394556,
0.70327590456,
0.72792383256,
0.8216620705600001,
0.69551603856,
0.64759637356,
0.78614262956
]
},
{
"command": "pnpr@HEAD",
"mean": 0.35090706776,
"stddev": 0.022287806784466024,
"median": 0.34409414356000007,
"user": 0.23812521999999997,
"system": 0.6219555400000001,
"min": 0.32486473856000003,
"max": 0.40047291156000003,
"times": [
0.32486473856000003,
0.33231601156000007,
0.34369228656000006,
0.33765776156000005,
0.33964798156000003,
0.34449600056000007,
0.35185344856000006,
0.37309887356000004,
0.40047291156000003,
0.36097066356000007
]
},
{
"command": "pnpr@main",
"mean": 0.37864602256,
"stddev": 0.027026623606568965,
"median": 0.37653074756000005,
"user": 0.27848561999999993,
"system": 0.65999854,
"min": 0.33353581056000003,
"max": 0.43052918356000003,
"times": [
0.33353581056000003,
0.37963335056,
0.37709237156000003,
0.37235937056000007,
0.43052918356000003,
0.41107012556000005,
0.37596912356000006,
0.38086275856000007,
0.37348708556000004,
0.35192104556000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.1696830962,
"stddev": 0.11318974385605704,
"median": 2.1641391089,
"user": 1.42048214,
"system": 1.02886926,
"min": 1.9924287359000001,
"max": 2.3263004209000004,
"times": [
2.2504198649,
2.0384522459000003,
2.1580462299,
1.9924287359000001,
2.0706516179000003,
2.1702319879000003,
2.3072003699000003,
2.3263004209000004,
2.2454429429,
2.1376565459
]
},
{
"command": "pacquet@main",
"mean": 2.0741826374000003,
"stddev": 0.054894207440338606,
"median": 2.0901464204,
"user": 1.26467634,
"system": 0.9499261599999999,
"min": 1.9709035339,
"max": 2.1487875669000003,
"times": [
2.0897730409000004,
2.1487875669000003,
2.0550304949,
2.0905197999,
2.1201996009000004,
2.0534898599000004,
2.0969014459000004,
2.0013980529000004,
1.9709035339,
2.1148229779000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.37274671,
"stddev": 0.013542949291876048,
"median": 0.3720917234,
"user": 0.27998574,
"system": 0.6584798599999999,
"min": 0.34618398990000004,
"max": 0.3912043289,
"times": [
0.3726848319,
0.38865871090000004,
0.3840630889,
0.3690198629,
0.3912043289,
0.3714986149,
0.34618398990000004,
0.3772429929,
0.3661813829,
0.3607292959
]
},
{
"command": "pnpr@main",
"mean": 0.3838292818,
"stddev": 0.010350332412843215,
"median": 0.3833855719,
"user": 0.26708104,
"system": 0.67006386,
"min": 0.3703653489,
"max": 0.3974927829,
"times": [
0.3775021429,
0.3892690009,
0.3755958579,
0.39247361090000005,
0.39059981990000003,
0.3974927829,
0.39632461090000004,
0.37338725590000005,
0.3703653489,
0.37528238690000004
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.53748165926,
"stddev": 0.02996346203926205,
"median": 0.53727719626,
"user": 0.53077718,
"system": 0.08434504000000001,
"min": 0.48605482726,
"max": 0.58141529326,
"times": [
0.55370372926,
0.51194758326,
0.5638715252600001,
0.56644490526,
0.52751864326,
0.58141529326,
0.52828473626,
0.50930569326,
0.54626965626,
0.48605482726
]
},
{
"command": "pacquet@main",
"mean": 0.49651289886,
"stddev": 0.04376149730265559,
"median": 0.48775953576,
"user": 0.48763758,
"system": 0.08001304,
"min": 0.43348812526,
"max": 0.58818508226,
"times": [
0.43348812526,
0.45424994826,
0.47271649526,
0.53425833626,
0.58818508226,
0.52177236126,
0.50316214326,
0.48389088926,
0.49162818226,
0.48177742526
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09205960358258065,
"stddev": 0.004028171963126653,
"median": 0.09107025126000001,
"user": 0.020886541290322583,
"system": 0.013095070967741937,
"min": 0.08553045026,
"max": 0.10187128926000001,
"times": [
0.09115549126000001,
0.09402975026,
0.09752777426,
0.09717529826,
0.09282518826000001,
0.09761418526000001,
0.09348293926000001,
0.08749703626000001,
0.09702423526000001,
0.09036546326,
0.08989944426,
0.08921850126000001,
0.10187128926000001,
0.08763861326000001,
0.09021117126,
0.09107025126000001,
0.09050305226000001,
0.08967444026,
0.09145890426,
0.09048635026,
0.08893935426,
0.08676036826000001,
0.09409657526000001,
0.08553045026,
0.08633415426,
0.09005269326000001,
0.09894571526000001,
0.09481645226,
0.09011206526000001,
0.09643765926,
0.09109284426000001
]
},
{
"command": "pnpr@main",
"mean": 0.09315353839793106,
"stddev": 0.008094015951588642,
"median": 0.09124997926,
"user": 0.022524000689655172,
"system": 0.012131836551724137,
"min": 0.08296874026,
"max": 0.12317492426000001,
"times": [
0.09551130226000001,
0.08809386126,
0.08658494726,
0.09651719826,
0.12317492426000001,
0.09874629926,
0.09673250426,
0.09522023326000001,
0.10029023926000001,
0.08608580526000001,
0.08591253926,
0.09362441626000001,
0.08766707726,
0.09124997926,
0.09446684426,
0.11160391526,
0.09473086126000001,
0.08797923526000001,
0.09005752226000001,
0.08296874026,
0.08695642726000001,
0.08842915326,
0.09172628726000001,
0.09026561426,
0.09543627126000001,
0.08878452326000001,
0.09412496926000001,
0.08969588126000001,
0.08881504126
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.6834814818799995,
"stddev": 0.15894748142828638,
"median": 4.61046999978,
"user": 2.4417923200000002,
"system": 1.7719701999999997,
"min": 4.55470798878,
"max": 5.00841460978,
"times": [
4.58680605978,
4.58537723778,
5.00841460978,
4.55470798878,
4.56826421078,
4.62218625878,
4.59875374078,
4.77758993878,
4.90678501878,
4.6259297547800005
]
},
{
"command": "pacquet@main",
"mean": 4.70345142628,
"stddev": 0.15976255573473389,
"median": 4.64525128878,
"user": 2.3168361200000005,
"system": 1.7706003,
"min": 4.52222465878,
"max": 5.02623056178,
"times": [
5.02623056178,
4.58882081878,
4.52222465878,
4.65112457478,
4.60939890178,
4.59926978778,
4.88483507078,
4.841618377780001,
4.63937800278,
4.67161350778
]
},
{
"command": "pnpr@HEAD",
"mean": 3.60067045308,
"stddev": 0.11546024856551722,
"median": 3.57778811328,
"user": 1.53661742,
"system": 1.4977740000000002,
"min": 3.49553137078,
"max": 3.89444882078,
"times": [
3.55926636378,
3.59278573878,
3.5117584717800003,
3.68160217578,
3.58638390778,
3.57277783878,
3.52935145478,
3.49553137078,
3.58279838778,
3.89444882078
]
},
{
"command": "pnpr@main",
"mean": 3.5986844921800007,
"stddev": 0.13831520512142517,
"median": 3.57469179428,
"user": 1.3710725199999998,
"system": 1.4124843999999999,
"min": 3.47031829878,
"max": 3.91969447078,
"times": [
3.7084937367800004,
3.91969447078,
3.6317783507800003,
3.53251210278,
3.50201511278,
3.47948784678,
3.62867300578,
3.49700051078,
3.47031829878,
3.61687148578
]
}
]
} |
…ning text Two follow-ups from review of the scheme-specifier peer support. hoistPeers decided whether a missing peer's range was semver by testing the raw specifier, so a scheme-carrying peer (work:^1.0.0, npm:bar@^5) was treated as non-semver and deduped onto the highest already-resolved version regardless of its range — auto-installing a version the peer rejects. Run the semver decision through getPeerVersionRange, keeping the raw specifier for the fallback that fetches the package, so scheme peers dedupe onto a compatible version when one exists and otherwise resolve from their original source. Fixed in both stacks. The Rust resolver reused one field for both the auto-install (hoist) source and the unmet-peer warning text, so it displayed the raw specifier while the TypeScript CLI displayed the extracted range. Split them: MissingPeer now carries wanted_range (the extracted range, for matching and display) and raw_range (the original specifier, read by the importer hoist loop), so both stacks show the same normalized range in warnings while auto-install still fetches from the right source.
|
Follow-up pushed in 2ea26bb addressing the automated review: Qodo (hoistPeers range-awareness): fixed — the auto-install selection now reduces scheme specifiers to a comparable range via CodeRabbit ( The real inconsistency was the opposite: Rust Written by an agent (Claude Code, claude-opus-4-8). |
|
Code review by qodo was updated up to the latest commit 2ea26bb |
…e range When several consumers require the same peer with different scheme specifiers and auto-install-peers-from-highest-match is enabled, the ranges are merged into a `||` union of the raw specs (`work:^1.0.0 || work:^2.0.0`). getPeerVersionRange could not parse that and fell back to `*`, so the hoist picker selected the highest preferred version even when it satisfied none of the declared ranges. Handle a `||` union in getPeerVersionRange by reducing each alternative to its version body, yielding a comparable semver union (`^1.0.0 || ^2.0.0`). The union is checked before the valid-range short-circuit, because node-semver leniently parses a union whose alternatives carry a scheme while the JS semver does not — doing the split first keeps both stacks identical. Fixed in the shared helper in both stacks, with unit tests and a hoist regression test that a version satisfying none of the merged ranges is not chosen.
|
Code review by qodo was updated up to the latest commit 3bc9685 |
|
Found 1 test failure on Blacksmith runners: Failure
|

Summary
peerDependenciesrejected any value that was not a semver range or aworkspace:/catalog:spec, throwingERR_PNPM_INVALID_PEER_DEPENDENCY_SPECIFICATION. This blocked named-registry specifiers likework:5.x.xin peers, even though they work fine independencies/devDependencies(Closes #13095).This PR accepts any specifier that carries a scheme — a named-registry spec (
<registry>:<version>), annpm:alias, or afile:/git/URL spec. During resolution the peer is matched against the semver range the specifier carries (work:5.x.x→5.x.x,npm:bar@^5→^5), or against*when it carries no version, while the original specifier still selects the package to auto-install. Barename@versionvalues (no scheme, not valid semver) are still rejected, since they are almost always a mistake.A shared
getPeerVersionRange/get_peer_version_rangehelper extracts the comparable range at every point a peer is matched: the satisfaction check, thehoistPeersauto-install selection (so a scheme peer dedupes onto a compatible version instead of the highest one in the tree), and the peers checker. Validation is relaxed viaisAcceptablePeerSpec/is_acceptable_peer_spec. The original specifier is preserved wherever a missing peer is actually fetched, so auto-install still resolves from the right source.TypeScript: new helpers in
@pnpm/deps.peer-range;validatePeerDependencies, bothresolvePeersmatch sites,hoistPeers, and thepeers-checkerroute through them.Rust (parity): new shared
peer_rangemodule inresolving-resolver-base(which also absorbs the two duplicatedis_valid_peer_rangecopies);resolve_peers,hoist_peers, and thepnpm peerscommand use it.MissingPeercarries the extracted range for matching/display and the original specifier for the hoist source, so warnings show the same normalized range as the TypeScript CLI while auto-install still fetches from the right source.Squash Commit Body
Checklist
pnpm/port.Written by an agent (Claude Code, claude-opus-4-8).
Summary by CodeRabbit
npm:aliases, localfile:sources, and Git/URL-style specs), enabling better matching and auto-install when configured.||unions.name@versionpeer values with the existing validation error.work:) peer specs and related hoisting/matching scenarios.