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 5 days 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));
if (generate === 'client') {
if (AST) {
if (AST || PRINT) {
const ast = parse(source, {
modern: true
});
write(
`${cwd}/output/ast/${file}.json`,
JSON.stringify(
ast,
(key, value) => (typeof value === 'bigint' ? ['BigInt', value.toString()] : value),
'\t'
)
);
if (AST) {
write(
`${cwd}/output/ast/${file}.json`,
JSON.stringify(
ast,
(key, value) => (typeof value === 'bigint' ? ['BigInt', value.toString()] : value),
'\t'
)
);
}
if (PRINT) {
const printed = print(ast);

Loading…
Cancel
Save