Skip to content

fix: compare prerelease versions against previous stable for size diff#2324

Open
joshuaisaact wants to merge 1 commit intonpmx-dev:mainfrom
joshuaisaact:fix/prerelease-size-comparison
Open

fix: compare prerelease versions against previous stable for size diff#2324
joshuaisaact wants to merge 1 commit intonpmx-dev:mainfrom
joshuaisaact:fix/prerelease-size-comparison

Conversation

@joshuaisaact
Copy link
Copy Markdown

@joshuaisaact joshuaisaact commented Mar 30, 2026

🔗 Linked issue

Resolves #2313

🧭 Context

When viewing an old prerelease version (e.g. oxlint@1.17.0-alpha.0), it compared against the latest version (in oxlint's case this was 1.57.0), not the stable version before the prerelease.

Since the latest version is newer and smaller, this showed a "size increase" warning on the old alpha. The package size of oxlint has decreased in newer versions, but we shouldn't say that the old alpha has 'increased'.

We should be comparing the old alpha against the closest previous stable.

📚 Description

I changed the prerelease comparison logic in getComparisonVersion to find the previous stable version in semver order, the same approach already used for stable versions.

The old code used the latest dist-tag as a shortcut, which broke when viewing prereleases older than latest.

The old prerelease behavior was:

  1. Look up latest dist-tag
  2. If no latest or prerelease IS latest, return null
  3. Otherwise compare against latest

The new behavior is:

Find the highest stable version before this prerelease, in semver order.

Which matches the non-alpha behaviour, removing the (bugged) shortcut.

Also updated the tests while I was there, because I am nice.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 30, 2026 6:00am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 30, 2026 6:00am
npmx-lunaria Ignored Ignored Mar 30, 2026 6:00am

Request Review

@github-actions
Copy link
Copy Markdown

Hello! Thank you for opening your first PR to npmx, @joshuaisaact! 🚀

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

📝 Walkthrough

Walkthrough

The changes update the prerelease version comparison logic in getComparisonVersion. Previously, when dealing with a prerelease version, the function returned the packument's dist-tags.latest tag value. The updated implementation now constructs a filtered, semver-sorted list of stable versions and returns the highest stable version with a lower version number than the prerelease. Non-prerelease version handling remains unchanged. Corresponding test cases were updated to reflect this new prerelease comparison behaviour.

Possibly related PRs

Suggested reviewers

  • ghostdevv
  • danielroe
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to and explains the changeset, detailing the bug fix for prerelease version comparison logic and the rationale for the changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

"Size increase" warning shows up incorrectly for alpha versions that are older and smaller than the latest release

1 participant