Skip to content

wasm2js usage or usecase unclear #2263

Closed
@advdv

Description

@advdv

Dear reader,

I'm either using the wasm2js tool wrong or I don't understand what it should be use for. I'm pretty new to the wasm ecosystem so my apologies if i'm asking something crazy here.

Basically I got a main.wasm file that I run fine in browsers that support wasm directly. But I would like to research the possibility of running it in older browsers as well. The description of the wasm2js tool in the README.md seems promising "compiles WebAssembly to JS" and is also hinted at in the wasmrust documentation: https://rustwasm.github.io/wasm-bindgen/examples/wasm2js.html

But whenever I try to run the resulting .js file in chrome or node it will give me errors such as Uncaught SyntaxError: Unexpected token .. This seems to indicate it is not actually valid Js as expected by the browser or node. Is there an extra compilation step i'm missing? Some sources on the internet mention that the tool outputs "almost asm.js" but its unclear to me what I should do with this information. Issue #1929 and https://v8.dev/blog/emscripten-llvm-wasm#javascript-output seem to suggest the tool is moving away from asm.js... what gives?

I'm building the wasm2js tool from source on the latest commit. But downloading it through the releases gives me the same mystery.

Any help on how to convert/transpile a wasm file to javascript that can be run in any browser would be appreciated.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions