Skip to content

Unnecessary bump to 1.0.0 when dealing with peer deps and 0.x versions #1228

@jakubmazanec

Description

@jakubmazanec

Affected Packages

TBH I'm not sure which package handles this. @changesets/assemble-release-plan?

Problem

There are two packages in a monorepo, foo and bar. Notice that their version have major version 0 and that bar depends on foo via peer dependnecy:

{
  "name": "foo",
  "version": "0.1.0"
}
{
  "name": "bar",
  "version": "0.1.0",
  "peerDependencies": {
    "foo": "^0.1.0"
  }
}

Let's create new changeset:

---
'foo': minor
---
New feature makes Foo better!

When running npx changeset version, foo is bumped to 0.2.0, that means peer dependency in bar/package.json must change to ^0.2.0, which is a breaking change (because that's how caret ranges work in https://www.npmjs.com/package/semver), so bar version is bumped too - to 1.0.0. But since we're still in 0.x versions, bumping bar to 0.2.0 would suffice (it is allowed to make breaking changes when major version is zero according to https://semver.org/).

Proposed solution

In this situation, bar is bumped to 0.2.0, not 1.0.0.

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