Skip to content
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

fix: version deduping #76

Merged
merged 2 commits into from
Nov 8, 2021
Merged

fix: version deduping #76

merged 2 commits into from
Nov 8, 2021

Conversation

guybedford
Copy link
Member

This fixes the version deduping algorithm to ensure that in an application with two packages, one depending on react: '16 || 17' and another depending on react: '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 when react: 16 is hit, we check all other packages using react and down grade them if the ranges accept that, allowing react: 16 to be used.
B) If react: 16 is installed first, we install that version. Then when react: 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 the react: 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!

@guybedford guybedford merged commit 5ddc802 into main Nov 8, 2021
@guybedford guybedford deleted the deduping branch November 8, 2021 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant