Treetop Flyer
Treetop Flyer4mo ago

WASM version of SWC.RC errors only in debug mode

NOTE: This is a bare bones example just to illustrate the problem: we aren't transpiling anything just getting the wasm to init. basic setup: - swc.ts:
import init from "https://esm.sh/@swc/wasm-web";
await init();
import init from "https://esm.sh/@swc/wasm-web";
await init();
- .vscode/launch.json:
{"configurations": [{"name": "debug", "request": "attach", "type": "node"}]}
{"configurations": [{"name": "debug", "request": "attach", "type": "node"}]}
steps: In the CLI run:
deno run -A swc.ts
deno run -A swc.ts
It should just run and quit OK with no errors. Next in the CLI run with a debug flag:
deno run -A --inspect-wait swc.ts
deno run -A --inspect-wait swc.ts
and then attach the debugger (vscode: "Run and debug" the configured debugger ["debug"]). You should see the console error:
error: Uncaught (in promise) TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
at eventLoopTick (ext:core/01_core.js:168:7)
error: Uncaught (in promise) TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
at eventLoopTick (ext:core/01_core.js:168:7)
3 Replies
Deno AI Helper
Deno AI Helper4mo ago
I wasn't able to find the answer to your question in the official Deno documentation. However, based on the information you've provided in your message, I can offer some general advice. The error message you're seeing suggests that the WebAssembly module is expecting a buffer source as an argument, but it's not receiving one. This could potentially be an issue with how the WebAssembly is being initialized or used within the @swc/wasm-web package when running in debug mode. One thing to note is that the launch.json configuration you've provided is for Node.js debugging, not Deno. Deno has its own debugger that can be used with Visual Studio Code. Here's an example of what the launch.json configuration might look like for Deno:
{
"configurations": [
{
"name": "Deno: Run",
"type": "pwa-node",
"request": "launch",
"program": "${workspaceFolder}/swc.ts",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "-A", "--inspect-brk"],
"attachSimplePort": 9229
}
]
}
{
"configurations": [
{
"name": "Deno: Run",
"type": "pwa-node",
"request": "launch",
"program": "${workspaceFolder}/swc.ts",
"runtimeExecutable": "deno",
"runtimeArgs": ["run", "-A", "--inspect-brk"],
"attachSimplePort": 9229
}
]
}
Please note that this advice is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. If you continue to experience issues, you may want to reach out to the maintainers of the @swc/wasm-web package or seek support from the Deno community for more specific guidance.
marvinh.
marvinh.4mo ago
@Treetop Flyer That sounds like a bug in Deno. Can you file an issue for that? https://github.com/denoland/deno/issues/new/choose
Treetop Flyer
Treetop Flyer4mo ago
will do thank you!