fix(arborist): drop self-link materialization for undeclared workspaces#9399
Open
manzoorwanijk wants to merge 1 commit into
Open
Conversation
a1934f3 to
4059d99
Compare
In install-strategy=linked, every workspace not listed in root's deps got a self-symlink at <ws>/node_modules/<wsName> as a side effect of parking its IsolatedLink off-root. Keep the Link in the tree so install scripts and --workspace filters still work, but mark it as tree-only so the reifier skips materialization and the orphan sweep removes any stale self-link left over from an older npm version. Fixes npm#9398
4059d99 to
53ef290
Compare
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
In
install-strategy=linked, every workspace not listed in the rootpackage.json's deps was getting a self-symlink inside its ownnode_modules/(e.g.packages/test/node_modules/@namespace/test -> ..).The workspace did not declare itself as a dependency; the link was a side effect of #9076 parking the workspace
IsolatedLinkoff-root.pnpm does not create such a self-link — packages that need to self-resolve by name are expected to use Node's
exports-based self-referencing.Fix
Keep the workspace
IsolatedLinkin the tree (so--workspacefilters resolve undeclared workspaces and install scripts still run via the diff'sunchanged-link path), but mark itisUndeclaredWorkspaceLink = trueand treat it as tree-only:#extractOrLinkreturns early for these links, so no symlink is materialized on disk.#cleanOrphanedStoreEntriesexcludes them from the valid set, so any stale self-link from an older npm version is swept on the next install.workspace.children.The only behavior change is that
require('<self-name>')from inside an undeclared workspace without anexportsfield no longer resolves.This matches pnpm and the strict-isolation intent of #9076.
Cross-workspace dep links, declared-workspace root symlinks, and workspace
postinstallexecution are unaffected.References
Fixes #9398
Related to #9076