Skip to content

Conversation

@lydell
Copy link
Contributor

@lydell lydell commented Mar 16, 2024

Beta versions currently have suffixes like -beta1, -beta2, -beta3 etc. That works fine until we reach -beta10. Unfortunately, the 10 in there is not treated numerically, so according to npm’s semver -beta2 is “higher” than -beta10. Numbers only seem to be treated numerically when preceded by a ..

This is problematic because:

  • ^1.1.0-beta1 happens to work as expected.
  • ^1.1.0-beta2 on the other hand matches 1.1.0-beta2 to 1.1.0-beta9 and then 1.1.0-beta20, but not 1.1.0-beta10 to 1.1.0-beta19.

You can play around with the above at https://semver.npmjs.com/.

In this example, I want -1 all the time, but it fails when going from 9 to 10:

> require("semver").compare("1.0.0-beta8", "1.0.0-beta9")
-1

> require("semver").compare("1.0.0-beta9", "1.0.0-beta10")
1 // 🚨 !!!

> require("semver").compare("1.0.0-beta10", "1.0.0-beta11")
-1

But with a dot it works:

> require("semver").compare("1.0.0-beta.8", "1.0.0-beta.9")
-1

> require("semver").compare("1.0.0-beta.9", "1.0.0-beta.10")
-1

> require("semver").compare("1.0.0-beta.10", "1.0.0-beta.11")
-1

Unfortunately, 1.1.0-beta.13 is considered lower than 1.1.0-beta12, so I recommend waiting with merging this until you have released the next stable version.

> require("semver").compare("1.1.0-beta.13", "1.1.0-beta12")
-1

@deepak1556 deepak1556 requested a review from Tyriar March 18, 2024 04:22
@deepak1556 deepak1556 added this to the 1.1.0 milestone Mar 18, 2024
@lydell
Copy link
Contributor Author

lydell commented Dec 21, 2025

Since v1.1.0 (not beta) was released (#843), now is a good time to look at this! (Before we reach 10 beta versions again.)

@Tyriar
Copy link
Member

Tyriar commented Dec 21, 2025

@lydell good call, will check out soon!

@Tyriar Tyriar modified the milestones: 1.1.0, 1.2.0 Dec 21, 2025
Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @lydell!

@Tyriar Tyriar enabled auto-merge December 22, 2025 14:00
@Tyriar Tyriar self-assigned this Dec 22, 2025
@Tyriar Tyriar merged commit fb4ae52 into microsoft:main Dec 22, 2025
5 checks passed
@lydell lydell deleted the fix-beta-versioning branch December 22, 2025 17:09
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.

4 participants