Oxc:下一代 JavaScript 解析器与代码检查工具的性能革命
Oxc: The Performance Revolution of Next-Gen JavaScript Parsing and Linting
| iDev Engineering | 2026-09-02T01:02:43
Oxc 项目以 Rust 重写 JavaScript 工具链的核心组件,解析速度比 ESLint 快 50-100 倍。本文解析其架构设计与工程实践。
The Oxc project rewrites core JavaScript toolchain components in Rust, achieving 50-100x faster parsing than ESLint. This article analyzes its architecture and engineering practices.
Oxc 项目概述Oxc(Oxidation Compiler)是一个用 Rust 编写的 JavaScript/TypeScript 工具集合,目标是成为 JavaScript 生态系统中最快的解析器、代码检查器、格式化器和转换器。与 SWC 专注于编译转换不同,Oxc 致力于覆盖整个开发者工具链,从代码编写到构建发布的每一个环节。性能基准测试在社区的对比基准测试中,Oxc Parser 解析一个 10 万行的 TypeScript 文件仅需 12ms,而 TypeScript 编译器需要 890ms,acorn 需要 450ms。Oxc Linter 检查同等规模的项目比 ESLint 快 50 倍,内存消耗仅为 ESLint 的 1/8。这些数据在开发者社区引发了广泛关注。架构设计深度解析Oxc 的性能优势源于三个关键设计决策:第一,使用 Arena 分配器管理 AST 节点内存,避免了大量小对象的堆分配开销;第二,采用无递归的解析算法,防止大型文件导致栈溢出;第三,Linter 规则通过 Visitor 模式实现单次 AST 遍历即可完成所有检查。这些底层优化使得 Oxc 在不牺牲正确性的前提下实现了数量级的性能提升。实际迁移建议目前 Oxc Linter 已覆盖超过 400 条规则,兼容大部分 ESLint 核心规则和 TypeScript ESLint 规则。我们建议团队分阶段迁移:先在 CI 中并行运行 Oxc 和 ESLint,对比结果差异,确认无误后逐步替换。Oxc 已被 Rspack、Rolldown 和 Biome 等项目采用。
Oxc Project OverviewOxc (Oxidation Compiler) is a collection of JavaScript/TypeScript tools written in Rust, aiming to become the fastest parser, linter, formatter, and transformer in the JavaScript ecosystem. Unlike SWC which focuses on compilation, Oxc targets the entire developer toolchain from code writing to build and release.Performance BenchmarksCommunity benchmarks show Oxc Parser can parse a 100,000-line TypeScript file in just 12ms, compared to 890ms for the TypeScript compiler and 450ms for acorn. Oxc Linter checks projects of equivalent scale 50x faster than ESLint, consuming only 1/8 the memory. These numbers have drawn widespread attention in the developer community.Architecture Deep DiveOxc's performance advantage stems from three key design decisions. First, it uses arena allocators for AST node memory management, avoiding heap allocation overhead from many small objects. Second, it employs a non-recursive parsing algorithm that prevents stack overflows on large files. Third, linter rules are implemented via the Visitor pattern, completing all checks in a single AST traversal. These low-level optimizations achieve order-of-magnitude performance improvements without sacrificing correctness.Migration RecommendationsOxc Linter currently covers over 400 rules, compatible with most ESLint core rules and TypeScript ESLint rules. We recommend a phased migration: first run Oxc and ESLint in parallel in CI to compare results, then gradually replace once confident. Oxc has been adopted by Rspack, Rolldown, and Biome.