Stream: git-wasmtime

Topic: wasmtime / Issue #161 Execute wasm file in NodeJS


view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2021 at 20:22):

bjorn3 commented on Issue #161:

I think this can be closed. It isn't related to Cranelift or Wasmtime.

view this post on Zulip Wasmtime GitHub notifications bot (Feb 03 2021 at 20:30):

cfallin closed Issue #161:

I'd like to expand the tutorial on how to run the wasm file in NodeJS after running it with wasmtime.

Normally you can simply run WebAssembly.instantiate(buf), but here the demo.c contains arguments input.txt and output.txt.
The WebAssembly requires a wasi_unstable object and within that a fd_prestat_get function, but I don't know how it should look like...

index.js

const fs = require('fs');
const buf = fs.readFileSync('./demo.wasm');

(async () => {
  const res = await WebAssembly.instantiate(buf, {wasi_unstable: {fd_prestat_get: () => {}}});

  console.log(res.instance);
})();


Last updated: Nov 22 2024 at 16:03 UTC