question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Automatic Dependency Updates Within Monorepo

See original GitHub issue

Problem

If I have @scope/package-a, @scope/package-b, @scope/package-c. Both @scope/package-b and , @scope/package-c rely on @scope/package-a. When I make a change to @scope/package-a, commit & create yarn changeset, select @scope/package-a and update it with a patch version, then yarn changeset version, @scope/package-a’s version changes, but both @scope/package-b AND @scope/package-c’s dependencies @scope/package-a does not get changed.

What’s the best way to ensure ALL dependents change to new latest version within its range? This happens with pre-releases for me as well as normal. I’ve tried changing package-a to minor AND major.

chanset --version
2.11.0

node --version
v13.13.0

yarn --version
1.22.4

config.json

{
  "$schema": "https://unpkg.com/@changesets/config@1.4.0/schema.json",
  "changelog": "@changesets/cli/changelog",
  "commit": false,
  "linked": [],
  "access": "restricted",
  "baseBranch": "master",
  "updateInternalDependencies": "patch",
  "ignore": []
}

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:9
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Andaristcommented, Oct 22, 2020

I believe you have made mistakes in that example output:

  • pkg-a should have version: 2.0.0
  • pkg-b should have version: 1.1.0

Nevertheless, I get your point. Why the dependency ranges have changed in here? Because the packages that are being published get dependency ranges updates according to updateInternalDependencies setting. This makes sense because when you change the code of a dependant package it might start to depend on some fresh code in a monorepo setup from a dependency package - so it’s safer to update the range. The idea was that if u change the code of a dependency then most likely a dependant package should not be affected by this but when you change the code of a dependant package it should always use the latest version of its monorepo dependencies - otherwise, it would be fairly easy to publish broken releases. This leads to some inconsistencies around when dependency ranges are updated - might be surprising at times.

As mentioned - we recognize this problem and we’d like to have it fixed, but I’m afraid that we don’t have much time to implement a solution for this ourselves currently. I’d be more than happy to assist anyone with guidance, code reviews etc if one would like to implement this.

2reactions
Andaristcommented, Oct 22, 2020

In such a case we don’t always update dependant packages - if their dependency ranges are satisfied by a new version of package-a then an update is skipped.

This is causing some problems/difficulties though - I was discussing this with @mitchellhamilton some time ago. From what I remember we’ve agreed on introducing an experimental flag that would change this behavior (to what you want, from what I understand) with a perspective of it becoming a default in the future.

Could you confirm that this is what you expect:

Input:

tree
---
pkg-a
  version: 1.0.0
pkg-b
  version: 1.0.0
  dependencies:
    pkg-a: ^1.0.0
pkg-c
  version: 1.0.0
  dependencies:
    pkg-a: ^1.0.0

changeset
---
pkg-a: patch

Output:

tree
---
pkg-a
  version: 1.0.1
pkg-b
  version: 1.0.1
  dependencies:
    pkg-a: ^1.0.1
pkg-c
  version: 1.0.1
  dependencies:
    pkg-a: ^1.0.1
Read more comments on GitHub >

github_iconTop Results From Across the Web

Automatic Dependency Updates Within Monorepo · Issue #476
When I make a change to @scope/package-a , commit & create yarn changeset , select @scope/package-a and update it with a patch version,...
Read more >
Automate dependency updates | Nicky blogs
Staying up to date with every dependency your project uses quickly turns into a chore. It's a never-ending stream of new releases.
Read more >
How to Easily Manage Dependencies in a JS Monorepo
Dependency management in a JavaScript monorepo is made much simpler with pnpm ... Automatic solutions and libraries can help but usually, ...
Read more >
Automate Dependency Updates With Renovate, Not With ...
It normally happens with monorepo dependencies. In such a situation, you can group update PRs of them into one PR.
Read more >
Automating Dependency Updates for Your GitHub Projects
In this article, we'll be using it to automatically run tests against pull requests made by Renovate to ensure that dependency updates do...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found