@yuku-parser/wasm
v0.5.41
Published
High-performance JavaScript/TypeScript parser, compiled to WebAssembly
Downloads
2,473
Maintainers
Readme
@yuku-parser/wasm
The yuku-parser JavaScript/TypeScript
parser as a single WebAssembly module. Runs anywhere: browsers, bundlers, Deno,
Bun and Node. Same API and same AST as yuku-parser.
Install
npm install @yuku-parser/wasmUsage
import { parse } from "@yuku-parser/wasm";
const { program, comments, diagnostics } = parse("const x: number = 1", {
lang: "ts",
});parse(source, options?) returns { program, comments, diagnostics, lineStarts,
locOf, scan }. Options:
| Option | Default | Description |
| ---------------------------- | ---------- | ----------------------------------------- |
| lang | "js" | "js" \| "ts" \| "jsx" \| "tsx" \| "dts" |
| sourceType | "module" | "module" \| "script" |
| preserveParens | true | Keep ParenthesizedExpression nodes |
| allowReturnOutsideFunction | false | Allow top-level return |
| semanticErrors | false | Also run semantic analysis |
| attachComments | false | Attach comments to their host node |
