oxc/npm/oxc-parser
overlookmotel 694f032a3d style: add trailing line breaks to package.json files (#5542)
For consistency with our `.editorconfig`.
2024-09-06 12:43:44 +00:00
..
scripts fix(npm): libc field should not be null 2024-08-22 23:29:22 +08:00
CHANGELOG.md Release crates v0.25.0 (#5107) 2024-08-23 15:37:36 +08:00
package.json style: add trailing line breaks to package.json files (#5542) 2024-09-06 12:43:44 +00:00
README.md chore(npm/oxc-parser): document parseOptions 2024-04-30 23:11:31 +08:00

The JavaScript Oxidation Compiler

See index.d.ts for parseSync and parseAsync API.

ESM

import oxc from "oxc-parser";
import assert from "assert";

function test(ret) {
  const program = JSON.parse(ret.program);
  assert(program.body.length == 1);
  assert(ret.errors.length == 0);
}

const sourceText = "let foo: Foo = 'foo';";
const options = {
  sourceFilename: "text.tsx", // the extension is used to determine which dialect to parse
};

test(oxc.parseSync(sourceText, options));

async function main() {
  test(await oxc.parseAsync(sourceText, options));
}

main();