chore: fix printing in sandbox (#18311)

when `PRINT` is true, the sandbox should write out the printed code. at
present it doesn't do this if `AST` is not also true
pull/18255/head
Rich Harris 4 months ago committed by GitHub
parent 4953860835
commit 688671ec23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -59,19 +59,21 @@ for (const generate of /** @type {const} */ (['client', 'server'])) {
mkdirp(path.dirname(output_js)); mkdirp(path.dirname(output_js));
if (generate === 'client') { if (generate === 'client') {
if (AST) { if (AST || PRINT) {
const ast = parse(source, { const ast = parse(source, {
modern: true modern: true
}); });
write( if (AST) {
`${cwd}/output/ast/${file}.json`, write(
JSON.stringify( `${cwd}/output/ast/${file}.json`,
ast, JSON.stringify(
(key, value) => (typeof value === 'bigint' ? ['BigInt', value.toString()] : value), ast,
'\t' (key, value) => (typeof value === 'bigint' ? ['BigInt', value.toString()] : value),
) '\t'
); )
);
}
if (PRINT) { if (PRINT) {
const printed = print(ast); const printed = print(ast);

Loading…
Cancel
Save