oxc/npm/oxc-parser
2024-09-13 22:51:33 +08:00
..
scripts chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00
CHANGELOG.md release(oxc): crates v0.28.0 (#5696) 2024-09-11 17:57:55 +08:00
package.json chore: fix package.json EOL 2024-09-13 22:51:33 +08:00
README.md chore: use dprint to format js, json and markdown 2024-09-08 13:24:58 +08:00

The JavaScript Oxidation Compiler

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

ESM

import assert from 'assert';
import oxc from 'oxc-parser';

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();