generate AST first (#9587)

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/9592/head
Rich Harris 1 year ago committed by GitHub
parent 1003acccc4
commit d57eff76ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -34,22 +34,11 @@ for (const generate of ['client', 'server']) {
const input = `${cwd}/input/${file}`; const input = `${cwd}/input/${file}`;
const source = fs.readFileSync(input, 'utf-8'); const source = fs.readFileSync(input, 'utf-8');
const compiled = compile(source, {
filename: input,
generate,
runes: argv.runes
});
const output_js = `${cwd}/output/${generate}/${file}.js`; const output_js = `${cwd}/output/${generate}/${file}.js`;
const output_css = `${cwd}/output/${generate}/${file}.css`; const output_css = `${cwd}/output/${generate}/${file}.css`;
mkdirp(path.dirname(output_js)); mkdirp(path.dirname(output_js));
fs.writeFileSync(output_js, compiled.js.code);
if (compiled.css) {
fs.writeFileSync(output_css, compiled.css.code);
}
if (generate === 'client') { if (generate === 'client') {
const ast = parse(source, { const ast = parse(source, {
modern: true modern: true
@ -57,6 +46,17 @@ for (const generate of ['client', 'server']) {
fs.writeFileSync(`${cwd}/output/${file}.json`, JSON.stringify(ast, null, '\t')); fs.writeFileSync(`${cwd}/output/${file}.json`, JSON.stringify(ast, null, '\t'));
} }
const compiled = compile(source, {
filename: input,
generate,
runes: argv.runes
});
fs.writeFileSync(output_js, compiled.js.code);
if (compiled.css) {
fs.writeFileSync(output_css, compiled.css.code);
}
} }
for (const file of js_modules) { for (const file of js_modules) {

Loading…
Cancel
Save