Files
oxc/napi/transform-react
Boshen 4a6542bfda chore(react_compiler): configure package publishing (#25389)
Prevents the internal `oxc_react_compiler` and
`oxc_transform_react_napi` Rust crates from being published while
including the `oxc-transform-react` npm package in workspace releases.

Validated with `taplo lint`, Cargo metadata, and `just ready`.

AI assistance was used for this change.
2026-08-08 08:05:28 +00:00
..
…
2026-08-03 11:21:03 +01:00
2026-08-03 11:21:03 +01:00

Oxc React Transform

Native Node.js bindings for Oxc's experimental Rust port of React Compiler.

The API follows oxc-transform: pass a filename, source text, and optional options to either transformSync or transform. React Compiler runs first, then Oxc removes TypeScript syntax and applies the configured JSX transforms.

import { transformSync } from "oxc-transform-react";

const result = transformSync(
  "Component.tsx",
  `
    export function Component({ name }: { name: string }) {
      return <div>Hello {name}</div>;
    }
  `,
  {
    reactCompiler: {
      target: "19",
    },
    jsx: {
      runtime: "automatic",
    },
  },
);

if (result.fatal) {
  console.error(result.errors);
} else {
  console.log(result.code);
}

errors contains every diagnostic reported by parsing, the React Compiler, and the downstream transform. Some React Compiler bail-outs have error severity but are nonfatal under the default panicThreshold; check fatal to decide whether the transform emitted usable code.

reactCompiler defaults to true. Set it to false to skip React Compiler, or pass an options object using the same names as babel-plugin-react-compiler/react-compiler-napi, including compilationMode, panicThreshold, target, gating, outputMode, suppression controls, and the supported environment flags.

jsx accepts the same options as oxc-transform, including automatic or classic runtime configuration and React Fast Refresh. Set it to "preserve" to leave JSX syntax in the output.

Callback-valued options such as logger, function-valued sources, and type provider callbacks are not accepted by the native binding. sources accepts an array of filename substrings instead.