fix(arborist): do not hoist undeclared workspaces in linked strategy#9076
Merged
wraithgar merged 3 commits intonpm:latestfrom Mar 7, 2026
Merged
Conversation
…d as dependencies With install-strategy=linked, all workspace packages were unconditionally symlinked into root node_modules/ regardless of whether root declared them as dependencies. Filter undeclared workspace deps in assignCommonProperties so they don't enter root's localDependencies, and only create root-level workspace links for explicitly declared dependencies.
1b55fb2 to
e9d4b06
Compare
2 tasks
wraithgar
reviewed
Mar 7, 2026
wraithgar
reviewed
Mar 7, 2026
wraithgar
reviewed
Mar 7, 2026
wraithgar
approved these changes
Mar 7, 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
With
install-strategy=linked, all workspace packages are unconditionally symlinked into the rootnode_modules/, regardless of whether the root declares them as dependencies. This defeats the strict isolation that the linked strategy is supposed to provide — any workspace can import any other workspace without declaring it as a dependency.The root cause is two-fold:
assignCommonProperties()includes all workspaces in root'slocalDependenciesbecause npm auto-createstype: 'workspace'edges from root to every workspacecreateIsolatedTree()unconditionally creates a workspace Link entry inroot.childrenatnode_modules/<wsName>for every workspaceThe fix:
#assignCommonProperties()so they don't enter root'slocalDependenciesnode_modules/<wsName>) for declared dependenciesBefore (broken)
After (fixed)
No symlinks at root
node_modules/since root doesn't depend on either workspace.References
Fixes #9072
Related to #6537 (same problem with
--install-strategy=nested)