Skip to content

feat(version): rewrite consumer pins on major bumps#85

Merged
exo-mv merged 1 commit into
masterfrom
egor/version-explicit-bumps-update-consumers
May 14, 2026
Merged

feat(version): rewrite consumer pins on major bumps#85
exo-mv merged 1 commit into
masterfrom
egor/version-explicit-bumps-update-consumers

Conversation

@exo-egor

Copy link
Copy Markdown
Contributor

Summary

lerna version updates in-monorepo consumer pins automatically. #82's explicit-bumps path lost that behavior. When a workspace package bumps 2.x → 3.0.0, every consumer's ^2.0.1 pin no longer satisfies the new version, so yarn falls back to the published 2.x on the registry — still carrying the old pre-migration source. That's what broke optimistic-balances' build on exodus-hydra#16530.

Behavior

Bump level Consumer pins
major / premajor (different major) walked + rewritten
minor, patch, preminor, prepatch, prerelease left alone — ^2.0.1 still satisfies 2.x.y, yarn keeps using the workspace symlink

For major bumps, ranges with these protocols are also skipped:

  • workspace:* / workspace:^
  • npm:@scope/alias@…
  • file: / link: / portal:
  • URLs (anything with ://)
  • dist-tags (*, latest, next)

Range prefix is preserved: ^2.0.1^3.0.0, ~2.0.1~3.0.0, >=2.0.1>=3.0.0, 2.0.1 (exact) → ^3.0.0 (default to caret).

Tests

181/181 passing (was 165, +16 new):

  • basic rewrite case
  • preserves range prefix (^/~)
  • stages every touched consumer package.json into the release commit
  • 8 skip protocols (.each)
  • cross-section rewrite (deps + devDeps + peerDeps)
  • 5 non-major bump levels (.each) — confirms consumer pins untouched

Follow-up

Once this lands, bump the hydra pin again so future releases get the fix.

When versionPackagesExplicit bumps a workspace package's major,
walk every other workspace package.json and rewrite any
\`dependencies\`/\`devDependencies\`/\`peerDependencies\` ref to the
bumped package whose existing semver range no longer satisfies the
new version. Preserves the existing range prefix (\`^\`, \`~\`, \`>=\`,
…). Minor and patch bumps skip the walk entirely — the existing
caret/tilde range already satisfies the new version, so yarn keeps
resolving the workspace symlink and there's no need to touch any
consumer's package.json.

Why: lerna's \`version\` flow does this automatically. The
explicit-bumps path in #82 lost the behavior, so a 2.x → 3.0.0
release on a workspace package would leave every consumer pinned
to \`^2.0.1\`. yarn falls back to the published 2.x copy on the
registry — still carrying the old pre-migration source — which
broke optimistic-balances' build in exodus-hydra#16530.

Skips refs that aren't semver ranges:
- \`workspace:*\` / \`workspace:^\`
- \`npm:@scope/alias@…\`
- \`file:\` / \`link:\` / \`portal:\`
- URLs (anything with \`://\`)
- dist-tags (\`*\`, \`latest\`, \`next\`)

Adds 13 new tests covering: basic rewrite, range-prefix preservation
(^/~), staging into the release commit, the 8 skip protocols (each as
its own .each row), cross-section rewrite (deps/devDeps/peerDeps),
and the 5 non-major bump levels (minor/patch/preminor/prepatch/
prerelease) as a single .each — confirming non-major bumps leave
consumers untouched.

181/181 tests passing (was 165, +16).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@exo-egor

Copy link
Copy Markdown
Contributor Author

@exo-mv to not forget

@exo-mv

exo-mv commented May 14, 2026

Copy link
Copy Markdown
Contributor

should we instead check which consumers consumed the previous version and bump them to use the new one but with the same ~ vs ^? e.g. if some consumer used ~2.2 and now we have 2.3, we should bump that consumer to use ~2.3?

cc @sparten11740

@exo-mv

exo-mv commented May 14, 2026

Copy link
Copy Markdown
Contributor

maybe ~2.2 case doesn't matter for us cause we always use ^

@exo-mv exo-mv merged commit 9a751fd into master May 14, 2026
5 of 6 checks passed
@exo-mv exo-mv deleted the egor/version-explicit-bumps-update-consumers branch May 14, 2026 13:51
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