Tuesday, 11 July 2023

How do I include a wasm file compiled by golang in a chrome extension?

I've tried everything in here:

Golang to wasm compilation

And I can't get past:

WebAssembly.instantiate(buffer, {wasi_snapshot_preview1: ""})
WebAssembly.instantiate(buffer, {go: {debug: ""}})

(i'm making them "" strings just to show I need to add the key but obviously they are not strings.)

i.e. I get errors like:

Failed to load WebAssembly module: TypeError: WebAssembly.instantiate(): Import #0 module="wasi_snapshot_preview1" error: module is not an object or function

or module debug or runtime.resetMemoryDataView or everything in wasm_exec.js

But if I use the simple.wasm from:

https://github.com/inflatablegrade/Extension-with-WASM

it works! That wasm must have been compiled by c or rust and NOT golang? Is there a way to make this work from go?

P.S. that Extension-with-WASM is manifest 2.0 but I got it work with 3.0:

https://github.com/inflatablegrade/Extension-with-WASM/issues/1



from How do I include a wasm file compiled by golang in a chrome extension?

No comments:

Post a Comment