swc/ecmascript/babel/compat/tests/swcgen.js
강동윤 6896a83d54
fix(es/codegen): Fix codegen of ~ (#2104)
swc_ecma_codegen:
 - Emit pending semi on `~`. (#2091)
2021-08-19 17:21:08 +09:00

17 lines
488 B
JavaScript

// Helper for generating SWC JSON.
// USAGE: node swcgen.js path/to/input.js > path/to/output.json
const {readFileSync} = require("fs");
const {parseSync} = require("../../../index.js");
const inputFile = process.argv[2];
if (!inputFile) {
console.error("Missing input file. Hint: `node swcgen.js path/to/input.js`");
process.exit(1);
}
const code = readFileSync(inputFile, "utf8");
const swcAst = parseSync(code, { jsx: true });
console.log(JSON.stringify(swcAst, null, 4));