Yarn: Not deduping child dependencies

Created on 16 Jan 2018  ยท  7Comments  ยท  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
bug

What is the current behavior?
yarn install does not dedupe child dependencies:

yarn list --pattern recompose

yarn list v1.3.2
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ @scope/[email protected]
โ”‚  โ””โ”€ [email protected]
โ””โ”€ [email protected]

Each one of these recompose dependencies are separate files.

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior?
Each of these should be deduped into a root shared dependency.

Please mention your node.js, yarn and operating system version.
yarn 1.3.2
node 8.4.0
linux

triaged

All 7 comments

@jshthornton You have not specified which version ranges the different modules will accept.
I notice that there is a version 0.26.0 and I suspect that your sub modules require ^0.25.0 meaning that the versions are incompatible and therefore each module has its own installed version.

However I do have this problem where the version ranges should be compatible

โ”œโ”€ @mediatool/[email protected]
โ”‚  โ””โ”€ @mediatool/[email protected]
โ”œโ”€ @mediatool/[email protected]
โ”‚  โ””โ”€ @mediatool/[email protected]
โ”œโ”€ @mediatool/[email protected]
โ”‚  โ””โ”€ @mediatool/[email protected]
โ”œโ”€ @mediatool/[email protected]
โ”‚  โ””โ”€ @mediatool/[email protected]
โ”œโ”€ @mediatool/[email protected]
โ”‚  โ””โ”€ @mediatool/[email protected]
โ”œโ”€ @mediatool/[email protected]
โ”‚  โ””โ”€ @mediatool/[email protected]
โ””โ”€ @mediatool/[email protected]

Note that each module has a version of @mediatool/mt-rest-server even though each module has specified the version range ^1.0.0 except for the module where the listing is done, there the version is ^1.0.1

Note that if I remove my yarn.lock file and run yarn then I get the desired behavior. But not in my case which was that from the start, every module had specified version ^1.0.0 and then the main module in my post above upgraded the version.

If I run yarn upgrade then deduplication is performed. But all other packages are also upgraded.

I would have expected that if I run yarn upgrade [packageName] then that package is upgraded and deduplicated. Am I wrong to expect this?

@TheLudd same problem with yours. And it breaks my project, since it's installing multiple "react" packages, and "react" allows only one instance.

I have to manually fix yarn.lock almost every time when I add a new dependency that depends on "react".... It's terrible, forcing me to create a new package yarn-dedupe to solve this problem.

I think it should be done by yarn itself.

@adventure-yunfei
Thanks for the info. Can you, or anyone else, confirm that the current behavior of yarn is intended and will not be changed?

yep, dedupe is borked.

here's a short, simple example to grok:

i have two packages that allow for a common dep, but do not use a common dep. this breaks runtime type checking (e.g. instanceof checks).

"graphql@>= 0.10 <1.0.0":
  version "0.13.2"
  resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.13.2.tgz#4c740ae3c222823e7004096f832e7b93b2108270"
  dependencies:
    iterall "^1.2.1"

"graphql@>=0.6 <0.13":
  version "0.12.3"
  resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.12.3.tgz#11668458bbe28261c0dcb6e265f515ba79f6ce07"
  dependencies:
    iterall "1.1.3"

in ^ example, 0.12.3 would have been fine for both, and 0.13.2 should not be present.

to replicate on [email protected], simply install "postgraphile": "^4.0.0-rc.1" and "@gql2ts/from-schema": "^1.8.0", and blamo, non-depuped.

i'm on OSX.

same occurs on [email protected]

Was this page helpful?
0 / 5 - 0 ratings