sagemathinc / cowasm

CoWasm: Collaborative WebAssembly for Servers and Browsers. Built using Zig. Supports Python with extension modules, including numpy.

Home Page:https://cowasm.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

wasi-js getImportObject

walmartwarlord opened this issue · comments

Hi! Thanks for this. I'm looking at the wasi-js example, and wondering where can get the value of wasmOpts here?

import { WASI } from "wasi-js";
import fs from "fs";
import nodeBindings from "wasi-js/dist/bindings/node";

const wasi = new WASI({
  args: [],
  env: {},
  bindings: {...nodeBindings, fs},
});

const source = await readFile(pathToWasm);
const typedArray = new Uint8Array(source);
const result = await WebAssembly.instantiate(typedArray, wasmOpts); // where can we wasmOpts
wasi.start(result.instance);

I tried looking at the WASI implementation of node 20 and tried to do it as well - but it is undefined:

const result = await WebAssembly.instantiate(typedArray, wasi.getImportObject()); // getImportObject is undefined

Any tips? Thank you!

I don't have time at the moment to look into this, but I would start by looking first at

const result = await WebAssembly.instantiate(typedArray, wasmOpts);