pnpm: Deduping algorithm not working properly
pnpm version: 2.0.0 (and earlier)
Code to reproduce the issue: https://github.com/nickpape-msft/react-pnpm-repro
Expected behavior:
The package react-dom-16-bundle
gets @types/react@16
& @types/react-dom@16
.
The package @types/react-dom@16
gets @types/react@16
, since the parent dependency (react-dom-16-bundle used 16, and react-dom has a *
dependency).
Actual behavior:
The package react-dom-16-bundle
gets @types/react@16
& @types/react-dom@16
.
The package @types/react-dom@16
gets @types/react@15
.
It seems that the deduping algorithm from #952 is not working as intended.
Additional information:
node -v
prints: 8.9.4- Windows, OS X, or Linux?: Windows
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 31 (21 by maintainers)
Commits related to this issue
- Update package.json fix for https://github.com/pnpm/pnpm/issues/1187 — committed to zkochan/react-pnpm-repro by zkochan 6 years ago
- refactor: @pnpm/resolve-dependencies ref #1187 — committed to pnpm/pnpm by zkochan 5 years ago
- feat: support resolution strategies resolution-strategy fast is the default fewer-dependencies makes pnpm prefer package versions that were already resolved hight in the dependency graph close #1187 — committed to pnpm/pnpm by zkochan 5 years ago
- feat: support resolution strategies PR #1739 * feat: support resolution strategies resolution-strategy fast is the default fewer-dependencies makes pnpm prefer package versions that were alre... — committed to pnpm/pnpm by zkochan 5 years ago
Looks good!
I was able to reproduce @nickpape-msft 's issue using his example repro above. (The behavior has changed slightly since
@types/react-dom
now specifies its dependency as"@types/react": "^15"
instead of"@types/react": "*"
, so the side-by-side versions are both from React 15.x. But the same effective problem is still there.)Then I installed using
--resolution-strategy fewer-dependencies
, and confirmed that with this option, only one version of@types/react
gets installed. Hurray!We will need to try this out in some production monorepos. But if it works as expected, I’m thinking we will change Rush to enable
--resolution-strategy fewer-dependencies
by default when PNPM is the package manager. I expect that it will eliminate a lot of confusion for people.🚢 3.1.0-0
config name:
resolution-strategy
. Possible values:fast
(the default),fewer-dependencies
ok, if this is so important, I’ll work on a flag