Repository navigation
fix(deploy): prevent extra directories when using relative deploy path - #11006
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a pnpm deploy regression where deploying to a relative (nested) target path could cause extra directories to be created inside the deploy target and/or inside other workspace projects, particularly with node-linker=hoisted.
Changes:
- Add a regression test ensuring
pnpm deploydoesn’t create unintended nested directories when deploying to a nested relative path. - Update deploy implementation to align workspace projects’
modulesDirresolution with the deploy target’snode_modules. - Add a changeset to publish the fix as a patch.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| releasing/commands/test/deploy/deploy.test.ts | Adds regression coverage for unintended directory creation during deploy with hoisted linker. |
| releasing/commands/src/deploy/deploy.ts | Adjusts workspace project modulesDir handling to avoid incorrect path joining that creates extraneous directories. |
| .changeset/fix-deploy-extra-directories.md | Declares patch releases for the deploy fix. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
themavik
left a comment
There was a problem hiding this comment.
Summary: Fixes pnpm deploy creating extra directories (e.g. project-2/foo/node_modules) when using a relative deploy path in workspaces.
Done well: Root cause is clear: only deployedProject had modulesDir set; non-deployed projects fell back to incorrect relative path. Fix correctly sets modulesDir for ALL workspace projects to path.relative(project.rootDir, deployNodeModules). The inline comment explains why this is needed. Regression test with multi-project workspace (project-1 depends on project-2) and deploy to some/nested/path verifies no extra dirs in deploy target or other projects.
Minor: The test asserts fs.existsSync(project-1/some) and project-2/some are falsy. Good coverage. Consider also asserting root/some is falsy if root is in allProjects, though the current test may already cover that implicitly.
In the legacy deploy path, only the deployed project's modulesDir was set to point to the deploy directory's node_modules. Other workspace projects fell back to the relative modulesDir from opts, which was incorrectly joined with each project's rootDir in read-projects-context, creating extraneous directories (e.g., project-2/foo/node_modules when deploying to ./foo) and corrupting the project's own node_modules. Now all workspace projects in allProjects get their modulesDir set to point to the deploy directory's node_modules, preventing any stray directory creation. Closes pnpm#10981 Co-Authored-By: Claude Opus 4.6 <[email protected]>
4a2544d to
3704e7e
Compare
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: pnpm/pnpm/.coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe deploy handler now updates module-directory paths for every workspace project. A regression test covers a hoisted-linker deployment to a nested relative path and checks for extra directories. A changeset requests patch releases for ChangesDeploy target path handling
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Assessment against linked issues
Suggested labels: Merge Risk: ⚪ Minimal · up to Workspace projects are directed to the deploy target during relative-path deployment, and the regression test checks for duplicated directories. No actionable merge risk remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
pnpm11/releasing/commands/src/deploy/deploy.tsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. pnpm11/releasing/commands/test/deploy/deploy.test.tsESLint skipped: the matched ESLint configuration already failed (missing-dependency). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
zkochan
left a comment
There was a problem hiding this comment.
LGTM! Rebased cleanly onto main, updated paths for pnpm11 monorepo layout, verified test suite passes and review threads are resolved.
Reviewed by Antigravity (gemini-2.5-pro).
Code Review by Qodo
1. A changeset link breaks colon style
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |


Summary
Fixes #10981
pnpm deploywith a relative path (e.g.,pnpm --filter=my-pkg deploy ./foo) creates extraneous nested directories inside the deploy target (foo/foo/...) and corrupts workspace projects'node_modules. This happens in the legacy deploy path (used when shared lockfile is unavailable ornode-linker=hoistedwithout pre-existing lockfile).Root Cause
In the legacy deploy path (
deploy.ts), only the deployed project'smodulesDirwas updated to point to the deploy directory'snode_modules(line 135):The
modulesDiroption passed toinstall.handler(line 193) was a relative path fromworkspaceDir:In
read-projects-context, this relativemodulesDiris used as a fallback for all workspace projects that don't have an explicitmodulesDir:For non-deployed projects, this produced wrong paths like
project-2/foo/node_modulesinstead offoo/node_modules, creating extra directories inside workspace projects and inside the deploy target.Fix
Set
modulesDirfor all workspace projects inallProjectsto point to the deploy directory'snode_modules, not just the deployed project:This ensures that no matter which code path is taken downstream, all
modulesDirreferences resolve to the deploy directory.Test plan
node-linker=hoistedto a nested relative path (some/nested/path) verifies no extra directories are created inside deploy target or workspace projectsSummary by CodeRabbit
pnpm deploywith a relative destination path creating unexpected extra directories in the deploy destination and workspace projects.