Skip to content

fix(query): report logical dep location under linked strategy#9664

Merged
owlstronaut merged 1 commit into
release/v11from
backport/v11/9656
Jun 25, 2026
Merged

fix(query): report logical dep location under linked strategy#9664
owlstronaut merged 1 commit into
release/v11from
backport/v11/9656

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Backport of #9656 to release/v11.

In continuation of our exploration of using `install-strategy=linked` in
the [Gutenberg
monorepo](WordPress/gutenberg#75814), which
powers the WordPress Block Editor.

Under `install-strategy=linked`, `npm query ':root > *'` reported a
direct dependency at its `node_modules/.store/<key>/node_modules/<pkg>`
backing path instead of the logical `node_modules/<pkg>` location,
diverging from the hoisted strategy.

There are two root causes.
In `hasParent` (query-selector-all.js), a store-backing node is `isTop`,
has `resolveParent === root`, and has a top-level symlink whose parent
is root, so it matched as a direct child of root through the `linksIn`
logical-parent block that exists for workspaces.
This returned the store node alongside its logical `Link`.
In the `query` command, `QuerySelectorItem` read `node.target.location`,
which for a linked dep resolves to the store node.

The fix skips store-backing nodes in the `linksIn` parent check, so a
store node is reached only through its logical `Link` (matched via the
`edgesIn` branch) rather than as a direct child of root.
The `query` command now reports the node's own logical `location`/`path`
when the target is in the store, while workspaces and regular nodes keep
the target location (for example `packages/<ws>`).
Deduplication now keys on the target's physical location and ranks
competing representations of the same package, so a top-level placement
wins over the canonical store node, which wins over an internal store
symlink.
This keeps direct deps logical and transitive deps at their canonical
store key for selectors such as `:root *`, and leaves the hoisted
strategy unchanged.

## References

Fixes #9617

(cherry picked from commit 803ba70)
@owlstronaut owlstronaut merged commit 8f13beb into release/v11 Jun 25, 2026
50 checks passed
@owlstronaut owlstronaut deleted the backport/v11/9656 branch June 25, 2026 17:58
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