fix(arborist): propagate overrides through Link nodes to targets#9198
Open
manzoorwanijk wants to merge 3 commits intonpm:latestfrom
Open
fix(arborist): propagate overrides through Link nodes to targets#9198manzoorwanijk wants to merge 3 commits intonpm:latestfrom
manzoorwanijk wants to merge 3 commits intonpm:latestfrom
Conversation
This method was a workaround for overrides not propagating through Link nodes to their targets. Now that Link.recalculateOutEdgesOverrides properly forwards overrides, workspace edges already have the correct overridden spec, making this detach logic unreachable dead code.
Verifies that when a Link node receives overrides via edgesIn, they are forwarded to its target node. The target's outgoing edges should use the overridden spec. Also covers the no-op case when target is null.
wraithgar
reviewed
Apr 7, 2026
Member
|
We are waiting to land any PRs until node ships with a newer version of the cli. CI should be green when that happens. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In continuation of our exploration of using
install-strategy=linkedin the Gutenberg monorepo, which powers the WordPress Block Editor.When using
install-strategy=linked, npm overrides for transitive dependencies were ignored.The overridden version was installed but reported as
invalidinstead ofoverridden, and withstrict-peer-depsthe install failed entirely withERESOLVE.The root cause is that override propagation stops at Link nodes and never reaches their targets.
Overrides propagate through the tree via
addEdgeIn->updateOverridesEdgeInAdded->recalculateOutEdgesOverrides.When a Link node receives overrides,
recalculateOutEdgesOverridesiterates overthis.edgesOut— but Links have noedgesOut(their targets do).So overrides never reach the target node's dependency edges, and those edges use
rawSpecinstead of the overridden spec.In the linked strategy, all packages in
node_modules/are Links pointing to targets in.store/.This meant no overrides propagated past the first level of the dependency tree.
The fix overrides
recalculateOutEdgesOverridesin theLinkclass to forward overrides to the target node.When
buildIdealTreecreates a root Link (e.g. on macOS where/tmp->/private/tmp), the target Node is now created withloadOverrides: trueso it loads override rules frompackage.json.The
#applyRootOverridesToWorkspacesworkaround method is removed — it was compensating for this exact bug by detaching workspace edges whose specs didn't match. With proper propagation, workspace edges already have the correct overridden spec, making the workaround dead code.References
Fixes #9197