Skip to content

fix(arborist): load transitive optional deps into linked actual tree#9654

Merged
owlstronaut merged 1 commit into
npm:latestfrom
manzoorwanijk:fix/linked-transitive-optional-actual-tree
Jun 25, 2026
Merged

fix(arborist): load transitive optional deps into linked actual tree#9654
owlstronaut merged 1 commit into
npm:latestfrom
manzoorwanijk:fix/linked-transitive-optional-actual-tree

Conversation

@manzoorwanijk

Copy link
Copy Markdown
Contributor

In continuation of our exploration of using install-strategy=linked in the Gutenberg monorepo, which powers the WordPress Block Editor.

Under install-strategy=linked, an installed transitive optional dependency was missing from the actual tree built by loadActual when scanning the filesystem (forceActual: true), the path npm sbom and npm query use. On disk the dep is correct — extracted in .store and symlinked as a store sibling of its consumer — but npm sbom omitted it (e.g. chokidarfsevents: 14 components vs the hoisted strategy's 15; esbuild@esbuild/darwin-arm64 likewise).

In #findMissingEdges(), the skip condition treated an edge as already resolved when !edge.missing. An unresolved optional edge has no target yet reports missing === false (Edge.error returns null for an optional edge with no target), so it was skipped and the on-disk store sibling was never walked or loaded.

This changes the check to walk any edge whose target is unresolved, including optional ones. The walk only loads a package that actually exists in an ancestor node_modules, so genuinely-uninstalled optionals (impossible platform) stay absent, and behavior is unchanged for required, missing, dummy, and hoisted-ancestor edges. The linked SBOM now matches the hoisted strategy.

References

Fixes #9627

@manzoorwanijk manzoorwanijk changed the title fix(arborist): load installed transitive optional deps into the linked actual tree fix(arborist): load transitive optional deps into linked actual tree Jun 25, 2026
@manzoorwanijk manzoorwanijk marked this pull request as ready for review June 25, 2026 06:01
@manzoorwanijk manzoorwanijk requested review from a team as code owners June 25, 2026 06:01
@owlstronaut owlstronaut merged commit 6a5bf26 into npm:latest Jun 25, 2026
22 of 23 checks passed
@manzoorwanijk manzoorwanijk deleted the fix/linked-transitive-optional-actual-tree branch June 25, 2026 17:40
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Backport to release/v11 created: #9665

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] install-strategy=linked: Installed transitive optional dependency is not materialized in the actual tree with install-strategy=linked

2 participants