Skip to content

我们很高兴地宣布 oxc-minify 的首个 alpha 版本发布。

🌐 We are excited to announce an alpha release for oxc-minify.

虽然缺少一些高级的压缩优化技术,当前版本在性能和压缩大小方面已经优于 esbuild,如 minification-benchmarks 所示。

🌐 While lacking some advanced minification techniques, the current version already outperforms esbuild in terms of performance and compression size, as demonstrated by minification-benchmarks.

typescript.js 上比较常用的压缩工具:

🌐 Comparing widely-used minifiers on typescript.js:

ArtifactOriginal sizeGzip size
typescript v4.9.5 (Source)10.95 MB1.88 MB
MinifierMinified sizeMinzipped sizeTime
@swc/core🏆-70% 3.32 MB🏆-54% 858.29 kB5x2,179 ms
oxc-minify-69% 3.35 MB-54% 860.67 kB🏆 444 ms
terser (no compress)-68% 3.53 MB-53% 879.30 kB14x6,433 ms
esbuild-68% 3.49 MB-51% 915.55 kB1x492 ms
terser ❌ Timed out--⚠️ +10,000 ms

oxc-minify 使用示例

🌐 oxc-minify Usage Example

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);

下次发布

🌐 Next Release

oxc-minify 正在被集成到 Rolldown 中,作为其内置的压缩工具,而 Rolldown 将成为 Vite 的未来

因此,对我们来说至关重要的是:

🌐 So it is critical for us to:

  • 继续实现高级压缩技术,例如常量内联和死代码删除。
  • 加强和扩展我们的测试基础设施,确保其具备生产准备能力。

致谢

🌐 Acknowledgements

感谢[@sapphi-red](https://github.com/sapphi-red)改进了压缩器, 尤其是“esbuild”所缺乏的高级符号缩小算法。

🌐 Thank you @sapphi-red for improving the minifier, especially the advanced symbol minification algorithm which esbuild lacks.