-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Yarn unnecessarily splitting dependencies #4125
Comments
Hey there! We need a concrete, reproducible scenario so we can investigate the issue and hopefully fix it. Would you mind providing us a sample |
Sure, I was able to simplifiy it down to two dependencies. {
"engines": {
"node": "8.1.4"
},
"dependencies": {
"jquery": "^1.12.4",
"jquery-ujs": "^1.2.2"
}
} Which for me produces the following # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
jquery-ujs@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/jquery-ujs/-/jquery-ujs-1.2.2.tgz#6a8ef1020e6b6dda385b90a4bddc128c21c56397"
dependencies:
jquery ">=1.8.0"
jquery@>=1.8.0:
version "3.2.1"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.2.1.tgz#5c4d9de652af6cd0a770154a631bba12b015c787"
jquery@^1.12.4:
version "1.12.4"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-1.12.4.tgz#01e1dfba290fe73deba77ceeacb0f9ba2fec9e0c" |
@mockdeep this is because |
You can find a similar discussion with reference to some others here: #3951 |
@BYK I've read over the comments there but I'm still not quite understanding the rationale for this change in behavior. There are quite a few dependencies in our yarn add [email protected] This ends up installing 2 versions of |
I can definitely relate to this and trust me when I say, our aim is to make this a reality when possible. That said there may be situations that it may not be possible to hoist everything up. And we also have some things that we can improve around common version/range resolutions. But from a purely spec-related perspective, what Yarn does is correct. The reason you are running into problems is either your project or its dependencies are relying on unspecified hoisting mechanics which are not guaranteed to exist. The correct way to ensure consistent and shared dependencies across projects is using In the meantime, we will try to make the hoister and resolver better to avoid duplicates but as stated above, this is not something projects can rely on. Neither for |
As suggested in yarnpkg/yarn#4125
Do you want to request a feature or report a bug?
This looks like a bug in version
0.27.5
. It works as expected on version0.24.6
.What is the current behavior?
When I run
yarn upgrade
, yarn splits out dependencies unnecessarily, causing multiple versions to be installed. The version specifications are the same as they were before, but result in two or more dependency versions instead of a single resolved version. Here's a diff from ouryarn.lock
:The JQuery version requirements did not change, and version
1.12.4
satisfies all of them, but for some reason yarn decided to add an additional copy of JQuery to satisfy transitive dependencies.What is the expected behavior?
Yarn should find a single version to satisfy dependencies where possible.
Please mention your node.js, yarn and operating system version.
Node: 8.1.4
Yarn: 0.27.5
Operating system: reproducible on both MacOS and Linux
The text was updated successfully, but these errors were encountered: