Skip to content

fix: preserve compatible workspace ranges and widen rejecting peers - #79

Merged
lucasbraum merged 4 commits into
mainfrom
fix/react-workspace-ranges
Oct 11, 2026
Merged

lucasbraum merged 4 commits into
mainfrom
fix/react-workspace-ranges

Conversation

@lucasbraum

@lucasbraum lucasbraum commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

What and why

fix react --target 19.3.0 rejected workspace ranges such as ^18.3.1 || ^19.0.0 before resolving the target and suggested replacing them with a narrower installed-version range.

Validate each declaration against its actual planned target using semver's default prerelease exclusion. Compatible dependency, development, optional and peer ranges stay unchanged and appear in report notes as already compatible. Rejecting peer ranges retain every alternative and gain the target major; unsupported rewrites ask the user to add that major without dropping alternatives. The same path handles companions and pnpm catalogs. npm, pnpm and Yarn Berry still install the exact requested versions when compatible manifests need no edits. Yarn Berry now preserves those versions through its native yarn set resolution command only for unchanged, compatible npm ranges or aliases after temporary overrides are removed; otherwise restoring a broad range could select a newer release. Yarn 3 uses the supported --mode=skip-build flag.

fix and verify check the actual installed target and every planned companion in each declaring workspace, including local copies that shadow hoisted packages. Missing or different versions fail the run before migration/verification and are checked again after verification scripts finish.

The workspace-subdirectory hint now preserves the target and prints uptide fix react --target 19.3.0 --cwd <root> without npx or --only.

How it was verified

  • Synthetic monorepo covers exact 18.2.0, caret ^18.2.0, peer union ^18.3.1 || ^19.0.0, open peer >=16.8, and rejecting complex peer ^17 || ^18 <18.3, for React and its three companions. Exact/caret dependencies move, compatible files remain byte-for-byte unchanged, and the complex peer becomes ^17 || ^18 <18.3 || ^19.0.0.
  • Additional coverage: every dependency section, aliases, prereleases, companion-specific target versions, catalog peers, report notes, atomic refusal with widening instructions, unchanged-manifest installation, and the CLI hint. Seven selected regression cases fail against the original commit and pass with this change.
  • Offline suites: 1,529 passed (1,149 core and 380 CLI), 28 skipped (15 existing plus the 13 separately exercised network cases). TMPDIR=/private/tmp COREPACK_DEFAULT_TO_LATEST=0 pnpm test --env-mode=loose -- --maxWorkers=2.
  • Real package-manager regressions: 13 passed. npm 11.21.0, pnpm 10.17.1, Yarn 3.2.1 and Yarn 4.9.2 each retain ^19.0.0 and >=16.8 byte-for-byte while moving React and @types/react from 19.1.0 to exact 19.2.0 in the lockfile and node_modules, surviving a frozen/immutable reinstall. Two additional Yarn cases upgrade exact pins, including the failing regression reproduced against 3161528. Yarn lock records match native yarn up --exact (apart from the intentionally preserved range descriptors), with no leftover manifest override or temporary descriptor. Three real-install checks verify build flags on Yarn 2.4.3, 3.2.1 and 4.9.2: --skip-builds for 2, --mode=skip-build for 3/4. Smoke itself uses Yarn 4.9.2. Command: UPTIDE_NETWORK=1 pnpm --filter @uptide/core exec vitest run src/fix/managers/compatible-ranges.test.ts. These cases run in Node 22 CI.
  • Descriptor-selection unit tests cover unchanged compatible ranges, scoped/unscoped npm aliases, rewritten and exact pins, rejecting ranges, and excluded workspace/catalog/link/file/portal/patch/git/URL protocols.
  • Negative verification tests cover stale/missing React and all three companions, stale workspace-local copies, an installer that updates only the lockfile, and test scripts that replace installed packages.
  • pnpm lint, pnpm typecheck, build, docs links and git diff --check pass. Lint reports only the existing Biome schema-version notice. Public-tree scan is clean; the CI-only private-identifier denylist is unavailable locally.

Smoke regression follow-up

The follow-up at 3161528 ran yarn set resolution on every moved dependency, including a newly rewritten exact pin. In the Yarn Berry smoke fixture this issued yarn set resolution zod@npm:4.6.5 npm:4.6.5, creating a self-reference that makes Yarn 4.9.2 terminate during resolution. The harness then masked the CLI error by trying to read the missing migration branch. The fix compares each declaration with its pre-upgrade value, permits only unchanged compatible npm ranges/aliases, skips exact self-resolutions, and prints smoke assertion errors immediately. The Yarn 3 flag was valid and is retained.

Underlying error, captured with the same packed 3161528 CLI in the isolated Berry diagnostic run:

error: yarn set resolution zod@npm:4.6.5 npm:4.6.5 failed: ➤ YN0000: · Yarn 4.9.2
➤ YN0000: ┌ Resolution step
ERROR: Yarn is terminating due to an unexpected empty event loop.

The unmodified smoke harness surfaced fatal: invalid object name 'uptide/zod-4.6.5' afterward. Local Docker comparisons:

Commit Command Result
5a5026d pnpm smoke 22 Pass: all five fixtures
3161528 pnpm smoke 22 Fail: Yarn Berry Zod upgrade; error above
5f43abe pnpm smoke 20 Pass: all five fixtures, Node 20.20.2
5f43abe pnpm smoke 22 Pass: all five fixtures, Node 22.23.3

The committed Yarn Berry lockfile diffs for both Zod and Stripe on both fixed smoke runs are byte-for-byte identical to the passing 5a5026d baseline.

Public Medusa reproduction: preflight and summary (initial range fix)

Fresh clone of medusajs/medusa, pinned to 146c46b0ad1146b40595c8ef586c4d5890982603. corepack enable && yarn install --immutable succeeded with Yarn 3.2.1 (warnings only). Ran the built CLI from the repository root, without --pr, with assisted fixes disabled:

node "$UPTIDE_CLI" fix react --target 19.3.0 --no-llm

Preflight passed the workspace range validation that previously aborted. Public-repository output:

uptide fix · react · root (yarn, 84 packages)
assisted fixes off (--no-llm): no code leaves this machine
  @testing-library/react 14.3.1  peers react, react-dom ^18.0.0  →  upgrade to 16.1.0 (accepts react 19, react-dom 19): add @testing-library/react to the command
  cmdk 0.2.1  peers react, react-dom ^18.0.0  →  upgrade to 1.0.1 (accepts react 19, react-dom 19): add cmdk to the command
  react-helmet-async 2.0.5  peer react ^16.6.0 || ^17.0.0 || ^18.0.0  →  upgrade to 3.0.0 (accepts react 19): add react-helmet-async to the command

The run continued beyond preflight but did not complete migration: it exited 2 during analysis with:

error: cannot fix an incomplete check: react analysis failed: Cannot read properties of undefined (reading 'escapedName')

No completed migration summary was produced. The temporary clone was retained for diagnosis; the Medusa source checkout remained clean at the pinned commit, with no migration branch created. This verifies removal of the range-preflight blocker, not an end-to-end successful React migration.

Running the built CLI from packages/design-system/icons also produced the corrected hint (temporary path abbreviated):

error: fix has to run at the project root
  Every workspace declaring the dependency is upgraded together.
  Next: uptide fix react --target 19.3.0 --cwd <root>

The full optional network suite was not run; the targeted real-manager suite and Docker smoke checks above were run. Medusa was not rerun for the installed-version follow-ups; its earlier analysis limitation is documented above. No private-repository output or package lists are included.

Checklist

  • Tests for the change, including failures reproduced on the original code
  • Lint, typecheck and full test suite pass
  • README and command docs updated
  • Patch changeset added
  • No new dependency
  • Fixtures are synthetic; reproduction output is from the named public repository
  • Changes made in a separate git worktree; commits signed off with git commit -s
  • CONTRIBUTING.md safety rules preserved

@lucasbraum
lucasbraum merged commit 560d87d into main Oct 11, 2026
8 checks passed
@lucasbraum
lucasbraum deleted the fix/react-workspace-ranges branch October 11, 2026 23:31
@uptide-release uptide-release Bot mentioned this pull request Oct 11, 2026
lucasbraum added a commit that referenced this pull request Oct 11, 2026
## What and why

`uptide fix react --target 19.3.0` on medusajs/medusa at `146c46b0ad`
passed range preflight after #79, then crashed during usage analysis
with `Cannot read properties of undefined (reading 'escapedName')`.

Scoped `rootFiles` were added to ts-morph without respecting `allowJs`.
The root workspace therefore retained a JavaScript syntax tree that
TypeScript excluded from its program, leaving its property symbols
unbound. Requesting the contextual type of an object passed to
`JSON.stringify` in
`www/packages/docs-ui/scripts/generate-mermaid-icons.mjs:109`
dereferenced one of those missing symbols. The installed compiler was
TypeScript 5.9.3; the crash occurred within ts-morph's bundled 6.0.2,
not a TS 7/tsgo mismatch.

Filter scoped JavaScript roots according to effective `allowJs`,
including the `checkJs` default. Enabled JavaScript remains analyzed;
compiler exceptions are not suppressed. Includes a patch changeset and
is rebased onto main after #79.

## How it was verified

- The minimal fixture (`JSON.stringify({ icons: {} })`) failed with the
same `escapedName` error before the fix for `.js`, `.jsx`, `.mjs`, and
`.cjs`. It now checks disabled/enabled JavaScript, implicit `checkJs`,
explicit `allowJs: false`, and preserved TypeScript usages.
- `pnpm lint` and `pnpm typecheck` passed.
- Full package suites: `TMPDIR=/private/tmp pnpm -r test --maxWorkers=4`
— **1,556 passed, 28 skipped** (1,170 core + 386 CLI). Running directly
preserves canonical TMPDIR; Turbo's environment filtering caused an
unrelated macOS `/var` versus `/private/var` release-test failure in the
first attempt.
- Integration build passed. After `corepack enable` and `yarn install
--immutable`, the original #79 revision plus this fix completed Medusa
analysis, ran its baseline test command, and reached dependency
installation. The run then exited 2 because Yarn 3.2.1 rejects `yarn
install --mode=skip-builds`. That separate package-manager blocker
remains; this does not claim a successful migration. The original Medusa
checkout stayed clean and no Medusa PR was created. Assisted edits were
disabled with `--no-llm`.

## Checklist

- [x] Tests for the change (a bug fix starts with a failing test)
- [x] Lint, typecheck, and full package test suites pass (commands
above)
- [x] README and docs reviewed; no changes needed to restore the
existing compiler-setting behavior
- [x] Changeset added
- [x] No new dependency
- [x] No private code, names or paths in fixtures, tests or docs
- [x] The rules in CONTRIBUTING.md ("Rules that do not bend") still hold

Signed-off-by: Lucas Braum <[email protected]>
lucasbraum pushed a commit that referenced this pull request Oct 11, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## [email protected]

### Patch Changes

- [#79](#79)
[`560d87d`](560d87d)
Thanks [@lucasbraum](https://github.com/lucasbraum)! - Preserve
workspace ranges that already accept upgrade targets, including
companions, and report them as already compatible. Widen rejecting peer
ranges without removing alternatives and give widening instructions for
unsupported ranges. Fix the workspace-root command hint to retain the
target and use positional package syntax without npx.
  
Verify that installed target and companion versions exactly match the
plan, including when ranges already accept the target. Preserve exact
Yarn Berry resolutions without narrowing manifests and correct Yarn 3's
build-suppression flag.
  
Limit Yarn Berry descriptor pinning to unchanged compatible npm ranges
and aliases, avoiding self-resolutions when an exact dependency is
upgraded.

Co-authored-by: uptide-release[bot] <338861287+uptide-release[bot]@users.noreply.github.com>
@uptide-release uptide-release Bot mentioned this pull request Oct 11, 2026
lucasbraum pushed a commit that referenced this pull request Oct 12, 2026
… check

A 0.7.4 regression from #79. upgradeInstall read sections in the order
dependencies, devDependencies, optionalDependencies, peerDependencies, so
a workspace declaring the moved package as a widened peer
(`^18.3.1 || ^19.0.0`) next to a bumped devDependency (`^19.3.0`) had the
peer range overwrite the installable one:

- the post-install check looked the peer range up, which is no lockfile
  descriptor; Yarn read an old copy and fix stopped with "Requested
  [email protected], but packages/design-system/icons resolved 17.0.2"
  (medusajs/medusa);
- npm and pnpm installed with the peer range rewritten to the exact
  version.

Only dependencies, devDependencies and optionalDependencies now feed the
install, `yarn set resolution` and the check; peer ranges are validated
and widened in the manifest only.

Fixture fixtures/lockfiles/peer-widened (npm, pnpm, Yarn 3, Yarn 4): all
four cases fail on main and pass here.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmiChUUtLdjbg6mNzKqVep
Signed-off-by: Claude <[email protected]>
lucasbraum added a commit that referenced this pull request Oct 12, 2026
… check (0.7.4 regression) (#85)

## What and why

A regression from #79, shipped in 0.7.4. `upgradeInstall` walked a
workspace's sections in the order `dependencies`, `devDependencies`,
`optionalDependencies`, `peerDependencies`. Take a workspace that
declares the moved package as a widened peer (`^18.3.1 || ^19.0.0`,
which #79 introduced) next to a bumped devDependency (`^19.3.0`). There,
the peer range overwrote the installable one:

- **The post-install check** looked up the peer range, which is no
lockfile descriptor. Yarn then read an old copy kept by another package,
and `fix` stopped. On medusajs/medusa (Yarn 3.2.1),
`packages/design-system/icons` gave: `Requested [email protected], but
packages/design-system/icons resolved 17.0.2; verification cannot use a
different target.`
- **npm and pnpm** installed with the peer range temporarily rewritten
to the exact version (`peerDependencies.react: "19.3.0"`).

Now only `dependencies`, `devDependencies` and `optionalDependencies`
feed the install descriptors, `yarn set resolution` and the check. Peer
ranges are validated and widened in the manifest only. A workspace that
declares the package only as a peer isn't checked, since it doesn't
install it.

Rebased onto `main` after #84 landed; one commit, signed off. The only
conflict was the Yarn Berry `set resolution` loop, which #84 had also
changed. The result keeps #84's change (rewritten ranges are pinned too)
and loops over the installed sections only.

## How it was verified

New fixture `fixtures/lockfiles/peer-widened/` for npm (v3), pnpm (v9),
Yarn 3 (lockfile v6) and Yarn 4 (v8). `packages/ui` declares `lib` as
`devDependencies: ^2.0.0` (bumped) and `peerDependencies: ^1.0.0 ||
^2.0.0` (widened), and `old-tool` keeps `[email protected]` in the lockfile. The
test runs the real `upgradeInstall` with the manager mocked to write the
after-lockfile. It asserts that the install succeeds, `lib` resolves to
the target 2.0.0, and the peer range at every install is the widened
one, never an install descriptor.

| | npm | pnpm | Yarn 3 | Yarn 4 |
|---|---|---|---|---|
| `main` (with #84) | ✗ peer installed as `2.0.0` | ✗ peer installed as
`2.0.0` | ✗ resolved 1.0.0 | ✗ resolved 1.0.0 |
| this PR | ✓ | ✓ | ✓ | ✓ |

The Yarn 3 fixtures from #84 and these, run together on the rebased
branch: `subtree-swap`, `pinning-overrides`, `peer-widened` and
`upgrade` all pass (44 tests). With `main`'s `upgrade.ts`, only the four
`peer-widened` cases fail.

On medusa, the same check passes with the dev range (`parseYarn` on
medusa's lockfile: `^19.3.0` → 19.3.0, `^18.3.1 || ^19.0.0` → 17.0.2).
This was the next stop after #84 on a local copy of medusa with its
`@types/react` resolutions pin relaxed.

`pnpm lint` (only the existing `biome.json` schema note), `pnpm build`,
`pnpm typecheck`, `pnpm test`: core 1195 passed / 28 skipped, CLI 393
passed.

## Checklist

- [x] Tests for the change (a bug fix starts with a failing test): all
four fixture cases fail on `main`
- [x] `pnpm lint && pnpm typecheck && pnpm test` pass
- [x] README and docs updated if behavior changed (no documented
behavior changes; the docs already say peers are widened in the
manifest)
- [x] Changeset added if a user would notice
(`.changeset/peer-ranges-not-install-descriptors.md`, patch, names the
0.7.4 regression)
- [x] No new dependency, or it was agreed in an issue
- [x] No private code, names or paths in fixtures, tests or docs
- [x] The rules in CONTRIBUTING.md ("Rules that do not bend") still hold

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01EmiChUUtLdjbg6mNzKqVep

Signed-off-by: Claude <[email protected]>
Co-authored-by: Claude <[email protected]>
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.

1 participant