fix #3466: include bundledDependencies in workspace npm pack#9689
Open
Amilliox wants to merge 1 commit into
Open
fix #3466: include bundledDependencies in workspace npm pack#9689Amilliox wants to merge 1 commit into
Amilliox wants to merge 1 commit into
Conversation
1 task
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.
The Problem
npm pack -w <workspace>omitsbundledDependenciesfrom the tarball when those dependencies are hoisted to the rootnode_modules.Root Cause
When packing a workspace directory, pacotes DirFetcher loads an Arborist tree from the workspace path. Arborist cannot resolve hoisted bundled dependencies (edge.to === null), so npm-packlists gatherBundles skips them. Even if the edge were resolved, the relative path from workspace to a hoisted dep goes up (../../node_modules/...), producing invalid tarball entries.
The Fix
Before creating the tarball, libnpmpack creates temporary symlinks inside the workspaces node_modules for each bundled dependency, pointing to the hoisted location:
workspace/node_modules/ -> ../../node_modules/
This makes Arborist resolve the edges naturally and generates correct tarball paths (package/node_modules//file). Symlinks are cleaned up after packing.
Verification
Fixes #3466