-
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 1.1.0 optimizeResolutions fails if package pattern has || in the range #4547
Labels
Comments
Actually, looks like we can manually craft a range that satisfies our needs: https://github.com/npm/node-semver/blob/master/semver.js#L768 |
I have a PR cooking for this. |
BYK
added a commit
that referenced
this issue
Sep 27, 2017
joaolucasl
pushed a commit
to joaolucasl/yarn
that referenced
this issue
Oct 27, 2017
…ns (yarnpkg#4562) **Summary** Fixes yarnpkg#4547 by testing each version against all ranges individually, rather than munging the patterns together to get a single range. **Test plan** Existing tests, plus a regression test to repro yarnpkg#4547: "manifest optimization respects versions with alternation"
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commit 4020ccd introduced a feature that still exists in the current version:
There is a bug with this feature. If a dependency has a || in its semver range, the code incorrectly resolves to a version that in reality really doesn't satisfy all version ranges.
For example I had the following lodash versions:
And the available versions were
'4.17.4', '3.5.0', '2.4.2', '3.10.1'
The code generates a
combinedRange
:^4.11.1 ~3.5.0 2.4.2 ^3.0.1 || ^2.0.0
And this combined range incorrectly resolves to a single version:
2.4.2
.The root of the issue is that semver apparently evaluates that expression as:
( ^4.11.1 ~3.5.0 2.4.2 ^3.0.1 ) || ^2.0.0
although the intention of the code is to evaluate it as^4.11.1 ~3.5.0 2.4.2 ( ^3.0.1 || ^2.0.0 )
It seems that there is no way to group the OR in the latter manner, hence as a fix the patterns with OR could simply be excluded from the optimization. Here's a patch that fixes the issue:
Tested on latest LTS version of node (v6.11.3).
The text was updated successfully, but these errors were encountered: