oxc/npm/oxc-parser
2024-06-06 15:51:53 +08:00
..
scripts Release napi oxc-parser@v0.4.0-alpha.0 2024-02-11 11:56:46 +08:00
CHANGELOG.md chore: regenerate changelogs 2024-06-06 15:51:53 +08:00
package.json chore: change website url to https://oxc.rs 2024-06-05 22:05:08 +08: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();