Repository navigation
fix(resolving-deps-resolver): apply overrides and the workspace root's pin to hoisted peers - #13369
Conversation
…s pin to hoisted peers Two peer-hoisting fixes, in both the TypeScript CLI and pacquet. overrides now govern peers pnpm auto-installs. Overrides are applied by the read-package hook, which only sees manifests; a peer nobody declares never passes through one, so it resolved against its declared peer range and could introduce a second copy of the package the override pinned. The required-peer picker now consults the override set first. The per-edge lookup that backs the hook is factored out and shared, so the two paths cannot drift: hooks/read-package-hook exports createDependencyOverrider, and pacquet's VersionsOverrider grows override_for_undeclared_dependency. Parent-scoped overrides cannot apply (no parent manifest), and a convergence override still applies only when its version satisfies the edge's range. The convergence collector does not see these edges — a range no manifest declares would skew the staleness verdict. getHoistableOptionalPeers now bounds its candidates by the workspace root's own specifier for the package, the same input hoistPeers short-circuits on. It previously maximised over every version in the graph, so an optional peer declared as `*` — the shape peerDependenciesMeta produces — pulled the newest version any importer had resolved into a sibling that declares nothing, next to the version the root pins. The alias-then-package-name precedence for finding that root dependency is now one helper shared by both pickers. Measured on vercel/next.js: the lockfile diff between the two stacks drops from 718 to 138 lines, the two stacks' resolved package key sets and every importer block now match, and the only remaining difference is three snapshot instances pacquet does not deduplicate. Related to #13320. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe changes thread dependency-edge overrides through TypeScript and Rust resolution paths. Required peer hoisting now supports rewritten or removed specifiers, while optional peer selection respects compatible workspace-root dependency ranges. ChangesPeer resolution behavior
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Installer
participant OverrideProvider
participant DependencyResolver
participant PeerHoister
participant WorkspaceRoot
Installer->>OverrideProvider: create bare-specifier override
Installer->>DependencyResolver: resolve dependencies with override hook
DependencyResolver->>PeerHoister: hoist required and optional peers
PeerHoister->>WorkspaceRoot: read root dependency range
WorkspaceRoot-->>PeerHoister: return allowed range
PeerHoister-->>DependencyResolver: return overridden and bounded peer results
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 honor overrides and workspace-root pins
AI Description
Diagram
High-Level Assessment
Files changed (20)
|
Confidence Score: 4/5The new follow-up fixes appear sound, but the outstanding Pacquet workspace-root range loss should be resolved before merging. Pacquet still removes versioned Files Needing Attention: pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs Reviews (7): Last reviewed commit: "perf(read-package-hook): skip the overri..." | Re-trigger Greptile |
Micro-Benchmark ResultsLinux |
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 #13369 +/- ##
=======================================
Coverage 87.21% 87.22%
=======================================
Files 536 536
Lines 92034 92114 +80
=======================================
+ Hits 80269 80347 +78
- Misses 11765 11767 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 @.changeset/overrides-reach-auto-installed-peers.md:
- Line 9: Update the changeset description to qualify that override behavior for
auto-installed peers is limited: parent-scoped overrides do not affect
undeclared peers, and convergence overrides apply only when compatible. Keep the
existing example and behavior description, adding only a brief clarification
that not every override applies to every auto-installed peer.
- Around line 2-6: Update the changeset entries for
`@pnpm/hooks.read-package-hook`, `@pnpm/installing.deps-resolver`,
`@pnpm/installing.deps-installer`, pacquet, and pnpm from minor to patch, since
this change only fixes auto-installed peer override backfilling and introduces
no public API change.
In `@pnpm11/installing/deps-resolver/src/hoistPeers.ts`:
- Around line 105-106: Update the rootRange calculation near rootBareSpecifier
to pass the workspace protocol specifier through getPeerVersionRange() before
semver.validRange(), ensuring workspace:^ ranges produce a usable bound for
optional peer hoisting. Add a regression test covering a workspace: peer range
and confirming an incompatible newer major is not hoisted.
🪄 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: 29d89c38-4b52-48ac-ae7e-c670858f0ab2
📒 Files selected for processing (20)
.changeset/optional-peer-hoist-respects-workspace-root.md.changeset/overrides-reach-auto-installed-peers.mdpnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/package-manager/src/overrides.rspnpm/crates/package-manager/src/overrides/tests.rspnpm/crates/resolving-deps-resolver/src/hoist_peers.rspnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rspnpm/crates/resolving-deps-resolver/src/lib.rspnpm/crates/resolving-deps-resolver/src/resolve_importer.rspnpm/crates/resolving-deps-resolver/src/resolve_importer/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rspnpm11/hooks/read-package-hook/src/createVersionsOverrider.tspnpm11/hooks/read-package-hook/src/index.tspnpm11/hooks/read-package-hook/test/createVersionOverrider.test.tspnpm11/installing/deps-installer/src/getPeerDependencyIssues.tspnpm11/installing/deps-installer/src/install/index.tspnpm11/installing/deps-resolver/src/hoistPeers.tspnpm11/installing/deps-resolver/src/resolveDependencies.tspnpm11/installing/deps-resolver/src/resolveDependencyTree.tspnpm11/installing/deps-resolver/test/hoistPeers.test.ts
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.53344676752,
"stddev": 0.17503746488706864,
"median": 2.48891119852,
"user": 1.51484688,
"system": 1.31771886,
"min": 2.35756924802,
"max": 2.7919532680200003,
"times": [
2.71991140702,
2.37528181902,
2.42550666002,
2.65439209702,
2.37316560502,
2.7919532680200003,
2.55231573702,
2.36091039802,
2.35756924802,
2.72346143602
]
},
{
"command": "pacquet@main",
"mean": 2.5337454253200002,
"stddev": 0.16466081036830385,
"median": 2.54898039252,
"user": 1.51125438,
"system": 1.2861051599999997,
"min": 2.34159798002,
"max": 2.7643683980200002,
"times": [
2.75916418302,
2.63166211902,
2.36436342402,
2.7643683980200002,
2.53531264902,
2.63626254902,
2.35484934502,
2.56264813602,
2.38722547002,
2.34159798002
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5485666961200002,
"stddev": 0.18566053787570078,
"median": 1.53171422452,
"user": 1.0667137800000002,
"system": 1.13206126,
"min": 1.3497587850200001,
"max": 1.78454681902,
"times": [
1.61113224002,
1.3497587850200001,
1.75740816302,
1.45229620902,
1.3768136850200001,
1.63331566002,
1.35055028202,
1.38531717302,
1.78454681902,
1.7845279450200002
]
},
{
"command": "pnpr@main",
"mean": 1.49029383202,
"stddev": 0.11083011913530623,
"median": 1.46120289502,
"user": 1.03471638,
"system": 1.18208056,
"min": 1.37360173702,
"max": 1.66183069602,
"times": [
1.3834657510200001,
1.66183069602,
1.4096906630200001,
1.37360173702,
1.4440164750200002,
1.39621952502,
1.64798793602,
1.47838931502,
1.60637855002,
1.5013576720200001
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.26036897752000004,
"stddev": 0.004438356513567172,
"median": 0.25987877812000004,
"user": 0.22052524000000004,
"system": 0.5355572599999999,
"min": 0.25429433162000004,
"max": 0.26990110762,
"times": [
0.26349338862000005,
0.25989119662000004,
0.25656215762,
0.26029177962000005,
0.25986635962000004,
0.26990110762,
0.25658866662,
0.25429433162000004,
0.25935476662,
0.26344602062000005
]
},
{
"command": "pacquet@main",
"mean": 0.2587050946200001,
"stddev": 0.009118637114051965,
"median": 0.25469112812000005,
"user": 0.21014863999999997,
"system": 0.5257750600000001,
"min": 0.24993609762,
"max": 0.27571750262000005,
"times": [
0.27275606462,
0.26402187262000004,
0.27571750262000005,
0.25474811462,
0.25260169962,
0.25834335562000005,
0.25463414162000003,
0.25156473062,
0.24993609762,
0.25272736662000006
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27192443572,
"stddev": 0.004324511533619233,
"median": 0.27120146212000007,
"user": 0.22348193999999996,
"system": 0.54332236,
"min": 0.26399779062,
"max": 0.27955593662000006,
"times": [
0.27165592662000004,
0.27590131862000006,
0.27032998762000005,
0.27417408062000004,
0.27955593662000006,
0.27074699762000004,
0.26866406262000003,
0.27452424862,
0.26969400762,
0.26399779062
]
},
{
"command": "pnpr@main",
"mean": 0.27039701962,
"stddev": 0.00664223716927327,
"median": 0.27227904312000006,
"user": 0.21109583999999998,
"system": 0.5381364599999999,
"min": 0.25694830862,
"max": 0.27946199062000004,
"times": [
0.27409819662,
0.27946199062000004,
0.26516227862,
0.27188023862000005,
0.27267784762,
0.27532510362,
0.26726668462000003,
0.25694830862,
0.26550620562000005,
0.27564334162000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.78305815744,
"stddev": 0.019318863657989703,
"median": 2.78410015224,
"user": 1.6549562799999997,
"system": 1.3795323999999998,
"min": 2.75203264624,
"max": 2.8116117432400003,
"times": [
2.79027135824,
2.75203264624,
2.76089326224,
2.7758342482400002,
2.79209877324,
2.80464423624,
2.79697224524,
2.7779289462400003,
2.7682941152400002,
2.8116117432400003
]
},
{
"command": "pacquet@main",
"mean": 2.7646594162400002,
"stddev": 0.02146479480215544,
"median": 2.7664335822400004,
"user": 1.71397618,
"system": 1.2790126,
"min": 2.72203028724,
"max": 2.79040540924,
"times": [
2.72203028724,
2.77776955624,
2.76154904524,
2.76198725924,
2.77087990524,
2.73623011924,
2.79040540924,
2.78344824324,
2.76130526724,
2.78098907024
]
},
{
"command": "pnpr@HEAD",
"mean": 1.55391081654,
"stddev": 0.1448644993264488,
"median": 1.4843545252400001,
"user": 1.04209548,
"system": 1.1545903,
"min": 1.4381529052400002,
"max": 1.8009606902400002,
"times": [
1.50038702624,
1.72817550824,
1.5161314572400002,
1.4381529052400002,
1.4457342232400001,
1.45272622324,
1.74797277524,
1.4405453322400001,
1.4683220242400001,
1.8009606902400002
]
},
{
"command": "pnpr@main",
"mean": 1.52641239644,
"stddev": 0.12555039441330423,
"median": 1.4620653857400001,
"user": 1.00461568,
"system": 1.1860534,
"min": 1.43457992024,
"max": 1.7948168632400001,
"times": [
1.43457992024,
1.4429186012400002,
1.4721574722400002,
1.5816539092400002,
1.45197329924,
1.7948168632400001,
1.5099584942400002,
1.6937593482400002,
1.44708113424,
1.4352249222400002
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.60295828988,
"stddev": 0.008874817805939366,
"median": 0.60207593368,
"user": 0.7420359999999999,
"system": 0.6662763600000001,
"min": 0.59167527718,
"max": 0.61830043018,
"times": [
0.59301473818,
0.6122418991799999,
0.60709745618,
0.60422469418,
0.59761006618,
0.61830043018,
0.59551730018,
0.59167527718,
0.59992717318,
0.60997386418
]
},
{
"command": "pacquet@main",
"mean": 0.58800870378,
"stddev": 0.01616860157424987,
"median": 0.58615282318,
"user": 0.7097576999999999,
"system": 0.68592516,
"min": 0.56613472318,
"max": 0.61427984018,
"times": [
0.57214607618,
0.59269974318,
0.59780490218,
0.58921620318,
0.61066323018,
0.61427984018,
0.58308944318,
0.58117794918,
0.57287492718,
0.56613472318
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30201193278000005,
"stddev": 0.006025418434571227,
"median": 0.30234757668,
"user": 0.19662459999999998,
"system": 0.52518686,
"min": 0.29304213418,
"max": 0.31361146118000005,
"times": [
0.30419258118000003,
0.30270905118,
0.29377497318,
0.30174732318,
0.30675802518,
0.30198610218000005,
0.31361146118000005,
0.30384791318000004,
0.29304213418,
0.29844976318000005
]
},
{
"command": "pnpr@main",
"mean": 0.30342395398000005,
"stddev": 0.005442859039459716,
"median": 0.30323682468,
"user": 0.19580919999999996,
"system": 0.54036366,
"min": 0.29508266118000004,
"max": 0.31309911818,
"times": [
0.30302991618,
0.30497484218000004,
0.30898196618,
0.29899810418,
0.29508266118000004,
0.29748020018000004,
0.30208249318,
0.31309911818,
0.30706650518,
0.30344373318
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.91267382222,
"stddev": 0.010658533012920074,
"median": 1.91057593192,
"user": 0.89408854,
"system": 0.79035756,
"min": 1.8940877979200001,
"max": 1.93026904892,
"times": [
1.93026904892,
1.92545884492,
1.9105313769199999,
1.90965827492,
1.8940877979200001,
1.92221979492,
1.90623919692,
1.90536842392,
1.91062048692,
1.91228497592
]
},
{
"command": "pacquet@main",
"mean": 1.90361530442,
"stddev": 0.00958367286507265,
"median": 1.89959644942,
"user": 0.94397374,
"system": 0.7652455600000001,
"min": 1.89506974392,
"max": 1.9219580779199998,
"times": [
1.91692143092,
1.89599781892,
1.9106822129199998,
1.90002602192,
1.90317587292,
1.89506974392,
1.89688630892,
1.8991668769199999,
1.8962686789199998,
1.9219580779199998
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29535741212,
"stddev": 0.007885676877366885,
"median": 0.29521171492,
"user": 0.19287604,
"system": 0.49993745999999994,
"min": 0.28214547292000003,
"max": 0.30839140092,
"times": [
0.29696095292,
0.29053343092,
0.29208598992,
0.29408553792000003,
0.28933084092,
0.28214547292000003,
0.29633789192,
0.29658675992,
0.30839140092,
0.30711584292
]
},
{
"command": "pnpr@main",
"mean": 0.30644883072,
"stddev": 0.0062859882176956,
"median": 0.30558621742000003,
"user": 0.20176203999999998,
"system": 0.53902566,
"min": 0.29552896092000003,
"max": 0.31575621492,
"times": [
0.30434107592,
0.30832317192,
0.30665830292,
0.29552896092000003,
0.31222824292,
0.30025669892,
0.30451413192,
0.30304031192,
0.31384119492,
0.31575621492
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.35825434678,
"stddev": 0.006219176199411607,
"median": 0.36008380718,
"user": 0.34771539999999995,
"system": 0.061521059999999995,
"min": 0.34534523118,
"max": 0.36533287418,
"times": [
0.34534523118,
0.36181234618,
0.35914398018,
0.35873018218,
0.36533287418,
0.36102363418,
0.35266151418,
0.36366409618,
0.36231641418,
0.35251319518
]
},
{
"command": "pacquet@main",
"mean": 0.34461403618,
"stddev": 0.00801291982789606,
"median": 0.34306985918,
"user": 0.3359444,
"system": 0.05263456,
"min": 0.33631555818000003,
"max": 0.36398961918,
"times": [
0.34220410718,
0.33742602518,
0.33631555818000003,
0.35164295018,
0.34416200718,
0.34204933518,
0.34419235518,
0.34393561118,
0.34022279318,
0.36398961918
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08729064415058822,
"stddev": 0.0009163633267236468,
"median": 0.08737724318000001,
"user": 0.020161699999999998,
"system": 0.00926032588235294,
"min": 0.08462448918,
"max": 0.08896460118,
"times": [
0.08462448918,
0.08722970618,
0.08839142018,
0.08678186518,
0.08774808118,
0.08667936218,
0.08814016818,
0.08667825918000001,
0.08811921918,
0.08828037118,
0.08543514018000001,
0.08819523518,
0.08688740718,
0.08697542318,
0.08823631218,
0.08695963318,
0.08714704618,
0.08768172118,
0.08787138718,
0.08667131018,
0.08724200318,
0.08730101518,
0.08783241418,
0.08834910518,
0.08729338018,
0.08585603918,
0.08759358518,
0.08755682518,
0.08779767818,
0.08755904918,
0.08745347118,
0.08636831218,
0.08896460118,
0.08598086418
]
},
{
"command": "pnpr@main",
"mean": 0.08751389590727274,
"stddev": 0.0016924030792995805,
"median": 0.08728909218,
"user": 0.02155118484848485,
"system": 0.007998736969696968,
"min": 0.08300612218,
"max": 0.09150910418000001,
"times": [
0.08698352718,
0.08562679818,
0.08300612218,
0.08672037318,
0.08818212118,
0.08702819218,
0.08712712718,
0.08775609018,
0.08632383918,
0.08854024518,
0.08708487918,
0.08689752618,
0.09069901218,
0.08540846718,
0.08656857818000001,
0.08737676718000001,
0.08747141518,
0.08732086218,
0.08728909218,
0.08809636018,
0.08704332018000001,
0.08840843618000001,
0.08659850318000001,
0.08665367718,
0.08707771518,
0.08784546818,
0.09150910418000001,
0.08800713218,
0.08859789218,
0.08479824118,
0.08986619718,
0.08923428918,
0.09081119318
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.541350862220001,
"stddev": 0.11648866141404093,
"median": 4.52875018332,
"user": 1.6852215000000001,
"system": 1.35258498,
"min": 4.41877995132,
"max": 4.73849362032,
"times": [
4.52076025532,
4.43361998432,
4.73849362032,
4.732072001320001,
4.43673282632,
4.57288860632,
4.53674011132,
4.41877995132,
4.4564150513200005,
4.56700621432
]
},
{
"command": "pacquet@main",
"mean": 4.55337530652,
"stddev": 0.11905616318417774,
"median": 4.478065393820001,
"user": 1.6710694999999998,
"system": 1.40270368,
"min": 4.44547021232,
"max": 4.743764773320001,
"times": [
4.70899418832,
4.468341945320001,
4.46760161432,
4.44547021232,
4.45485536032,
4.68317588732,
4.4877888423200005,
4.46805970532,
4.743764773320001,
4.6057005363200005
]
},
{
"command": "pnpr@HEAD",
"mean": 3.48442023562,
"stddev": 0.04711376351785575,
"median": 3.4727364968199996,
"user": 1.2068772999999997,
"system": 1.23298858,
"min": 3.44232092132,
"max": 3.6029396283199997,
"times": [
3.4715981923199997,
3.4738748013199996,
3.4983910153199997,
3.45751280032,
3.6029396283199997,
3.48607960832,
3.44232092132,
3.44727035232,
3.5101235253199996,
3.4540915113199997
]
},
{
"command": "pnpr@main",
"mean": 3.5656472551199996,
"stddev": 0.09371512211768679,
"median": 3.5552541263199995,
"user": 1.1298814,
"system": 1.2753853800000001,
"min": 3.4579254473199996,
"max": 3.7329236933199996,
"times": [
3.7329236933199996,
3.50954757232,
3.4579254473199996,
3.47822755132,
3.58050603832,
3.68094407532,
3.63842799232,
3.55482122832,
3.4674619283199997,
3.5556870243199996
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13369 |
| 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,438.15 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 282.15 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 293.04 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.62 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,349.76 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,442.32 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 264.00 ms |
…r mandate Three follow-ups from review of the peer-hoisting fixes, in both stacks. An override must redirect a hoist, never create one. With autoInstallPeers off, hoisting only deduplicates a package the graph or the workspace root already provides; consulting the overrides ahead of those checks let an override install a peer that appears nowhere in the workspace, in a configuration that asks for no peer to be auto-installed. The picker now skips a peer nothing provides before it looks at the override set. The overrider learns the directory of the importer the peer is hoisted into, so a `link:` / `file:` override target stays relative to it. Called without a directory, the local-override renderer falls back to the absolute path, which would write this machine's filesystem layout into the importer's specifier in the lockfile. getHoistableOptionalPeers reads the workspace root's specifier through getPeerVersionRange, so a `workspace:` range or an `npm:` alias bounds the candidates as well; parsed raw, both yield no range and left the candidates unbounded, which is the shape the fix set out to bound. Also: pickVersionOverride takes its two override sets as one object, and the changeset bumps the packages that only gained wiring as patch. Related to #13320. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…into one helper The package directory argument repeated at every call site pushed each assertion onto several lines, which the perfectionist trailing-comma rule then rejected. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Addressing the Qodo findings, all in 7f4bc57: 1. Local override target on an undeclared peer (valid, fixed). The overrider now receives the directory of the importer the peer is hoisted into, so a 2. 3. Trailing commas in multi-line parameter lists (not applied). This repo's ESLint config sets Written by an agent (Claude Code, claude-opus-5). |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/package-manager/src/overrides/tests.rs (1)
27-28: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the restatement comment.
It only narrates the helper and its fixed fixture path, rather than documenting a non-obvious invariant. As per coding guidelines, “comments should explain only non-obvious reasons or invariants.”
🤖 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/package-manager/src/overrides/tests.rs` around lines 27 - 28, Remove the restatement doc comment above VersionsOverrider::override_for_undeclared_dependency in the test fixture, leaving the helper and its behavior unchanged.Sources: Coding guidelines, 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 `@pnpm/crates/package-manager/src/overrides/tests.rs`:
- Around line 27-28: Remove the restatement doc comment above
VersionsOverrider::override_for_undeclared_dependency in the test fixture,
leaving the helper and its behavior unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: a167b6e7-66a3-4262-b7ef-21024c7e6ada
📒 Files selected for processing (13)
.changeset/overrides-reach-auto-installed-peers.mdpnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm/crates/package-manager/src/overrides.rspnpm/crates/package-manager/src/overrides/tests.rspnpm/crates/resolving-deps-resolver/src/hoist_peers.rspnpm/crates/resolving-deps-resolver/src/hoist_peers/tests.rspnpm/crates/resolving-deps-resolver/src/resolve_importer.rspnpm11/hooks/read-package-hook/src/createVersionsOverrider.tspnpm11/hooks/read-package-hook/test/createVersionOverrider.test.tspnpm11/installing/deps-resolver/src/hoistPeers.tspnpm11/installing/deps-resolver/src/resolveDependencies.tspnpm11/installing/deps-resolver/src/resolveDependencyTree.tspnpm11/installing/deps-resolver/test/hoistPeers.test.ts
🚧 Files skipped from review as they are similar to previous changes (8)
- .changeset/overrides-reach-auto-installed-peers.md
- pnpm11/installing/deps-resolver/src/resolveDependencyTree.ts
- pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
- pnpm11/installing/deps-resolver/src/resolveDependencies.ts
- pnpm/crates/package-manager/src/overrides.rs
- pnpm11/installing/deps-resolver/src/hoistPeers.ts
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
- pnpm11/hooks/read-package-hook/src/createVersionsOverrider.ts
…s pin to hoisted peers (pnpm#13369) Two peer-hoisting fixes, in both the TypeScript CLI and pacquet. overrides now govern peers pnpm auto-installs. Overrides are applied by the read-package hook, which only sees manifests; a peer nobody declares never passes through one, so it resolved against its declared peer range and could introduce a second copy of the package the override pinned. The required-peer picker now consults the override set first. The per-edge lookup that backs the hook is factored out and shared, so the two paths cannot drift: hooks/read-package-hook exports createDependencyOverrider, and pacquet's VersionsOverrider grows override_for_undeclared_dependency. Parent-scoped overrides cannot apply (no parent manifest), and a convergence override still applies only when its version satisfies the edge's range. The convergence collector does not see these edges — a range no manifest declares would skew the staleness verdict. An override redirects a hoist rather than creating one: without autoInstallPeers, a peer neither the graph nor the workspace root provides stays uninstalled. The overrider is handed the directory of the importer the peer is hoisted into, so a link: / file: target stays relative to it. getHoistableOptionalPeers now bounds its candidates by the workspace root's own specifier for the package, the same input hoistPeers short-circuits on. It previously maximised over every version in the graph, so an optional peer declared as `*` — the shape peerDependenciesMeta produces — pulled the newest version any importer had resolved into a sibling that declares nothing, next to the version the root pins. The alias-then-package-name precedence for finding that root dependency is now one helper shared by both pickers, and the root's specifier is read through getPeerVersionRange so a workspace: range or an npm: alias bounds the candidates as well. Measured on vercel/next.js: the lockfile diff between the two stacks drops from 718 to 138 lines, the two stacks' resolved package key sets and every importer block now match, and the only remaining difference is three snapshot instances pacquet does not deduplicate. Related to pnpm#13320.
…ejects (#13869) getHoistableOptionalPeers bounds its candidates by the workspace root's own specifier for the package, so the root decides the version an optional peer is hoisted at. A specifier disjoint from the declared peer range bounded the candidates down to none: nothing was hoisted, and the importer then fell back to the root's version through resolvePeersFromWorkspaceRoot, which is the very version the peer range rejects. A root pinning date-fns 2.30.0 gave an importer @base-ui/react([email protected]) for an optional date-fns@^4.0.0 peer while [email protected] sat in the graph, and pnpm peers check then reported that resolution as unmet. The root's specifier is now consulted only when it overlaps every range recorded for the peer. An overlapping pin still bounds the candidates as before, so the hoisting corrected in #13369 stays; a disjoint one is dropped and the picker maximizes over the graph again. Fixes #13867 --------- Co-authored-by: Zoltan Kochan <[email protected]>
Summary
Two peer-hoisting fixes from #13320, both landed in the TypeScript CLI and pacquet together.
1.
overridesnow reach auto-installed peers. An override only ever rewrote dependencies declared in a manifest, because it is applied through the read-package hook. A peer nobody declares — installed becauseautoInstallPeersis on — has no manifest to rewrite, so it resolved against its declared peer range instead and could pull in a second copy of the very package the override pinned:Before:
[email protected]. After:[email protected], on both stacks (verified byte-identical lockfiles).The required-peer picker now consults the override set before the workspace-root short-circuit and before
allPreferredVersions. Parent-scoped overrides (parent>child) do not apply — there is no parent manifest to match — and a convergence override ("pkg@") applies only when its version satisfies the peer range, exactly as for a declared edge.An override redirects a hoist; it never creates one. With
autoInstallPeersoff (dedupePeerDependentskeeps hoisting active), hoisting only deduplicates a package the graph or the workspace root already provides, so a peer nothing provides stays uninstalled even when an override names it. Alink:/file:override target is resolved relative to the importer the peer is hoisted into, so the importer's specifier stays portable instead of recording an absolute path.2. The optional-peer hoist now respects the workspace root's specifier.
resolvePeersFromWorkspaceRoot(on by default) makes the workspace root's own specifier decide which version a missing required peer is installed at.getHoistableOptionalPeersignored it entirely and always took the highest version present anywhere in the graph. The root specifier is read throughgetPeerVersionRange, so aworkspace:range or annpm:alias bounds the candidates too; one with no version body leaves them unbounded.On
vercel/next.js,[email protected]declarespostcssas an optional peer throughpeerDependenciesMetaalone — so it arrives with range*— and the three importers that depend onwebpackand declare nopostcssgot[email protected]hoisted, in a workspace whose root pinspostcss: 8.5.10. Each of those importers then also hoisted[email protected]for the requiredpostcsspeer of thecssnanoit had just hoisted, so which of the two won thepostcssalias came down to ordering.Measured on
vercel/next.js@dcf242a1with both stacks run back to back — full re-resolution, same tree:pnpm-lock.yamldiff, TS vs pacquetsnapshots:keys only in one stack[email protected]references, TS lockfileThe 3 remaining pacquet-only keys (
[email protected],@2.32.0,@napi-rs/[email protected]) are cases where pacquet keeps a second instance the TypeScript CLI deduplicates. Separate issue, not touched here.Related to #13320.
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).
Summary by CodeRabbit
-to remove unwanted edges.overridesalso apply to peers automatically installed viaautoInstallPeers.