Overview
The Oxc Transformer is a high-performance code transformation engine that transpiles modern JavaScript and TypeScript to older JavaScript versions. It’s designed as a Babel alternative with significantly better performance.TypeScript Transpilation
Strip TypeScript types and transform TS-specific syntax.
JSX/React
Transform JSX to JavaScript with React or automatic runtime.
ES2015-ES2026
Transpile modern JavaScript to ES5/ES2015 for compatibility.
Decorators & Proposals
Support for Stage 3 decorators and upcoming features.
Features
TypeScript Transformation
- Type Stripping: Remove all TypeScript type annotations
- Enum Transpilation: Convert TypeScript enums to JavaScript
- Namespace Support: Handle TypeScript namespaces
- Decorators: Stage 3 decorator support
- Import Type Removal: Strip type-only imports
- JSX in TSX: Handle JSX in TypeScript files
JSX Transformation
- React Classic: Transform to
React.createElement - React Automatic: Modern automatic JSX runtime
- React Fast Refresh: Hot module reloading support
- Development Mode: Add source locations and keys
- Fragment Support: Handle
<>syntax
ES2015+ Features
- ES2015
- ES2016-ES2019
- ES2020-ES2026
- Arrow functions
- Classes
- Template literals
- Destructuring
- Spread operator
- For-of loops
- Block scoping
Node.js API
Installation
npm
Basic Usage
Transform Options
TypeScript Transformation
JSX Transformation
Target Environment
React Fast Refresh
Rust API
Adding to Cargo.toml
Cargo.toml
Basic Usage
TypeScript Options
JSX Options
Target Environment
Transformation Examples
TypeScript to JavaScript
JSX to JavaScript
Modern JavaScript to ES5
Advanced Features
Compiler Assumptions
Optimize output with compiler assumptions:Helper Functions
Control how helpers are imported:Decorator Support
Framework Integrations
Vite Plugin
vite.config.ts
Rollup Plugin
rollup.config.js
Webpack Loader
webpack.config.js
Performance
Benchmarks
The transformer is significantly faster than Babel:| Tool | Time (1000 files) |
|---|---|
| Oxc Transform | ~1s |
| SWC | ~2s |
| Babel | ~15s |
Performance Tips
Disable Unnecessary Features
Only enable transformations you need for your target environment.
Use Assumptions
Compiler assumptions reduce output size and improve performance.
Parallel Processing
Transform files in parallel for maximum throughput.
Cache Results
Cache transformation results when possible.
Migration from Babel
Configuration Comparison
Plugin Equivalents
| Babel Plugin | Oxc Option |
|---|---|
@babel/preset-env | env: { targets } |
@babel/preset-typescript | typescript: true |
@babel/preset-react | jsx: { runtime } |
@babel/plugin-transform-runtime | helper: { mode } |
@babel/plugin-proposal-decorators | decorator: {} |
Limitations
Resources
GitHub Repository
Source code and examples
Rust Docs
Complete Rust API documentation
npm Package
Node.js bindings
Playground
Try transformations online
FAQ
Can I use Babel plugins with Oxc transformer?
Can I use Babel plugins with Oxc transformer?
No, Oxc doesn’t support Babel’s plugin API. However, most common transformations are built-in.
Is the output identical to Babel?
Is the output identical to Babel?
The output is functionally equivalent but may differ in formatting and variable naming. The transformer aims for correctness, not byte-for-byte compatibility.
Does it support decorator metadata?
Does it support decorator metadata?
Yes, Stage 3 decorators with metadata are supported.
Can I use it with Create React App?
Can I use it with Create React App?
Not directly, but you can eject and configure webpack to use oxc-loader.
Does it generate source maps?
Does it generate source maps?
Yes, source maps are generated automatically and included in the output.