fix(arborist): drop self-link materialization for undeclared workspaces#9418
Merged
Conversation
…es (#9399) In continuation of our exploration of using `install-strategy=linked` in the [Gutenberg monorepo](WordPress/gutenberg#75814), which powers the WordPress Block Editor. ## Summary In `install-strategy=linked`, every workspace not listed in the root `package.json`'s deps was getting a self-symlink inside its own `node_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 `IsolatedLink` off-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](https://nodejs.org/api/packages.html#self-referencing-a-package-using-its-name). ## Fix Keep the workspace `IsolatedLink` in the tree (so `--workspace` filters resolve undeclared workspaces and install scripts still run via the diff's `unchanged`-link path), but mark it `isUndeclaredWorkspaceLink = true` and treat it as tree-only: - `#extractOrLink` returns early for these links, so no symlink is materialized on disk. - `#cleanOrphanedStoreEntries` excludes them from the valid set, so any stale self-link from an older npm version is swept on the next install. - The link is no longer added to `workspace.children`. The only behavior change is that `require('<self-name>')` from inside an undeclared workspace without an `exports` field no longer resolves. This matches pnpm and the strict-isolation intent of #9076. Cross-workspace dep links, declared-workspace root symlinks, and workspace `postinstall` execution are unaffected. ## References Fixes #9398 Related to #9076 (cherry picked from commit dac7ff6)
owlstronaut
approved these changes
May 27, 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.
Backport of #9399 to
release/v11.