Skip to content

feat(react)!: use Oxc for JSX and add React Compiler support - #17951

Merged
matthewp merged 4 commits into
withastro:mainfrom
hanford:feat/react-oxc-compiler
Sep 17, 2026
Merged

matthewp merged 4 commits into
withastro:mainfrom
hanford:feat/react-oxc-compiler

Conversation

@hanford

@hanford hanford commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Changes

  • Upgrades @astrojs/react to @vitejs/plugin-react v6, using Oxc for JSX transforms and Fast Refresh.
  • Adds opt-in experimental React Compiler support with react({ compiler: true }). Requires oxc-transform-react; React 17 and 18 also require react-compiler-runtime.
  • Removes the babel integration option. Custom Babel transforms can be configured through @rolldown/plugin-babel in vite.plugins. Includes a major changeset and migration guidance.

Closes #17952. Related to #14955.

Testing

  • Adds integration coverage for compiler output, server rendering, and custom Babel transforms before TypeScript is stripped, with the compiler enabled and disabled.
  • Adds E2E coverage for hydration and state preservation through Fast Refresh.
  • React integration tests pass: 24 passed, 3 existing skips. Build/typecheck, formatting, lint, and frozen-lockfile installation also pass.

Docs

@changeset-bot

changeset-bot Bot commented Sep 9, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0b7f8c4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added pkg: react Related to React (scope) pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Sep 9, 2026
@hanford hanford changed the title feat(react)!: migrate to Oxc and expose React Compiler feat(react): migrate to Oxc and expose React Compiler Sep 9, 2026
Comment thread .changeset/friendly-tacos-compile.md
@hanford hanford changed the title feat(react): migrate to Oxc and expose React Compiler feat(react): add opt-in Oxc React Compiler support Sep 9, 2026
@hanford
hanford requested a review from matthewp September 9, 2026 16:22
@hanford hanford changed the title feat(react): add opt-in Oxc React Compiler support feat(react): add opt-in OXC React Compiler support Sep 9, 2026
@matthewp

Copy link
Copy Markdown
Contributor

I don't think this is correct, the oxc still runs and strips types before it reaches babel. I don't think this preserves babel compatibility.

I don't think being backwards compatible is important here, we can release this as a major. We just want to document for the user who still wants to use custom babel transformations how they can do so.

@hanford hanford changed the title feat(react): add opt-in OXC React Compiler support feat(react)!: migrate to Oxc and expose React Compiler Sep 10, 2026
@hanford
hanford force-pushed the feat/react-oxc-compiler branch from 267e3f1 to 018f010 Compare September 10, 2026 18:04
@hanford hanford changed the title feat(react)!: migrate to Oxc and expose React Compiler feat(react)!: use Oxc for JSX and add React Compiler support Sep 10, 2026
@hanford

hanford commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@matthewp Agreed, you're right: preserving JSX doesn't preserve Babel compatibility when Oxc has already stripped the types.

I've updated the PR to make this a major release, use @vitejs/plugin-react v6, and remove the babel integration option and compatibility layer. The README, changeset, and docs PR now include migration examples for custom Babel transforms using @rolldown/plugin-babel under vite.plugins.

I also added a TSX regression test that verifies Babel sees TypeScript syntax before Oxc strips it, with the compiler both on and off. The PR is rebased on main with the lockfile conflict resolved, and the React integration and Chrome tests pass.

@matthewp

Copy link
Copy Markdown
Contributor

Ok much better, will talk about docs with the @ArmandPhilippot about the docs and see when we can get this in.

@hanford

hanford commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

@matthewp Do you have a rough sense of when this might land e.g., days or weeks? Selfishly, I’m excited to use it myself 🙂 No rush, just figuring out whether to wait or use patch-package with these changes in the meantime.

@hanford
hanford force-pushed the feat/react-oxc-compiler branch from 018f010 to 7b4f56d Compare September 16, 2026 21:23
@hanford
hanford force-pushed the feat/react-oxc-compiler branch from 7b4f56d to f44be21 Compare September 17, 2026 15:41
Comment thread packages/integrations/react/README.md Outdated
Co-authored-by:  Matthew Phillips <matthew@matthewphillips.info>
@matthewp
matthewp merged commit e5b0ac4 into withastro:main Sep 17, 2026
25 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: react Related to React (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support the Oxc React Compiler in @astrojs/react

2 participants