Skip to content

fix(apply-release-plan): preserve the upper bound of hyphen dependency ranges - #2389

Open
Taiwudao wants to merge 1 commit into
changesets:mainfrom
Taiwudao:fix/hyphen-range-upper-bound
Open

Taiwudao wants to merge 1 commit into
changesets:mainfrom
Taiwudao:fix/hyphen-range-upper-bound

Conversation

@Taiwudao

Copy link
Copy Markdown

Problem

When changeset version updates an internal dependency range, hyphen ranges such as 1.0.0 - 2.0.0 are silently rewritten to the bare new version. The upper bound — and with it the whole compatibility window — disappears from the manifest.

With:

// packages/pkg-a/package.json
{ "name": "pkg-a", "version": "1.0.0" }

// packages/pkg-b/package.json
{ "name": "pkg-b", "version": "1.0.0", "dependencies": { "pkg-a": "1.0.0 - 2.0.0" } }

and changesets pkg-a: minor + pkg-b: patch, changeset version produces:

-  "dependencies": { "pkg-a": "1.0.0 - 2.0.0" }
+  "dependencies": { "pkg-a": "1.1.0" }

pkg-a@1.1.0 is inside the authored window, so the range should stay bounded (for example >=1.1.0 <=2.0.0).

This is the same class of bug as #2271, which #2297 fixed for ranges written with explicit >/< comparators. new Range("1.0.0 - 2.0.0").set[0] also contains exactly one lower (>=) and one upper (<=) comparator, but getNewDependencyRange decided whether a range was bounded by looking for literal >/< characters in the input string, so hyphen ranges fell through to the ^/~/>= fallback and were replaced with a bare version.

Fix

Recognize the hyphen syntax as bounded as well, so those ranges reuse the existing bounded-range branch. Caret, tilde and x-ranges still keep their shorthand form, and union ranges still fall back as before.

Tests

  • Added a table-driven case in packages/apply-release-plan/src/index.test.ts: 1.2.0 - 2.0.0 with a minor release to 1.3.0 now yields >=1.3.0 <=2.0.0 instead of 1.3.0. Removing the source change makes this case fail, so the test does lock in the behavior.
  • pnpm exec vitest run packages/apply-release-plan/src packages/cli/src/commands/version packages/assemble-release-plan/src → 410 passed / 1 todo.
  • pnpm exec tsc, pnpm exec eslint <changed files> and pnpm exec oxfmt --check <changed files> pass.
  • Added a changeset.

One note on output shape: the range is normalized to >=x <=y, matching how the existing bounded branch already rewrites >=1.0.0 <2.0.0. Keeping the hyphen spelling would need style information that getNewDependencyRange does not carry today; happy to rework it if you would rather preserve the authored form.

@netlify

netlify Bot commented Nov 21, 2026

Copy link
Copy Markdown

👷 Deploy request for changesets pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit e891298

@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e891298

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

This PR includes changesets to release 2 packages
Name Type
@changesets/apply-release-plan Patch
@changesets/cli 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

This branch has not been deployed

No deployments
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.

1 participant