Skip to content

Only bump peer dependents when leaving range using an experimental flag#383

Merged
emmatown merged 15 commits intochangesets:masterfrom
Feiyang1:fei-experimental-flags
Jun 8, 2020
Merged

Only bump peer dependents when leaving range using an experimental flag#383
emmatown merged 15 commits intochangesets:masterfrom
Feiyang1:fei-experimental-flags

Conversation

@Feiyang1
Copy link
Contributor

@Feiyang1 Feiyang1 commented Jun 1, 2020

Replaces #185
Introduces an experimental flag onlyUpdatePeerDependentsWhenOutOfRange. When set to true, peer dependents are bumped only if the peerDep version is leaving range.

@changeset-bot
Copy link

changeset-bot bot commented Jun 1, 2020

🦋 Changeset is good to go

Latest commit: 2778497

We got this.

This PR includes changesets to release 6 packages
Name Type
@changesets/assemble-release-plan Major
@changesets/apply-release-plan Major
@changesets/get-release-plan Major
@changesets/config Patch
@changesets/types 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

@@ -0,0 +1,7 @@
---
"@changesets/assemble-release-plan": patch
Copy link
Member

@emmatown emmatown Jun 2, 2020

Choose a reason for hiding this comment

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

This is a major to assemble-release-plan, apply-release-plan and any other package that exposes a function that accepts a Config object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Marked the following packages major - assemble-release-plan, apply-release-plan and @changesets/get-release-plan.

Out of curiosity, only @changesets/assemble-release-plan consumes the experimental flag for now, why do we want to bump major for apply-release-plan and get-release-plan?

Second question - Why do we want to use major for them at all? It seems to me a minor version bump suffices because it's not a breaking change. You kinda touched on it in #185 (comment), but I don't think I understand

We'll likely do lots of majors to internal packages(as in the packages that aren't the cli package) when changing these options because otherwise we would have to use exact ranges everywhere

Can you please elaborate?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, I'm also not sure about this - future changes should be majors (if we are worried about breaking those unsafe flags - which we don't for the top-level packages, we don't want to major bump cli, so Im also unsure why we should care about breaking them for internal ones, the only thing that comes to my mind are fresh reinstalls), but adding the first "unsafe" flag shouldn't require major bump based on my understanding.

Copy link
Member

Choose a reason for hiding this comment

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

If we did not do a major for assemble-release-plan, people would get broken installs for anything below the latest version of @changesets/cli because they could have the new version of @changesets/assemble-release-plan where we depend on config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH.onlyUpdatePeerDependentsWhenOutOfRange existing and an old version of @changesets/config.

The reason that it's also important to bump other packages which accept a Config object is that we've added a new required property to the Config object so therefore they should have major bumps. This will manifest concretely in the form of type errors(for consumers of the internal packages) but it's also a conceptual thing that would still exist if we did not have types, types are just making it visible.

This is similar to something often seen in the React community where React adds a new feature like forwardRef or hooks, adding that feature isn't a major for React but it if a consumer starts using that new feature, that consumer has to do a major bump.

@emmatown
Copy link
Member

emmatown commented Jun 3, 2020

Could you add a test to https://github.com/atlassian/changesets/blob/master/packages/cli/src/commands/version/version.test.ts for something like this:

A project that looks like this:

  • pkg-a@1.0.0
    • peerDependencies
      • pkg-b@^1.0.0
  • pkg-b@1.0.0

Then you add the following changeset:

  • pkg-a@patch
  • pkg-b@patch

The project should look like this:

  • pkg-a@1.0.1
    • peerDependencies
      • pkg-b@^1.0.0 (this is the important bit, this must be ^1.0.0, NOT ^1.0.1)
  • pkg-b@1.0.1

@Feiyang1
Copy link
Contributor Author

Feiyang1 commented Jun 3, 2020

Could you add a test to https://github.com/atlassian/changesets/blob/master/packages/cli/src/commands/version/version.test.ts for something like this:

A project that looks like this:

  • pkg-a@1.0.0

    • peerDependencies

      • pkg-b@^1.0.0
  • pkg-b@1.0.0

Then you add the following changeset:

  • pkg-a@patch
  • pkg-b@patch

The project should look like this:

  • pkg-a@1.0.1

    • peerDependencies

      • pkg-b@^1.0.0 (this is the important bit, this must be ^1.0.0, NOT ^1.0.1)
  • pkg-b@1.0.1

Done. I actually didn't handle this case before, so it required some code changes as well.

Would you mind explain the rationale behind keeping ^1.0.0 instead of bumping it to ^1.0.1? Is it because bumping peerDepedencies signals the change of minimal required version for peerDependencies, and thus consumers need to upgrade them and it should be a major for the dependent? Thanks!

@emmatown
Copy link
Member

emmatown commented Jun 4, 2020

Is it because bumping peerDepedencies signals the change of minimal required version for peerDependencies, and thus consumers need to upgrade them and it should be a major for the dependent

Yep, that.

return getBumpLevel(release.type) >= minLevel;
}

export function shouldUpdatePeerDependency(
Copy link
Member

Choose a reason for hiding this comment

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

Could you merge this function with shouldUpdateInternalDependency? I find it understand to understand what's going on here with the way the logic is working in versionPackage and this particular part of Changesets is something that's very important that we get right and it's hard to check if it's hard to understand

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Also moved the test from cli package to apply-release-plan because that's where we test updateInternalDependencies.

@Feiyang1
Copy link
Contributor Author

Feiyang1 commented Jun 8, 2020

@mitchellhamilton Do you think we are ready to merge it? I'd like to create a PR (code is ready) for #381 (comment) which depends on this one.

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

Thanks!!

@atlassian-cla-bot
Copy link

Thank you for your submission! Like many open source projects, we ask that you sign our CLA (Contributor License Agreement) before we can accept your contribution.
If your email is listed below, please ensure that you sign the CLA with the same email address.

The following users still need to sign our CLA:
❌mitchellhamilton

Already signed the CLA? To re-check, try refreshing the page.

@emmatown emmatown merged commit addd725 into changesets:master Jun 8, 2020
@github-actions github-actions bot mentioned this pull request Jun 8, 2020
@Feiyang1 Feiyang1 deleted the fei-experimental-flags branch June 11, 2020 20:02
hasparus added a commit to hasparus/TypeChain that referenced this pull request Oct 18, 2021
jpwilliams added a commit to inngest/inngest-js that referenced this pull request Dec 12, 2023
## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

We use non-local peer dependencies due to a restriction with the build
process of `inngest`.

This contributes to changesets bumping peer dependencies for packages
that want to reference `inngest` from their wide constraint (e.g.
`^3.0.0`) to a narrower one (e.g. `^3.7.1`).

I believe we can avoid this using an experimental flag added in
changesets/changesets#383.

## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~~Added a [docs PR](https://github.com/inngest/website) that
references this PR~~ N/A
- [ ] ~~Added unit/integration tests~~ N/A
- [x] Added changesets if applicable

## Related

- changesets/changesets#383
- changesets/changesets#524
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.

3 participants