Stream: wit-bindgen

Topic: ✔ bindgen macro and wasm-tools compatibility


view this post on Zulip Ramon Klass (Oct 05 2023 at 17:23):

after cargo update, I'm getting this error when trying to adapt my component, do I need to pin wit-bindgen or something?

[xtask/src/main.rs:23] &command = Command {
    program: "wasm-tools",
    args: [
        "wasm-tools",
        "component",
        "new",
        "--adapt",
        "wasi_snapshot_preview1=/opt/wasi/wasi_snapshot_preview1.reactor.wasm",
        "target/wasm32-wasi/release/guest_editor.wasm",
        "-o",
        "/tmp/.tmpGVR7D1/initialized.wasm",
    ],
    create_pidfd: false,
}
error: failed to encode a component from module

Caused by:
    0: module requires an import interface named `__wbindgen_placeholder__`

view this post on Zulip Lann Martin (Oct 05 2023 at 17:26):

__wbindgen_placeholder__ is a symbol from wasm-bindgen, unrelated to anything in the wasmtime / component ecosystem

view this post on Zulip Ramon Klass (Oct 05 2023 at 17:28):

so basically I have some dependency that thinks it should compile for the web, that helps me pin down where this is coming from, thank you :)

view this post on Zulip Ramon Klass (Oct 05 2023 at 17:28):

(I'm pretty sure it's swc)

view this post on Zulip Lann Martin (Oct 05 2023 at 17:28):

iirc getrandom is a common source of these errors, via its js feature

view this post on Zulip Lann Martin (Oct 05 2023 at 17:28):

oh yeah swc would make sense too

view this post on Zulip Joel Dice (Oct 05 2023 at 17:33):

When this came up with Leptos (https://github.com/leptos-rs/leptos/issues/295), I created https://github.com/dicej/stubber as a hacky workaround.

for server rendering, if you want to run the wasm in a runner without v8 functionality, you would probably will need a wasm32-wasi target. unfortunately, due to some dependencies, mostly wasm-bindg...
Tool to convert Wasm module imports to trapping stubs - GitHub - dicej/stubber: Tool to convert Wasm module imports to trapping stubs

view this post on Zulip Ramon Klass (Oct 05 2023 at 17:42):

fun thing: this is exactly the problem I have, it is leptos-reactive (which I use for something other than html) that has a hard dependency on serde-wasm-bindgen
I'll ask Greg why the dependency that pulls in wasm-bindgen isn't optional and stubber is exactly what fixes my problem ;)

view this post on Zulip Notification Bot (Oct 05 2023 at 17:46):

Ramon Klass has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC