Skip to content

Wai bindgen rust is not working with the JS feature #39

@kajacx

Description

@kajacx

Scenario:

I want to use wai_bindgen_wasmer to create a Rust program that would import WASM plugins, and then run that program on a webpage. I unserstand that's what the js feature is for, but it is not working for me.

Just to re-itarate, i DO NOT want to import the WASM plugin in JS runtime.

The problem:

When I use the wai_bindgen_wasmer runtime and compile that to WASM using wasm-pack, I get this error at runtime: panicked at 'should create instance: Incompatible Export Type', src\lib.rs:41:14 (source)

fn get_color() -> protocol_plugin::Color {

    let mut store = Store::new(Engine::default());

    let module = Module::new(&store, PLUGIN_BYTES).expect("should create module");

    let (plugin, _) =
        protocol_plugin::ProtocolPlugin::instantiate(&mut store, &module, &mut imports! {})
            .expect("should create instance"); // <-- HERE

    plugin.get_color(&mut store).expect("should get color")
}

I tried cloning the wai repo and using that instead, and it actually throws a different error: panicked at 'not implemented: direct data pointer access is not possible in JavaScript', C:\Programs\Cargo\bin\registry\src\github.com-1ecc6299db9ec823\wasmer-3.1.1\src\js\externals\memory_view.rs:87:9

The code is the same as above.

Steps to reproduce:

Clone this repo at the wasm-pack-example-two-errors tag, and then clone https://github.com/wasmerio/wai.git into the repository. See the run-wasm-only.sh and run-wasm-only-forked.sh scripts on how to run the example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions