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"
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.