Repository navigation
fix(pnpm): ignore workspace when listing production dependencies - #606
Merged
Merged
Conversation
floydspace
approved these changes
Nov 26, 2026
floydspace
left a comment
Owner
There was a problem hiding this comment.
Approving. Tested against #590.
Reproduction (pnpm 11.8.0, plugin built from master, 40-package workspace)
pnpm ls --prod --jsonfrom.esbuild/.buildreturns every workspace package (42 entries, first entry isroot). With--ignore-workspaceit returns onlysvc.- Through the plugin, with
maxBufferlowered to 20 KB as a proxy for the real 100 MB limit: master fails withMaxBufferError: Command failed: pnpm ls --prod --json / maxBuffer exceeded. With this PR's flag it does not. I did not test a workspace large enough to hit 100 MB. - Besides the oversized output, master reads
JSON.parse(output)[0], which isrooton affected versions, so the wrong package's dependencies can be read.
Affected pnpm versions
- Bug present in 11.0.0 through 11.27.0, fixed in 11.27.1 (release notes: commands run in a project the workspace does not include now act on that project alone).
- Not affected: 9.15.x, 10.x, 11.27.1+, 12.23.0. So this flag only matters for 11.0.0-11.27.0. Upgrading pnpm to 11.27.1+ also resolves #590.
Regression check (pnpm 9.15.4/9.15.9, 10.33.0/10.34.9, 11.x, 12.23.0)
- The flag is accepted on all of them.
- When
.buildhas its ownpackage.json(the only casepack.tsuses, sincegetProdDependenciesis only called whenhasExternalsis true), output is identical with and without the flag. - If
.buildhad no manifest, the flag would return the nearest package without its dependencies. The plugin does not reach that state.
Notes
- The flag can be removed once pnpm 11.0.0-11.27.0 is no longer supported.
- The new tests only assert the argument list, which is acceptable for a one-line change.
- Separate from this PR: inside a workspace,
pnpm installin.esbuild/.buildattaches to the workspace ("Scope: all N workspace projects") and installs nothing, so externals are dropped from the zip. This happens with or without this PR and should be tracked as its own issue.
|
🎉 This PR is included in version 1.59.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Fixes #590
Root cause
In pnpm 11, running
pnpm ls --prod --jsonfrom a subdirectory inside a pnpm workspace without its own manifest (such as.esbuild/.buildwhen no temporarypackage.jsonis generated) becomes workspace-recursive and outputs dependency graphs for every workspace package. In large monorepos, this output can exceed Execa's defaultmaxBufferlimit.Changes
src/packagers/pnpm.ts: Pass--ignore-workspacebeforelsinPnpm.getProdDependencies()so pnpm lists only the single nearest package (matching pre-pnpm-11 behavior when.esbuild/.build/package.jsonis present or absent, as well as in standalone non-workspace projects).src/tests/packagers/pnpm.test.ts: Added unit tests verifyingPnpm.getProdDependencies()invokespnpmwith--ignore-workspace(with and withoutdepth) and returns the first parsed dependency entry.Verification
src/tests/packagers/pnpm.test.tsfail without the fix and pass with it (pnpm run test:unit src/tests/packagers/pnpm.test.ts).pnpm --ignore-workspace ls --prod --jsonreturns only the single target package in both.esbuild/.buildwith and without apackage.json, as well as in a standalone project.pnpm run lint(eslint .andtsc --noEmit && tsc -p tsconfig.examples.json) passes.pnpm exec tsc -p ./tsconfig.build.jsonpasses.