Replies: 2 comments 1 reply
|
This is not a bug at the moment. This is a choice. Changing how this works is a design question. |
|
Workaround that worked for us (AdonisJS monorepo, pnpm 12.8.2) Same shape of problem: The 12.8 fix from #15344 did not apply because the skip rule requires every importer that reaches the package to list the peer, and our workspace modules depend on Removal overrides (#15008) solved it at the source, one line per overrides:
'@adonisjs/core>@adonisjs/assembler': '-'
'@adonisjs/auth>@japa/api-client': '-'
# ... one per AdonisJS package that declares the peerThe prod closure dropped from 738 to 615 packages for one app and 673 to 524 for the other, with no tooling left. Dev kept working because core imports assembler via |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Verify latest release
pnpm version
12.9.1;11.28.3
Which area(s) of pnpm are affected? (leave empty if unsure)
Dependencies resolver
Link to the code that reproduces this issue or a replay of the bug
https://github.com/SF97/pnpm-dedupe-peer-repro
Reproduction steps
Reproduction repository: https://github.com/SF97/pnpm-dedupe-peer-repro
Use pnpm 12.9.1, pinned in the repo. The same behavior was also verified with 11.28.3.
Clone the reproduction repository and enter it:
git clone https://github.com/SF97/pnpm-dedupe-peer-repro.git cd pnpm-dedupe-peer-reproFollow README step 1, including resetting
pnpm-workspace.yamlto the default settings before the clean install. The checked-in configuration disables both settings, so this reset is required to reproduce the behavior.Run
pnpm --filter app why --prod node-forge. Althoughappdeclares onlywebpack, the production graph includes:Follow README step 4 to disable only
dedupePeerDependents, then reinstall from scratch and run the same app-filtered command. The chain still appears.Follow README step 5 to disable both
autoInstallPeersanddedupePeerDependents, then reinstall from scratch. The command now produces no output.node-forgeremains only intooling's development graph.Follow README step 5 to disable both
autoInstallPeersanddedupePeerDependents, then reinstall from scratch. The command now produces no output.node-forgeremains only intooling's development graph.The README includes all five control configurations. On both tested pnpm versions, defaults and either setting disabled alone expose the chain; excluding
toolingor disabling both settings removes it fromapp's production graph.Describe the Bug
Adding an unrelated workspace package with Webpack CLI/dev-server in its
devDependencieschanges another package's production dependency graph.appdeclares onlywebpack, but its resolved Webpack instance gains the optionalwebpack-clipeer, exposingwebpack-dev-server,selfsigned, andnode-forgeunder--prod.This occurs on pnpm 11.28.3 and 12.9.1, including when
dedupePeerDependents: false. Disabling bothautoInstallPeersanddedupePeerDependents, or excluding the unrelated tooling package, removes that chain fromappwithout changing its manifest.I understand that
dedupePeerDependentscan share instances with optional peers. However, here the peer is supplied only by an unrelated workspace package'sdevDependencies, yet its dependency chain becomes reachable fromappunder--prod. This also occurs withdedupePeerDependents: false. This production/development boundary crossing doesn't make sense to me.Expected Behavior
Including or excluding an unrelated workspace package's development tooling should not change
app's production dependency closure. I would expectnode-forgeto remain reachable only throughtooling's development dependencies, andpnpm --filter app why --prod node-forgeto produce no output, with any of the configuration combinations provided.Which Node.js version are you using?
24.21.0
Which operating systems have you used?
If your OS is a Linux based, which one it is? (Include the version if relevant)
Ubuntu
Contributing a fix
All reactions