Unexpected peerdependent bump to 1.0.0 in pre mode · Issue #960 · changesets/changesets · GitHub
Skip to content

Unexpected peerdependent bump to 1.0.0 in pre mode #960

Closed

Description

@hmans

Problem

I have a branch in pre mode, and I don't understand why Changesets is planning on bumping this peerdependent to 1.0.0, even if the dependency's new version perfectly satisfies the specified range (0.11 is >= 0.9, right?)

image

I would have expected the specified peer dependency range to remain intact, and the dependent's version not to be bumped to 1.0.0.

To clarify, bumping the peer dependency range would be acceptable (even if I did not expect it), but the bump to 1.0.0 is not.

My config.json:

{
  "$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
  "changelog": "@changesets/cli/changelog",
  "commit": false,
  "fixed": [],
  "linked": [],
  "access": "public",
  "baseBranch": "main",
  "updateInternalDependencies": "minor",
  "ignore": [],
  "___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
    "onlyUpdatePeerDependentsWhenOutOfRange": true
  }
}

Version of changesets in use is 2.24.4.

Link to PR and repository: https://github.com/hmans/miniplex/pull/126/files

Thanks!

Activity

  1. hmans commented on Sep 24, 2022

    @hmans
    Author

    Addendum: setting "updateInternalDependencies": "patch" didn't make a difference.

  2. Andarist commented on Oct 2, 2022

    @Andarist
    Member

    Thanks for the repro case - I will try to analyze this case soon

  3. Andarist commented on Oct 6, 2022

    @Andarist
    Member

    It seems that the CLI did the right thing here (well, perhaps the bump could be to the next minor version and not the next major version but that's a separate issue).

    Your next version of the miniplex was computed as 0.11.0-next.0 and the existing range for this dependency in miniplex-react was >=0.9.0. Prereleases are somewhat weird and special and they often work with semver ranges in somewhat unexpected ways. Despite the >= modifier - such a prerelease version doesn't satisfy this range:

    require('semver').satisfies('0.11.0-next.0', '>=0.9.0') // false
  4. hmans commented on Oct 6, 2022

    @hmans
    Author

    Thanks for taking a closer look!

    perhaps the bump could be to the next minor version and not the next major version but that's a separate issue

    A minor bump would have been acceptable, yes.

    Your next version of the miniplex was computed as 0.11.0-next.0 and the existing range for this dependency in miniplex-react was >=0.9.0. Prereleases are somewhat weird and special and they often work with semver ranges in somewhat unexpected ways. Despite the >= modifier - such a prerelease version doesn't satisfy this range:

    require('semver').satisfies('0.11.0-next.0', '>=0.9.0') // false

    Is this because it being a prerelease, or because of some sort of lexical sorting issue triggered by the -next?

  5. Andarist commented on Oct 6, 2022

    @Andarist
    Member

    A minor bump would have been acceptable, yes.

    Note that this minor bump would only be possible because your miniplex-react is still in 0.x.

    Maybe I could consider changing the rules somehow to use the minimal version bumping during the prerelease stage and only bump the dependent version to a higher bump when exiting the prerelease mode? But this gets really fuzzy to me and I would have to consider what would be the implications - also what that would actually allow us to avoid here.

    There is a chance that this could avoid such "redundant" bumps for the >= ranges.

    Is this because it being a prerelease, or because of some sort of lexical sorting issue triggered by the -next?

    It's because the version is a prerelease version:

    require('semver').satisfies('0.11.0-next.0', '>=0.9.0', { includePrerelease: true }) // true

    Those ranges are used when you install packages and their dependencies. Usually, the higher available (and compatible) version is chosen by the package manager. You certainly wouldn't like to get installed a prerelease version of a transitive dependency if your dependency declared a range like this :P That would be disastrous.

    For the same reason - we need to adjust the dependency version range. Otherwise, you wouldn't be able to install your transitive dependencies with that prerelease version. The package manager would refuse to install the prerelease dependency and you would end up with:

    miniplex-react@0.5.0-next.0
    miniplex@0.10.5 (despite the fact that 0.11.0-next.0 is available and it's the version that works with `miniplex-react@0.5.0-next.0`)
  6. hmans commented on Oct 6, 2022

    @hmans
    Author

    Thanks for taking the time to explain it in so much detail, it is highly appreciated.

    FWIW, the entire thing reminded me that it was time to publish the 1.0.0 of those packages. ;-)

  7. Andarist commented on Oct 6, 2022

    @Andarist
    Member

    One additional idea is that perhaps for the >= range we could "upgrade" it to smth like ">=0.9.0 || >=0.11.0-0.next.0":

    require('semver').satisfies('0.11.0-next.0', '>=0.9.0 || >=0.11.0-next.0') // true

    Then we could even "bring back" the original range when exiting the premode.

  8. hmans commented on Oct 7, 2022

    @hmans
    Author

    If that is a feasible thing to do, it'd be perfect!

  9. alvarosabu commented on Nov 14, 2022

    @alvarosabu

    I'm having the same issue, pkgB has pkgA as peerDependency.

    PkgB is bumped to 1.0.0 instead of next minor version.

    PkgA is bumped to next minor correctly.

  10. alvarosabu commented on Nov 18, 2022

    @alvarosabu

    Is there a work around? I'm basically doing the version bumping and then putting the correct minor version by hand

  11. dohooo commented on Dec 1, 2022

    @dohooo

    I'm having the same issue, pkgB has pkgA as peerDependency.

    PkgB is bumped to 1.0.0 instead of next minor version.

    PkgA is bumped to next minor correctly.

    Same here. Are there any updates?

  12. bluwy commented on Jun 26, 2026

    @bluwy
    Member

    @beeequeue is this also indirectly resolved by #2090?

  13. beeequeue commented on Jun 26, 2026

    @beeequeue
    Member

    i belive this was indeed caused by the peer dependent major bump, so it should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions