Skip to content

Commit

Permalink
chore: add AST output to sandbox (#9488)
Browse files Browse the repository at this point in the history
Co-authored-by: Rich Harris <[email protected]>
  • Loading branch information
Rich-Harris and Rich-Harris authored Nov 16, 2023
1 parent c823dd2 commit 755fe33
Showing 1 changed file with 9 additions and 1 deletion.
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

1 comment on commit 755fe33

@vercel
Copy link

@vercel vercel bot commented on 755fe33 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-5-preview-git-main-svelte.vercel.app
svelte-5-preview-svelte.vercel.app
svelte-octane.vercel.app
svelte-5-preview.vercel.app

Please sign in to comment.