fix: resolve relative file: dependencies correctly with install-strategy=linked#9030
Open
manzoorwanijk wants to merge 1 commit intonpm:latestfrom
Open
fix: resolve relative file: dependencies correctly with install-strategy=linked#9030manzoorwanijk wants to merge 1 commit intonpm:latestfrom
manzoorwanijk wants to merge 1 commit intonpm:latestfrom
Conversation
…tegy Local file: dependencies were incorrectly classified as external in the isolated reifier, routing them through store extraction instead of symlinking directly. This caused the relative path to resolve from the wrong directory, producing ENOENT errors. Treat file dep targets found in fsChildren as local dependencies, alongside workspaces, so they get symlinked directly.
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.When using
install-strategy=linked, relativefile:dependencies (e.g.,file:./project2) fail with ENOENT because the path is resolved one level above the project root. For example,file:./project2becomesfile:../project2, causing npm to look for/Users/dan/Source/project2instead of/Users/dan/Source/project1/project2.In the isolated reifier, non-workspace
file:dependencies are incorrectly classified as "external" dependencies. This routes them through the store extraction path (pacote.extract) instead of symlinking them directly like workspaces. A Link node'sresolvedvalue is relative to itsnode_modules/location — that relative path becomes invalid when used from the store context.This PR treats local
file:dep targets found infsChildrenas local dependencies (alongside workspaces) so they get symlinked directly instead of extracted into the store:_makeIdealGraph: Skip nodes fromroot.externalif they (or their Link target) are inidealTree.fsChildren.assignCommonProperties: Classify deps whose targets are innode.fsChildrenas local dependencies instead of external.References
Fixes #7549