mirror of
https://github.com/swc-project/swc.git
synced 2024-11-27 13:38:33 +03:00
790a262c07
swc_babel_ast: - Rename as `swc_estree_ast`. swc_babel_compat: - Rename as `swc_estree_compat`. swc_babel_visit: - Rename as `swc_estree_visit`.
17 lines
488 B
JavaScript
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));
|
|
|