fix: skip isolated tree for workspace-filtered installs with linked strategy#9040
Open
manzoorwanijk wants to merge 2 commits intonpm:latestfrom
Open
fix: skip isolated tree for workspace-filtered installs with linked strategy#9040manzoorwanijk wants to merge 2 commits intonpm:latestfrom
manzoorwanijk wants to merge 2 commits intonpm:latestfrom
Conversation
…trategy The isolated tree built by _createIsolatedTree() uses plain objects with Array children and a stub inventory.query(), which are incompatible with workspace filtering in _diffTrees() and the post-reify re-rooting logic. Skip the isolated tree swap when --workspace is specified and fall back to the normal reify path.
Packages with link: specs in their dependencies (e.g. link:.) cause npa to throw EUNSUPPORTEDPROTOCOL when isRegistryDependency is accessed during lockfile save. Catch the error and treat unsupported spec types as non-registry dependencies.
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, this is a follow-up of the fixes from #8996.npm install --workspacecrashes with aTypeErrorwheninstall-strategy=linkedis configured.The isolated tree built by
_createIsolatedTree()is structurally incompatible with workspace-filtered installs:root.childrenis an Array, not a Map — workspace filtering calls.get(ws)which doesn't exist on Arrayinventory.query()is a stub returning[]— theset rootsetter can't resolve Link targets during post-reify re-rootingfilterSetcomputed against the isolated tree becomes invalid after the tree is swapped back to the originalnpm 11.x throws:
npm 10.x throws:
This PR:
Skips
_createIsolatedTree()when--workspaceis active, falling back to the normal reify path with real Node/Link instances. A subsequent fullnpm installrestructures everything back to linked layout. The isolated tree was designed for fullnpm install, not filtered installs.Handles unsupported spec types in
isRegistryDependency— packages withlink:specs in their dependencies (e.g.link:.) causenpato throwEUNSUPPORTEDPROTOCOLwhenisRegistryDependencyis accessed during lockfile save. The fix catches the error and treats unsupported spec types as non-registry dependencies.References
Fixes #9038