Skip to content

Commit 755fe33

Browse files
authored
chore: add AST output to sandbox (#9488)
Co-authored-by: Rich Harris <[email protected]>
1 parent c823dd2 commit 755fe33

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

playgrounds/sandbox/run.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as path from 'node:path';
33
import { fileURLToPath } from 'node:url';
44
import glob from 'tiny-glob/sync.js';
55
import minimist from 'minimist';
6-
import { compile, compileModule } from 'svelte/compiler';
6+
import { compile, compileModule, parse } from 'svelte/compiler';
77

88
const argv = minimist(process.argv.slice(2));
99

@@ -49,6 +49,14 @@ for (const generate of ['client', 'server']) {
4949
if (compiled.css) {
5050
fs.writeFileSync(output_css, compiled.css.code);
5151
}
52+
53+
if (generate === 'client') {
54+
const ast = parse(source, {
55+
modern: true
56+
});
57+
58+
fs.writeFileSync(`${cwd}/output/${file}.json`, JSON.stringify(ast, null, '\t'));
59+
}
5260
}
5361

5462
for (const file of js_modules) {

0 commit comments

Comments
 (0)