Skip to content

Oxc Transformer Alpha


We are excited to announce an alpha release for Oxc transform (a.k.a transpile).

This release contains three major features:

  1. Transforming TypeScript to ESNext.
  2. Transforming React JSX to ESNext, with built-in React Refresh.
  3. TypeScript Isolated Declarations DTS Emit without using the TypeScript compiler.

In this alpha stage, we recommend to experiment with these features to speed up build times.

Our benchmark shows:

  • Transform: Oxc is 3x - 5x faster than SWC, uses 20% less memory, and has smaller package size (2 MB vs SWC's 37 MB).
  • Transform: Oxc is 20x - 50x faster than Babel, uses 70% less memory, and is 19 MB smaller, with only 2 npm packages to install vs Babel's 170.
  • React development + React Refresh: Oxc is 5x faster than SWC, 50x faster than Babel.
  • TS isolated declarations .d.ts emit: Oxc is 40x faster than TSC on typical files, 20x faster on larger files.

Usage Examples ​

oxc-transform npm package ​

Vue.js is currently experimenting the oxc-transform npm package for isolated declarations in its build pipeline:

javascript
import { isolatedDeclaration } from "oxc-transform";
const dts = isolatedDeclaration(filename, ts);

@lukeed and @maraisr are utilizing oxc-transform for their packages empathic and dldr to transform and generate .d.ts in a single step.

The following example demonstrates emitting .js and .d.ts in a single transformation step:

javascript
import { transform } from "oxc-transform";
const transformed = transform(filePath, sourceCode, {
  typescript: {
    onlyRemoveTypeImports: true,
    declaration: { stripInternal: true },
  },
});
await fs.writeFile("out.js", transformed.code);
await fs.writeFile("out.d.ts", transformed.declaration);

unplugin-isolated-decl ​

vue-macros uses unplugin-isolated-decl as the integration tool for its esbuild plugin.

@sxzz reports their .d.ts generation time is reduced from 76s to 16s.

Bazel build at Airtable ​

@michaelm from Airtable is integrating Oxc's isolated declarations .d.ts emit in their CI pipeline within their Bazel build.

Rust oxc_transformer crate ​

The Rolldown bundler uses the oxc_transformer Rust crate directly.

Benchmark Results ​

The benchmark setup is located at oxc-project/bench-transformer and the benchmarks are shown in its GitHub Actions.

(Corrections are welcome for any misconfigurations.)

On ubuntu-latest, an example of different lines of code are measured:

Transform ​

Linesoxcswcbabel
~1000.14 ms0.7 ms (5x)11.5 ms (82x)
~10000.9 ms5.7 ms (6.3x)38.7 ms (43x)
~1000014.9 ms35.9 ms(2.4x)492 ms (33x)

Isolated Declarations ​

Linesoxctsc
~1000.1 ms23.1 ms (231x)
~10003.1 ms26.8 ms (8.6x)
~100003.5 ms115.2 ms (33x)

Package size ​

Oxc downloads only 2 npm packages, a total of 2 MB.

PackageSize
@oxc-transform/binding-darwin-arm642.0 MB
@swc/core-darwin-arm6437.5 MB
@babel/core + @babel/preset-env + @babel/preset-react + @babel/preset-typescript21 MB and 170 packages

Memory Usage ​

Oxc uses less memory.

Memory usage transforming parser.ts (10777 lines) - measured using /usr/bin/time -alh node:

Max RSS
oxc51 MB
swc67 MB
babel172 MB

Next Release ​

Our next release will include target lowering to ES6 and @babel/plugin-transform-modules-commonjs.

Acknowledgements ​

Thank you @Dunqing and @overlookmotel for all the hard work involved in this release.

Thank you snyder.tech, schoolhouse.world, @lukeed and @maraisr for the generous sponsorship.

Released under the MIT License.