Bump oxc-transform-react to 0.158.0 and pin its compiler fixes
Summary
Bumps oxc-transform-react from 0.156.0 to 0.158.0 in @acusti/vite-plugin-react-compiler (exact pin). The root and docs devDependency ranges move with it, so bun hoists a single copy.
It skips 0.157.0, whose new bail-outs 0.158.0 removes again (oxc-project/oxc#28820). In Outlyne, those bail-outs would have left components uncompiled in 8 files.
The PR lands as 21 commits on top of main:
- the 0.158.0 bump with its changeset, with the 0.157.0 triage in its commit message
- 13 pins, one per fix that landed in 0.157.0
- an
it.failsfor an asserted allocation that #27427 misses - two regression guards for 0.157.0's bail-outs, which fail against 0.157.0
- an
it.failsfor the remaining skip, below - a pin for 0.158.0's non-ASCII ref panic fix
- an
AGENTS.mdsection documenting how to vet a bindings bump - a README commit describing that vetting to users
Every commit passes the plugin suite against 0.158.0.
Each item below was checked by running identical inputs through the bindings with the plugin's own transform() options (jsx: 'preserve', reactCompiler: {}, plus reportDiagnostics and panicThreshold where noted). Runtime claims come from rendering each input in sequence in React 19 (happy-dom), with clicks where relevant. Each input was rendered four ways: uncompiled, 0.156.0, 0.157.0 or 0.158.0, and babel-plugin-react-compiler@1.0.0 (with @babel/core 7).
What changes for users of 0.11.0 (0.156.0 → 0.158.0)
One new skip that can fail builds (it.fails)
A component or hook is now skipped when all of these hold:
- it keeps the result of a call it passes a callback to
- that callback reassigns one of the component's own variables
- the call sits inside an
if, a loop, aswitch, a ternary or&&
It was already skipped outside those. The diagnostic is "Cannot reassign variable after render completes", and under panicThreshold: 'critical_errors' or 'all_errors' it fails the build. A discarded result still compiles.
statement (cb is (m) => { warning = m; }) | 0.156.0 | 0.157.0 / 0.158.0 | Babel 1.0.0 / experimental |
|---|---|---|---|
if (touched) valid = validate(value, cb); | compiles | skipped | compiles |
valid = touched ? validate(value, cb) : true; | compiles | skipped | compiles |
valid = touched && validate(value, cb); | compiles | skipped | compiles |
for (const r of rules) valid = validate(r, cb); | compiles | skipped | compiles |
switch (touched) { case true: valid = validate(value, cb); } | compiles | skipped | compiles |
if (touched) { validate(value, cb); } (result discarded) | compiles | compiles | compiles |
valid = validate(value, cb); (unconditional) | skipped | skipped | skipped |
The skip comes from oxc-project/oxc#26893's rewrite of the check. The latest experimental React Compiler build (0.0.0-experimental-a1856f3-20260507) compiles these cases too, so as far as a published build shows, this is a divergence from React Compiler. Outlyne's 2,096 files have no instance of it.
An it.fails test asserts that the if case compiles. An upstream report is drafted but not filed yet; its answer decides whether that test stays an it.fails or becomes a plain pin of the skip. The changeset leads with this skip.
0.157.0's bail-outs are gone (regression guards)
0.157.0 skipped two shapes in which a callback reassigns a variable declared in another callback, and failed builds on them under panicThreshold:
- an async function reassigning such a variable, like
let socket; (async () => { socket = await connect(url); })();in an effect - a function returning the result of a callback that reassigns its own local or parameter, like
return items.map((item) => { n += 1; … })orreturn fetchPage(page).then((next) => { rows = rows.concat(next); … })
0.158.0 includes oxc-project/oxc#28820 (fixing oxc-project/oxc#28401), which limits the check to bindings declared in the component or hook. All six inputs from the earlier review compile again, and so do the 8 Outlyne files 0.157.0 would have skipped.
Two plain tests guard against the regression coming back: LoadAll and the useSocket effect each fail against 0.157.0 and pass against 0.156.0 and 0.158.0.
Runtime miscompiles fixed (landed in 0.157.0)
Every 0.156.0 output below renders differently from the uncompiled component, and every 0.158.0 output matches it.
| Fix | 0.156.0 behavior | Babel 1.0.0 |
|---|---|---|
| oxc-project/oxc#27420: memo block keyed on an input it reassigns | a clamped prop reuses an earlier render's output; quantity 3 after 5, with 3 in stock, still says "Only 3 in stock" | same bug |
| oxc-project/oxc#27421: variable reassigned in a loop inside a memo block | not restored when the block is skipped, so the "first error" link becomes # | same bug |
| oxc-project/oxc#27418: value set in a branch next to an early return on a flag | cached once per mount, so the status stays "Saving" | same bug |
oxc-project/oxc#27422: useRef inline in a memoized object (not pinned) | only called when the object rebuilds; "Should have a queue" on the next render | same bug |
oxc-project/oxc#27427: allocation in a useMemo result | new Set() shared across dependency changes, so impressions stop tracking | same bug |
| oxc-project/oxc#27426: value only passed to a state setter during render | memoization dropped; "Too many re-renders" | same bug |
oxc-project/oxc#27423: callback reading ref.current when the ref isn't recognized (boxRef ?? ownRef) | guard reads ref.current.offsetWidth during render and throws on mount | same bug |
| oxc-project/oxc#27070: property read in a JSX callback | guard reads user.id during render and throws once user is null | same bug |
oxc-project/oxc#27424: nextId.current++ | evaluates to the new value, so ids start at 1; a bigint counter throws | same bug |
oxc-project/oxc#27425: heights[index++ % columns] += h (not pinned) | target evaluated twice; heights land in the wrong columns | same bug |
oxc-project/oxc#27428: { ['__proto__']: label } (not pinned) | printed as a plain __proto__ key; the entry vanishes | same bug |
| oxc-project/oxc#26161: BigInt literals | printed as undefined; arithmetic throws | skips the function |
| oxc-project/oxc#26519: component inside a factory | callback outlined out of the factory's scope: "renderItem is not defined" | same bug |
Three rows aren't pinned, because nothing in this repo or its 12,712 dependency files has their shapes:
- #27428: no computed
'__proto__'key. - #27425: only pure keys, like
parts[parts.length - 1] += x, which behave the same on both versions. - #27422: the inline hooks that do exist, like
ref: React.useCallback(…), don't change output, and no corpus file moves a hook out of a memo block.
Now compiled (pinned)
- oxc-project/oxc#26181: a debounced callback with
debounced.cancel = cancel. 0.156.0 skipped it with "Ref type environment did not converge"; Babel 1.0.0 compiles it. - oxc-project/oxc#26893:
count++on a variable a closure captures. Babel 1.0.0 bails, like 0.156.0. - oxc-project/oxc#27309: a
.mapcallback passing an item to a handler that mutates a global (window.location.hash = id). Babel 1.0.0 bails, like 0.156.0.
Non-ASCII ref panic (pinned)
A ref-like name that starts with a non-ASCII letter (élanRef, 한글Ref) panics 0.156.0 and 0.157.0, which aborts the process, a dev server included. 0.158.0 compiles it (oxc-project/oxc#28758), as Babel 1.0.0 does. Against older bindings, the test aborts the Vitest worker.
It's pinned despite having no corpus instance, because a regression would take the process down. The existing unreachable-catch pin is there for the same reason.
Also in 0.158.0
- Source maps: codegen keeps one mapping per generated position (oxc-project/oxc#28844) and preserves names in duplicate mappings (oxc-project/oxc#26051). Mappings change in about 1,240 dependency files; code doesn't.
- Shared transformer fixes (TypeScript enum merging, class-properties lowering, the minifier): none changed a corpus file's code in default mode.
- Public typings: they add only a
typescripttransform option (enum inlining) since 0.156.0, which the plugin doesn't pass.
Known gap (it.fails)
#27427 misses an allocation wrapped in a TypeScript assertion. seen: [] as string[] or new Set() as Set<string> is still cached once per mount, as on 0.156.0 and with Babel 1.0.0.
Not pinned
- Member chains (oxc-project/oxc#27995): about 5,000 links crashes 0.156.0, and chains of 501 to 4,900 links compiled slowly. 0.158.0 skips any chain over 500 links. Only generated code has them. The changeset mentions it.
- Exponential phi type resolution (oxc-project/oxc#27417): seconds and gigabytes on 0.156.0, milliseconds after, with identical output. A test would hinge on a timeout. The changeset mentions it.
- Recursive CFG traversal (oxc-project/oxc#28119): a narrow fix. 0.158.0 still overflows near 15k sequential
ifs when a value defined before the chain is read after it. declare const|letinside a function body (oxc-project/oxc#27429): tsc rejects it, so only unchecked code can reach it.- A side effect of #27423: a function called during render that reads
.currenton a context object mutated outside render now goes stale, where 0.156.0 and Babel recompute it. That code breaks the Rules of React. - Opt-in only, or no visible change:
- async components under
validateNoImpureFunctionsInRender(oxc-project/oxc#27974) - the capitalized-calls fixes (oxc-project/oxc#25960, oxc-project/oxc#26735)
- try/finally lowering for lint (oxc-project/oxc#26093)
- the
+constant-folding fix (oxc-project/oxc#28544) - parser, semantic and regex fixes; in probes, only
f<string> in o(oxc-project/oxc#28300) changed, from fatal to accepted
- async components under
README and AGENTS.md
README: new "Bindings version" section under Usage. It says what each release is checked against:
- the pinned tests and known gaps
- a comparison of every JS/TS file in the repo and its dependencies, compiled with the old and new bindings
- runtime checks against the uncompiled code and Babel 1.0.0
It also says a release is skipped in favor of the next one that fixes it when its regressions outweigh its fixes. Regressions that ship anyway, and changes to what compiles because the new behavior is correct, are called out in the changelog and tracked in the upstream-tracking suite.
README: "Why this exists" no longer says a plain Vite + React app has nothing to gain from the plugin. @vitejs/plugin-react 6.1.2's compiler: true uses oxc-transform-react as an optional peer dependency (^0.152.0) that the app installs and vets itself.
AGENTS.md: new "Bumping oxc-transform-react" section, after "Dependency upgrades". It writes down the procedure behind the README's promises:
- triaging upstream between the crate tags
- comparing the repo,
node_modulesand Outlyne in both modes - the runtime comparison
- what to pin, and how to prove a pin against the old bindings
- the regressions-versus-fixes decision
- writing the changeset from the last shipped bindings version
Corpora
| Corpus | Files | 0.156.0 → 0.158.0, default mode | compilationMode: 'all' |
|---|---|---|---|
| This repo | 119 | 2 code diffs: MonthCalendar.tsx (#27420; it no longer misses its cache on every render without a title) and useStyles.ts (#27424, same behavior) | diffs from #27420 and #27424, plus one newly compiled function (#26893) |
Dependencies (every JS/TS file ≤ 2 MB, compiled under a path outside node_modules) | 12,712 | 2 code diffs, both #27420 (Storybook) | 250 code diffs, 6 compile-status flips |
| Outlyne (every tracked JS/TS file, with its own plugin options, which are the defaults) | 2,096 | 15 code diffs; no file changes its diagnostics, compile status or fatal status | 57 code diffs, 1 compile-status flip (newly compiled) |
The six compile-status flips in the dependency corpus under 'all':
- 3 newly compiled:
superPropBase, semver'smakeSafeRegex, react-docgen'sgetTypeParameters. - 3 newly skipped:
- two copies of yaml's
stringifyDocument, by the remaining skip - rolldown's
replacePlugin, which mutates its own argument in aforEachcallback, a real violation
- two copies of yaml's
Outlyne on 0.157.0 would have added diagnostics in 8 files and left components uncompiled in at least 2 of them. Six of the 8 were on its async or returned-callback bail-outs: EmbedRenderer, Video, WorkspaceProvider, SectionDialog, media-picker Uploads and useBookingFlow.
Outlyne's 15 code diffs on 0.158.0 come from two changes:
- Coarser cache guards (#27070):
Projects,LayoutButtonEditor,PageHeaderLogoTypeEditor,MenuManagerandMessagingAvailabilitykey onproject,section,settings,menuandavailabilityin place of property paths read in callbacks. - Newly memoized values, mostly ones passed to state setters during render (#27426):
BookingTerms,PageLinkEditor,PricingPopover,SubmissionsPopover,VideoPosterEditor,WebsiteSettings,Uploads,useSyncHealth,PromptUsageMeterandutils/media.ts.
media.ts now memoizes a value that reads a module-level cache during render. Its own fetch still updates the value, through mediaURL. The one difference is timing: when another instance caches an entry first, the slot now picks it up only once its own fetch resolves. Separately, that reading turned up a duplicate-request bug in the same hook, fixed in outlyne/outlyne#3056.
No input threw, crashed, or changed fatal status on any version.
Tests
upstream.test.ts gains 16 plain tests and 2 it.fails tests, verified by aliasing oxc-transform-react to older installs:
- 0.156.0: exactly the 13 pins fail, and so does the remaining-skip
it.fails, since 0.156.0 compiles its input. - 0.157.0: exactly the 2 regression guards fail.
- The panic pin: it aborts the worker against both.
- Existing tests: all 36 pass on every version.
Validated on the rebased head with:
bun install --frozen-lockfilebun run buildbun run buildall(including the Storybook build)bun run test(729 passed, 2 expected fail)bun run lintbun run tscbun run format:check- the plugin suite at every commit
🤖 Generated with Claude Code