Stream: wasmtime

Topic: wasm-bindgen and Go


view this post on Zulip skullptr (Aug 15 2023 at 07:45):

Hi! I'm trying to embed Rust lib called Rapier Physics(RP) into Go plugin using wasmtime-go.
Rapier uses wasm-pack and [wasm-bindgen] in code, so *.wasm WASI and *.js files are generated.

When I create a new intance of this module in Go, all WASI imports are satisfied automatically, but __wbg* ones, obviously, are not, which is expected. After providing wbg-s my plan was calling RP wasm functions directly from Go.

Corresponding *.js file has getImports() function, which returns this wbg object with all bindings. How I can feed this wbg now to wasmtime-go instance?

If it would be NodeJS/TypeScript environment, then of course it would be easier. So I'm really stuck.

view this post on Zulip fitzgen (he/him) (Aug 15 2023 at 15:52):

wasm-bindgen is built with the assumption that there is always a JS engine and JS glue code that can be used for integration (ie browsers and node, etc)

it will not work with wasmtime or other standalone wasm runtimes

you will need to add wasi support to RP so that it supports non-js wasm environments


Last updated: Oct 23 2024 at 20:03 UTC