Skip to content

Transformer

A high-performance transformer that rewrites unsupported syntax into forms supported by target runtimes.

Features

Oxc's transform pipelines run their supported features in a fixed order, regardless of the order of the options:

  1. React Compiler — runs first, on the original source.
  2. TypeScript — type stripping.
  3. Decorators.
  4. Plugins — e.g. styled-components.
  5. React Refresh — component instrumentation, runs just before the JSX transform.
  6. JSX — JSX to JavaScript.
  7. Lowering — ES2026 down to ES2015.
  8. Inject — global variable injection.
  9. Define — global variable replacement.

oxc-transform exposes steps 2–9. The dedicated oxc-transform-react package runs the React Compiler first, followed by TypeScript syntax removal, React Refresh, and JSX transformation.

Oxc also supports TypeScript Isolated Declarations emit without using the TypeScript compiler.

General Options

The transform function accepts a filename, source code, and an options object:

js
import { transform } from "oxc-transform";

const result = await transform("lib.ts", sourceCode, {
  // Force the source language. Inferred from filename by default.
  lang: "tsx", // "js" | "jsx" | "ts" | "tsx" | "dts"

  // Treat the source as script, module, or CommonJS. Inferred by default.
  sourceType: "module", // "script" | "module" | "commonjs" | "unambiguous"

  // The current working directory. Used to resolve relative paths.
  cwd: "/path/to/project",

  // Enable source map generation.
  sourcemap: true,

  // Configure runtime helper strategy.
  helpers: {
    mode: "Runtime", // "Runtime" (import from @oxc-project/runtime) or "External" (use global babelHelpers)
  },

  // See sub-pages for more options:
  // typescript, jsx, target, assumptions, define, inject, decorator, plugins
});

The transform function is async. A synchronous transformSync variant is also available with the same signature.

Installation

Node.js

Rust

Use the umbrella crate oxc with the transformer feature.

Rust usage example can be found here.

Dedicated Transform Packages

oxc-transform-react

A React-focused transform pipeline that combines the experimental React Compiler, TypeScript syntax removal, JSX transformation, and React Fast Refresh.

oxc-transform-relay

A Relay transform that replaces graphql tagged templates with references to artifacts generated by relay-compiler while preserving other syntax for downstream tooling.

Integrations