Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 51ce472

Browse files
author
Wenjie Xia
committed
chore(compiler): update the build script
print diagnostic message simply
1 parent c5386a1 commit 51ce472

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

compiler/build.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if (import.meta.main) {
1010
p.close()
1111

1212
const wasmData = await Deno.readFile('./pkg/aleph_compiler_bg.wasm')
13+
const wpjsContent = await Deno.readTextFile('./pkg/aleph_compiler.js')
1314
const data = brotli.compress(wasmData)
1415
const data64 = base64.encode(data)
1516
const hash = (new Sha1).update(data).hex()
@@ -26,5 +27,16 @@ if (import.meta.main) {
2627
'./dist/wasm-checksum.js',
2728
`export const checksum = ${JSON.stringify(hash)}`
2829
)
29-
await Deno.copyFile('./pkg/aleph_compiler.js', './dist/wasm-pack.js')
30+
await Deno.writeTextFile(
31+
'./dist/wasm-pack.js',
32+
`import log from "../../shared/log.ts";` + wpjsContent.replace('console.error(getStringFromWasm0(arg0, arg1));', `
33+
const msg = getStringFromWasm0(arg0, arg1);
34+
if (msg.includes("DiagnosticBuffer")) {
35+
const diagnostic = msg.split('DiagnosticBuffer(["')[1].split('"])')[0]
36+
log.error("swc:", diagnostic)
37+
} else {
38+
log.error(msg)
39+
}
40+
` )
41+
)
3042
}

0 commit comments

Comments
 (0)