Skip to content

Commit dc5c773

Browse files
committed
write out precompiled source
Signed-off-by: Karthik Ganeshram <[email protected]>
1 parent 7ce6e82 commit dc5c773

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/build-tools/src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { readFile, writeFile } from 'node:fs/promises';
1313
import { mergeWit } from '../lib/wit_tools.js';
1414
//@ts-ignore
1515
import { precompile } from "./precompile.js"
16+
import path from 'node:path'
1617

1718
async function main() {
1819
try {
@@ -65,9 +66,16 @@ async function main() {
6566
const source = await readFile(src, 'utf8');
6667
const precompiledSource = precompile(source, src, true) as string;
6768

68-
// Using the old syntax because the new syntax does not allow passing in the precompiled string
69-
//@ts-ignore
70-
const { component } = await componentize(precompiledSource, inlineWit, {
69+
// Write precompiled source to disk for debugging purposes In the future we
70+
// will also write a source map to make debugging easier
71+
let srcDir = path.dirname(src);
72+
let precompiledSourcePath = path.join(srcDir, 'precompiled-source.js');
73+
await writeFile(precompiledSourcePath, precompiledSource);
74+
75+
const { component } = await componentize({
76+
sourcePath: precompiledSourcePath,
77+
// @ts-ignore
78+
witWorld: inlineWit,
7179
runtimeArgs,
7280
enableAot: CliArgs.aot,
7381
});

0 commit comments

Comments
 (0)