Oxc Transformer Alpha
Oxc transform(別名:transpile)のアルファ版リリースを発表し、お喜び申し上げます。
このリリースには以下の3つの主要機能が含まれています:
- TypeScript → ESNext への変換。
- React JSX → ESNext への変換(組み込みの React Refresh 機能付き)。
- TypeScript コンパイラを使用せずに、TypeScript Isolated Declarations DTS Emit を実行。
このアルファ段階では、ビルド時間を短縮するために、これらの機能を試していただくことをおすすめします。
私たちのベンチマーク の結果は以下の通りです:
- 変換:Oxc は SWC より 3~5倍高速で、メモリ使用量が20%少なく、パッケージサイズも小さい(2 MB 対 SWC の 37 MB)。
- 変換:Oxc は Babel より 20~50倍高速で、メモリ使用量が70%少なく、パッケージサイズが19 MB小さく、インストールする npm パッケージ数はわずか2つ(Babel では170個)。
- React 開発 + React Refresh:Oxc は SWC より 5倍高速、Babel より 50倍高速。
- TS isolated declarations
.d.tsemit:Oxc は通常のファイルでは TSC より 40倍高速、大きなファイルでは 20倍高速。
使用例
oxc-transform npm パッケージ
現在、Vue.js はそのビルドパイプライン内で、孤立宣言用に oxc-transform npm パッケージを実験しています:
import { isolatedDeclaration } from "oxc-transform";
const dts = isolatedDeclaration(filename, ts);@lukeed および @maraisr は、自身のパッケージ empathic および dldr において oxc-transform を活用し、.d.ts を1ステップで変換・生成しています。
以下の例は、1回の変換ステップで .js と .d.ts を出力する方法を示しています:
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 は、esbuild プラグイン用の統合ツールとして unplugin-isolated-decl を使用しています。
@sxzz は、.d.ts の生成時間が 76秒から 16秒にまで短縮されたと報告しています。
Airtable における Bazel ビルド
Airtable からの @michaelm は、Bazel ビルド内での CI パイプラインに、Oxc の孤立宣言 .d.ts 出力機能を統合しています。
Rust oxc_transformer クレート
バンドラーの Rolldown は、oxc_transformer Rust クレートを直接利用しています。
ベンチマーク結果
ベンチマークの設定は oxc-project/bench-transformer にあり、ベンチマークの結果はその GitHub Actions に表示されています。
(誤設定の修正については歓迎いたします。)
ubuntu-latest 環境で、コード行数の異なる例について測定を行いました:
変換
| 行数 | oxc | swc | babel |
|---|---|---|---|
| ~100 | 0.14 ms | 0.7 ms (5x) | 11.5 ms (82x) |
| ~1000 | 0.9 ms | 5.7 ms (6.3x) | 38.7 ms (43x) |
| ~10000 | 14.9 ms | 35.9 ms(2.4x) | 492 ms (33x) |
孤立宣言
| 行数 | oxc | tsc |
|---|---|---|
| ~100 | 0.1 ms | 23.1 ms (231x) |
| ~1000 | 3.1 ms | 26.8 ms (8.6x) |
| ~10000 | 3.5 ms | 115.2 ms (33x) |
パッケージサイズ
Oxc はわずか 2 個の npm パッケージをダウンロードし、合計 2 MB です。
| パッケージ | サイズ |
|---|---|
@oxc-transform/binding-darwin-arm64 | 2.0 MB |
@swc/core-darwin-arm64 | 37.5 MB |
@babel/core + @babel/preset-env + @babel/preset-react + @babel/preset-typescript | 21 MB と 170 個のパッケージ |
メモリ使用量
Oxc はより少ないメモリを使用します。
parser.ts(10777 行)の変換におけるメモリ使用量(/usr/bin/time -alh node で測定):
| 最大 RSS | |
|---|---|
| oxc | 51 MB |
| swc | 67 MB |
| babel | 172 MB |
次回リリース
次回のリリースでは、目標下限(ES6)および @babel/plugin-transform-modules-commonjs の導入を予定しています。
認知感謝
今回のリリースに尽力いただいた @Dunqing および @overlookmotel に感謝します。
また、snyder.tech、schoolhouse.world、@lukeed、@maraisr の皆様に、ご慷慨なスポンサーシップをいただき、心より感謝申し上げます。



