-
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
Transitive wildcard dependencies should use existing versions if possible #4136
Comments
Actually seems like a regression from #1158 Yarn version: 0.27.5 |
Upon further investigation, seems like a bug in the package resolver and how it handles "*". If I manually set https://github.com/yarnpkg/yarn/blob/master/src/package-request.js#L265 The current behavior seems to be: if two packages have compatible (but possibly different, e.g. ^5.0.1, ^5.0.0) and valid semverRanges, then the resolved version for both (possibly 5.2.3 in my example) should match and the call to "getExactVersionMatch" will work properly. If the versions don't match, or for example, the package is added to an existing yarn.lock file (with version being something like 5.2.1), then the getHighestRangeVersionMatch will search for existing saved versions and resolve the highest one correctly together. In both these scenarios, it seems that it doesn't work for * or ~. Not sure if this is expected |
This is also related to DefinitelyTyped/DefinitelyTyped#18708 |
The current behavior is not a bug. It is "legal" to resolve these two separately and here's what happens: the To get a single one, |
Closing as duplicate of #3951 and tracking a fix in microsoft/types-publisher#366 |
Basically an extension of #2763
When packages declare dependencies using wildcards, existing version should be re-used if possible for consistency's sake. For example:
My package.json:
@types/react-redux
depends on"@types/react": "*"
In my
yarn.lock
:In this case, I think @types/react-redux should use 15.6.1 because it's specified by the package.json. For other example, such as dependencies using ^15.6, and package.json using ~15, they should both use 15.6.1.
EDIT: I now realize I can use --flat to force this with the resolutions block, but it seems strange to me that this isn't the default. If packages properly declare their dependencies, it shouldn't matter which version the have installed, so it seems ideal to always use package.json version if possible.
Also, --flat requires you to resolve /all/ dependencies which is just impossible for most repos.
The text was updated successfully, but these errors were encountered: