fix(arborist): omit root dev deps in linked strategy when shared with workspaces#9081
Merged
wraithgar merged 2 commits intonpm:latestfrom Mar 9, 2026
Merged
Conversation
wraithgar
previously approved these changes
Mar 9, 2026
wraithgar
reviewed
Mar 9, 2026
wraithgar
approved these changes
Mar 9, 2026
manzoorwanijk
added a commit
to manzoorwanijk/npm-cli
that referenced
this pull request
Mar 9, 2026
wraithgar
pushed a commit
that referenced
this pull request
Mar 9, 2026
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.Summary
Fixes
--omit=dev(and--omit=optional,--omit=peer) not being fully respected in the linked install strategy for monorepos.PR #9066 added a
shouldOmit()check during graph traversal inmakeIdealGraph(), which works for dev deps that are only dev deps. However, it missed two cases:dev=false(reachable via prod paths), soshouldOmit()returns false. The package correctly goes into the store (the workspace needs it), but root incorrectly gets a symlink to it because#assignCommonProperties()doesn't filter by edge type.devDependenciesare always hoisted to root'snode_modules/because#rootDeclaredDepsunconditionally includesdevDependencieskeys, and npm auto-createsworkspacetype edges (notdevedges) for all workspaces.Changes
#assignCommonProperties()for root and workspace nodes — dev, optional, and peer edges are excluded when their corresponding--omitflag is set.#rootDeclaredDeps— so workspaces declared only as root devDependencies aren't hoisted when--omit=devis set.References
Fixes #9080