fix(js): include workspace member node_modules in install sandbox#23342
Open
jcrobak wants to merge 1 commit into
Open
fix(js): include workspace member node_modules in install sandbox#23342jcrobak wants to merge 1 commit into
jcrobak wants to merge 1 commit into
Conversation
Fixes JavaScript workspace builds where dependencies are installed under members' node_modules/. The install sandbox now captures every workspace member's node_modules/, not just the build target's. This fixes pnpm workspaces in pants and also fixes npm/yarn workspaces when a version conflict prevented hoisting. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Problem
In a nodejs workspace, each project of the workspace can have its own
node_modulesdirectory that is populated during installation. Previously, pants was capturing the project's workspace and the top-level workspace but not sibling or descendent projects. This caused certain operations to fail, such astsc --buildon a pnpm workspace project since a pnpm project doesn't hoist member deps to the root by default. Outside of pnpm, there are reports of this causing problems with yarn/npm projects where a version conflict prevents hoisting.Solution
In
node_modules_directories, the install sandbox now captures every workspace member'snode_modules/, not just the build target's.Note: the new behavior only impacts the install path ( when
self.packageis set). Lockfile generation's codepath (viaNodeJsProjectEnvironment.from_root()) doesn't setself.packageand keeps the "root only" behavior. Dropping theif self.packagecheck would align with the approach from #23264, but I left out that change to minimize the scope. I added a test to demonstrate this behavior.References
node_modulesdetection #23264AI Disclosure
Claude Code was used to diagnose the problem, write the fix with my input, and write
the regression tests