Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateInternalDependents incorrectly updates version of transitive devDependencies #947

Closed
BPScott opened this issue Sep 16, 2022 · 3 comments · Fixed by #949
Closed

updateInternalDependents incorrectly updates version of transitive devDependencies #947

BPScott opened this issue Sep 16, 2022 · 3 comments · Fixed by #949

Comments

@BPScott
Copy link
Contributor

BPScott commented Sep 16, 2022

Problem

updateInternalDependents currently incorrectly triggers version updates on packages with transitive dependencies on devDependencies. I appreciate that is too terse to make sense, a demo is clearer:

The following demonstration with reproduction steps is available at https://github.com/BPScott/changesets-transitive-deps-bug

Consider a repository with 3 packages:

  • package-a
  • package-b - this has a devDependency on package-a
  • package-c - this has a runtime dependency on package-b

package-a is the only package with a changeset associated with it.

Expected behaviour

When running npm run changset version, I would expect changsets to:

  • Update package-a: Increase the version in the package.json and generate a CHANGELOG entry, as there is a changeset associated with this package.
  • Update package-b: Update the devDependency version of package-a to the new version i the package.json. The version of package-b should be untouched as only a devDependency changed. No CHANGELOG entry is created as the version does not change.
  • Not touch package-c's package.json. Because package-b's version was not updated there should be no change to package-c's package.json or CHANGELOG.

Actual Behaviour

The expected changes to package-a and package-b's both occur as expected.

However modifications are made to package-c, when there should be none, because there package-b did not receive a version bump.

package-c's version number is increased in the package.json. A changelog heading for the new version is generated, but no content is present.

Proposed solution

Changsets is currently smart enough to skip bumping the version of a package is when one of its devDependencies has changed. Because that package does not recieve a version bump, neither should any of its dependencies. I.e. in the above example - because package-b did not receive a version bump, then package-c should be have a version bump either.

@BPScott
Copy link
Contributor Author

BPScott commented Sep 16, 2022

I tried changing the devDependency in package-b from ^1.0.0 to *.

When this occurs, package-b's package.json is no longer updated (this is expected behaviour), however the version in package-c continues to be (incorrectly) updated.

You can see that in action in the star-devdep branch of my reproduction repository.

@BPScott
Copy link
Contributor Author

BPScott commented Sep 17, 2022

I've tried to dig into this in #949. I've not got an acutal fix, but I've wrote a set of failing tests that identify the problematic behaviour and what it should be doing. Hopefully that's useful as as a starting point for somebody else.

@Andarist
Copy link
Member

@BPScott thank you for the report and the test cases - I will look into fixing this next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants