解析器
🌐 Parser
这已经准备好生产了。
🌐 This is production ready.
特性
🌐 Features
- 比 SWC 解析器快 3 倍(基准)。
- 解析
.js(x)和.ts(x)。 - 通过 Test262 的所有解析器测试,并通过 Babel 和 TypeScript 的 99% 测试。
- 直接返回 ESM 信息,无需
es-module-lexer。 - ✅ 与 checker.ts 一起使用
安装
🌐 Installation
Node.js
- 使用节点绑定 oxc 解析器。
- 在 stackblitz 上试试。
Rust
使用总的箱子 oxc 或单独的 oxc_ast 和 oxc_解析器 箱子。
🌐 Use the umbrella crate oxc or the individual oxc_ast and oxc_parser crates.
可以在这里找到 Rust 使用示例。
🌐 Rust usage example can be found here.
打印
解析和转换后,你可以打印代码。
🌐 After parsing and transforming, you can print code.
这是一个直接使用 esrap 的例子 (parse 倒过来!):
🌐 Here's a direct example using esrap (parse in reverse!):
js
import { print } from "esrap";
import ts from "esrap/languages/ts";
import { parseSync } from "oxc-parser";
const { program } = parseSync("test.js", 'alert("hello oxc & esrap");');
const { code } = print(program, ts());
console.log(code); // alert("hello oxc & esrap");INFO
今天,注释不会被打印。它将通过 oxc-parser #13285 获得支持。
