Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't work with wasmer-js #15

Open
magulyas opened this issue Dec 30, 2024 · 2 comments
Open

Can't work with wasmer-js #15

magulyas opened this issue Dec 30, 2024 · 2 comments

Comments

@magulyas
Copy link

Issue

I can't load the py2wasm generated file with wasmer-js.

hello.py

def talk(message):
    return "Talk " + message

def main():
    print(talk("Hello World"))

if __name__ == "__main__":
    main()

Compiling

py2wasm hello.py -o myprogram.wasm

Browser side code

import { init, WASI } from '@wasmer/wasi';
async function load(){
  const moduleBytes = fetch('myprogram.wasm');
  const module = await WebAssembly.instantiateStreaming(moduleBytes); // -> Error
  await init();
  const wasi = new WASI({
    env: {  },
    args: [ ],
  });
  await wasi.instantiate(module, {});
  const exitCode = wasi.start();
  const stdout = wasi.getStdoutString();
  console.log(`${stdout}(exit code: ${exitCode})`);
}

Error (Chrome console)

Uncaught (in promise) TypeError: WebAssembly.instantiate(): Imports argument must be present and must be an object

Test with wasmer

wasmer run myprogram.wasm  
Talk Hello World
@syrusakbary
Copy link
Member

Hey @magulyas , you should try to use @wasmer/sdk, not the deprecated @wasmer/wasi.

@magulyas
Copy link
Author

Hi @syrusakbary, This issue is independent from @wasmer/wasi. It's coming from WebAssembly.instantiate() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants