wasmerio / wasmer-go

🐹🕸️ WebAssembly runtime for Go
https://pkg.go.dev/github.com/wasmerio/wasmer-go
MIT License
2.8k stars 161 forks source link

Can we run Javy compiled JS program with wasmer-go? #400

Open royaljain opened 10 months ago

royaljain commented 10 months ago

Summary

I'm trying to run a simple JS function, using Javy to compile the wasm file.

index.js

export function foo() {
    console.log("Hello from foo!");
}

index.wit

package local:main;

world index-world {
  export foo: func(); 
}

javy compile index.js --wit index.wit -n index-world -o index.wasm

main.go

var wasmBytes, _ = ioutil.ReadFile("index.wasm")

var engine = wasmer.NewEngine()
var store = wasmer.NewStore(engine)

var module, err = wasmer.NewModule(store, wasmBytes)

var importObject = wasmer.NewImportObject()
var instance, _ = wasmer.NewInstance(module, importObject)

var foo, _ = instance.Exports.GetFunction("foo")

Problem: Instance object is null.

Error: panic: runtime error: invalid memory address or nil pointer dereference

Can javy compiled wasm run with wasmer-go? Any leads on how to dig deeper also help!

Additional details

wasmer run -e foo index.wasm

This runs correctly.

zzrice commented 1 month ago

I have the same problem, have you solved it already?