Skip to content

chore: add AST output to sandbox #9488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion playgrounds/sandbox/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import glob from 'tiny-glob/sync.js';
import minimist from 'minimist';
import { compile, compileModule } from 'svelte/compiler';
import { compile, compileModule, parse } from 'svelte/compiler';

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

Expand Down Expand Up @@ -49,6 +49,14 @@ for (const generate of ['client', 'server']) {
if (compiled.css) {
fs.writeFileSync(output_css, compiled.css.code);
}

if (generate === 'client') {
const ast = parse(source, {
modern: true
});

fs.writeFileSync(`${cwd}/output/${file}.json`, JSON.stringify(ast, null, '\t'));
}
}

for (const file of js_modules) {
Expand Down