Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the version deduping algorithm to ensure that in an application with two packages, one depending on
react: '16 || 17'
and another depending onreact: '16'
that you end up with one version of React at 16, instead of two separate versions of React.This is achieved with a greedy resolution algorithm, by:
A) If
react: 16 || 17
is installed first, we install the highest version at 17. Then whenreact: 16
is hit, we check all other packages using react and down grade them if the ranges accept that, allowingreact: 16
to be used.B) If
react: 16
is installed first, we install that version. Then whenreact: 16 || 17
is hit, we try install react 17 by upgrading all usages of react to this version, we then find out that we can't upgrade thereact: 16
range, so we cancel the 17 upgrade and stick with 16 instead.That's the core of the "JSPM greedy version constraint solver". Take that, NP complete!