Skip to content

fix(arborist): drop self-link materialization for undeclared workspaces#9418

Merged
owlstronaut merged 1 commit into
release/v11from
backport/v11/9399
May 27, 2026
Merged

fix(arborist): drop self-link materialization for undeclared workspaces#9418
owlstronaut merged 1 commit into
release/v11from
backport/v11/9399

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

Backport of #9399 to release/v11.

…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 owlstronaut merged commit d8a7803 into release/v11 May 27, 2026
35 checks passed
@owlstronaut owlstronaut deleted the backport/v11/9399 branch May 27, 2026 16:51
@github-actions github-actions Bot mentioned this pull request May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants