Oxc ミニファイアのアルファ公開
oxc-minify のアルファ版を公開します。
高度な圧縮手法はまだ一部足りませんが、現時点の実装でも minification-benchmarks に示すとおり、 性能と圧縮後サイズの両面で esbuild を上回っています。
typescript.js を題材にした、広く使われているミニファイア同士の比較:
| 成果物 | 元のサイズ | Gzip サイズ | |
|---|---|---|---|
| typescript v4.9.5 (ソース) | 10.95 MB | 1.88 MB | |
| ミニファイア | 圧縮後サイズ | 圧縮後 Gzip | 時間 |
| @swc/core | 🏆-70% 3.32 MB | 🏆-54% 858.29 kB | 5x2,179 ms |
| oxc-minify | -69% 3.35 MB | -54% 860.67 kB | 🏆 444 ms |
| terser (no compress) | -68% 3.53 MB | -53% 879.30 kB | 14x6,433 ms |
| esbuild | -68% 3.49 MB | -51% 915.55 kB | 1x492 ms |
| terser ❌ タイムアウト | - | - | ⚠️ +10,000 ms |
oxc-minify の使用例
typescript
import { minify } from "oxc-minify";
const filename = "test.js";
const code = "const x = 'a' + 'b'; console.log(x);";
const options = {
compress: {
target: "esnext",
},
mangle: {
toplevel: false,
},
codegen: {
removeWhitespace: true,
},
sourcemap: true,
};
const result = minify(filename, code, options);
console.log(result.code);
console.log(result.map);次のリリース
oxc-minify は Rolldown の組み込みミニファイアとして統合が進んでおり、 Rolldown は Vite の将来の基盤になる予定です。
そのため、私たちは次を重要視します。
- 定数インライン化やデッドコード除去など、高度な圧縮の継続実装。
- 本番品質に届くよう、テスト基盤の強化と拡充。
謝辞
ミニファイアの改善、特に esbuild にない高度なシンボル圧縮アルゴリズムについて、@sapphi-red に感謝します。
