fix: support for sorting dependenciesMeta in Yarn berry #323
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.
A PR for fixing #301
This implementation follows the sorting of yarn.
In Yarn berry, the dependenciesMeta field can also contain a range (
"package-name@1.2.3"
).The Yarn source code only uses the identifier when sorting dependencyMeta. This is different from the current implementation of this package. Each time when running Yarn, this will result in a conflict. This fix will bring the sorting in line with that of Yarn.
The current implementation sorts on the whole name including the range. Therefore, in the example below,
"bats-assert@2.0.0"
comes before"bats@1.10.0"
(because-
comes before@
)In this implementation, the range will be stripped from the name before sorting. Therefore, it will sort like yarn:
"bats"
comes before"bats-assert"
current sort-package-json implementation:
yarn:
The sorting stays the same for dependenciesMeta that do not have a range in their name.
I also checked if peerDependenciesMeta should have the same fix, however a range is not supported there in Yarn Berry.