deno icon indicating copy to clipboard operation
deno copied to clipboard

WASM SWC errors only in debug mode

Open TreetopFlyer opened this issue 10 months ago • 2 comments

Version: Deno 1.42.3

The following initializes the wasm version of swc.rc: example.ts

import init from "https://esm.sh/@swc/wasm-web";
await init();

You can deno run example.ts without issue, however when in debug mode (--inspect-wait or --inspect-brk), and after a debugger gets attached, it errors with:

error: Uncaught (in promise) TypeError: WebAssembly.compile(): Argument 0 must be a buffer source
    at eventLoopTick (ext:core/01_core.js:168:7)
Process exited with code 1

It's possible that this is specific to SWC, but it is interesting to note that Deno itself has to be in debug mode for it to happen so just mentioning it here, thank you.

TreetopFlyer avatar Apr 24 '24 10:04 TreetopFlyer

Just an a side note if the problem is in the WASM code (please delete if its not helpful): Another way of looking at this issue is that we're ultimately trying to jury-rig a transpiler here. Instead, if Deno (and Deploy) had some way of just exposing its own internal SWC transpiler so you don't have to add one "again" to your project e.g.

const esmDevString = await Deno.swc(`export default (props:{title:string})=><h1>{props.title}</h1>;`, {
    sourceMaps: "inline",
    jsc:{
        parser: { syntax: "typescript", tsx: true},
        transform: { react: { runtime: "automatic" } }
    }
});

it could benefit anyone working with isomorphic javascript.

TreetopFlyer avatar Apr 24 '24 12:04 TreetopFlyer

seems related https://github.com/denoland/deno/issues/21508

Hajime-san avatar May 27 '24 02:05 Hajime-san

Closing as dupe of #21508

lucacasonato avatar Jun 08 '24 17:06 lucacasonato