Skip to content

Do not bump ignored independent packages when exiting pre mode - #2092

Merged
Andarist merged 8 commits into
changesets:mainfrom
chatman-media:fix/exit-pre-mode-ignored-independent-packages
Aug 10, 2026
Merged

Andarist merged 8 commits into
changesets:mainfrom
chatman-media:fix/exit-pre-mode-ignored-independent-packages

Conversation

@chatman-media

Copy link
Copy Markdown
Contributor

Problem

When exiting pre mode, assembleReleasePlan gives a patch bump to any package whose recorded pre-version isn't 0 (i.e. it had a prerelease during the pre phase), so that packages that were prereleased but didn't otherwise get a bump still get released. The intent is documented here.

However, this block does not consistently respect the ignore config (and privatePackages.version):

  • For a package that already has a none release in the plan (e.g. an ignored dev dependent), the else if branch correctly checks shouldSkipPackage and skips it.
  • For a package that has no existing release in the plan — e.g. an ignored package that is independent (not a dependent of anything being released) — the if (!existingRelease) branch creates a patch release without checking shouldSkipPackage.

As a result, an ignored, standalone package that happened to have a prerelease version gets bumped on pre exit even though the user explicitly ignored it (and passed e.g. --ignore <pkg>). This matches the report in #1543, where a package that other packages do not depend on is incorrectly version-bumped on pre exit.

Note that ignored packages are intentionally excluded from preInfo.preVersions (in getPreInfo), so preVersions.get(name) returns undefined for them, and undefined !== 0 is true — which is exactly what slips them past the guard.

Fix

Hoist the shouldSkipPackage check to the top of the condition so it guards both the "create new patch release" and the "upgrade existing none → patch" branches, and drop the now-redundant check from the else if. Behavior for non-ignored packages is unchanged.

Tests

Added a test asserting that an ignored, independent package that had a prerelease is not bumped when exiting pre mode (it fails without the fix). The existing "should not bump ignored dev dependents when exiting pre-release mode" test continues to pass, and the full test suite is green.

Closes #1543

@changeset-bot

changeset-bot Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6b940a9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@changesets/config Patch
@changesets/assemble-release-plan Patch
@changesets/apply-release-plan Patch
@changesets/cli Patch
@changesets/get-release-plan Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codecov

codecov Bot commented Jun 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.53%. Comparing base (496ca21) to head (6b940a9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2092      +/-   ##
==========================================
+ Coverage   84.12%   84.53%   +0.41%     
==========================================
  Files          80       80              
  Lines        3162     3163       +1     
  Branches      892      889       -3     
==========================================
+ Hits         2660     2674      +14     
+ Misses        445      432      -13     
  Partials       57       57              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cschanhniem cschanhniem left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good fix. The pre-exit bump logic for ignored independent packages is a subtle edge case — I can see how it slipped through. The key insight is that ignored packages are intentionally excluded from preInfo.preVersions, which makes preVersions.get(name) return undefined, and undefined !== 0 is true, bypassing the guard.

The hoisted shouldSkipPackage check is the right fix — it covers both branches (new release and upgrade-from-none) without changing behavior for non-ignored packages.

One small suggestion on the test: the new test asserts that the ignored package is NOT bumped, which is the right assertion. It might also be worth adding a companion test that verifies an ignored package that IS a dependent of something being released still gets the correct treatment (i.e., it should be skipped via the existing else if branch, not via the new guard). That ensures the hoisted check doesn't inadvertently change the dependent-ignored behavior.

The changeset entry (spicy-zebras-camp.md) makes sense — this is a patch-level fix for assemble-release-plan.

@netlify

netlify Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for changesets ready!

Name Link
🔨 Latest commit 6b940a9
🔍 Latest deploy log https://app.netlify.com/projects/changesets/deploys/6a79f042784ee1000817f683
😎 Deploy Preview https://deploy-preview-2092--changesets.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

// we want to give it a patch release.
// Detailed explanation at https://github.com/changesets/changesets/pull/382#discussion_r434434182
if (preInfo.preVersions.get(pkg.packageJson.name) !== 0) {
if (preVersion != null && preVersion !== 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changed to a check like this as preInfo.preVersions already does not included ignored packages and we can rely on that check

expect(releases[1].newVersion).toEqual("1.0.1-next.0");
});

it("should not bump ignored independent packages that had a prerelease when exiting pre-release mode", () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this reported situation relate to a temporarily or permanently ignored package? If the first one, how do you expect to handle the ignored package's transition to the unignored state?

Comment thread .changeset/spicy-zebras-camp.md Resolved
@Andarist Andarist changed the title fix: do not bump ignored independent packages when exiting pre mode Do not bump ignored independent packages when exiting pre mode Aug 10, 2026
@Andarist
Andarist enabled auto-merge August 10, 2026 15:38
@Andarist
Andarist added this pull request to the merge queue Aug 10, 2026
Merged via the queue into changesets:main with commit c98af4c Aug 10, 2026
18 checks passed
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.

changeset incorrectly bumps version after exit mode.

4 participants