feat(version): rewrite consumer pins on major bumps#85
Merged
Conversation
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).
Contributor
Author
|
@exo-mv to not forget |
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? |
Contributor
|
maybe ~2.2 case doesn't matter for us cause we always use ^ |
exo-mv
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
lerna versionupdates 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.1pin 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 onexodus-hydra#16530.Behavior
major/premajor(different major)minor,patch,preminor,prepatch,prerelease^2.0.1still satisfies2.x.y, yarn keeps using the workspace symlinkFor major bumps, ranges with these protocols are also skipped:
workspace:*/workspace:^npm:@scope/alias@…file:/link:/portal:://)*,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):
.each).each) — confirms consumer pins untouchedFollow-up
Once this lands, bump the hydra pin again so future releases get the fix.