Skip to content

Support the Oxc React Compiler in @astrojs/react #17952

Description

@hanford

What problem does this solve?

I'd like to enable the Oxc React Compiler directly through @astrojs/react, without writing a separate Vite transform or changing existing Babel configuration.

Proposed API

import react from '@astrojs/react';
import { defineConfig } from 'astro/config';

export default defineConfig({
  integrations: [react({ compiler: true })],
});

Users would install oxc-transform-react, plus react-compiler-runtime for React 17/18. An options object should also be accepted for compiler configuration.

Compatibility

This should be an opt-in, non-breaking addition. Existing projects should keep working without configuration changes, including projects using custom Babel plugins or Babel configuration callbacks.

Vite's React plugin supports the Oxc compiler in v6, but that version removes the babel option. Keeping Astro's current React plugin and adding an Oxc transform ahead of it would let us expose the compiler without requiring that migration.

Compilation should apply to client components, respect the integration's file filters, and preserve hydration and Fast Refresh. The scope is @astrojs/react.

Related work

Implementation: #17951. It preserves Babel support and includes a minor changeset.

Related: #14955 proposes an option for the Babel-based React Compiler.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

triage: not actionableNot a bug report or not actionable for triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions