Stream: wit-bindgen

Topic: ✔ module requires import named `__wbindgen_placeholder__`


view this post on Zulip Ari Seyhun (Nov 23 2023 at 05:54):

When building my component with wasm-tools component new, I get an error:

module requires an import interface named `__wbindgen_placeholder__`

This only occurs when I include a local crate as a dependency (and use it).
I'm not sure what part of this dependency is causing this issue, but the dependency itself has nothing to do with wasm, and is just a regular rust crate.

From digging into the code of wasm bindgen, it seems like __wbindgen_placeholder__ is supposed to get replaced with something, however in my case it isn't?

view this post on Zulip Ari Seyhun (Nov 23 2023 at 06:04):

Sorry it doesn't work, here's the current output:

 wasm-tools component new ./target/wasm32-wasi/release/game.wasm -o ./modules/game.wasm --adapt ./../../../thalo-rs/thalo/crates/thalo_cli/wasi_snapshot_preview1.wasm
error: failed to encode a component from module

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

view this post on Zulip Alex Crichton (Nov 23 2023 at 06:21):

This indicates that wasm bindgen is being used but that's not compatible with components so the only fix will be to figure out what's depending on wasm bindgen and to either update or remove that dependency

view this post on Zulip Ari Seyhun (Nov 23 2023 at 06:28):

That's strange, it would make sense however when I do cargo tree -p game or cargo tree -i wasm-bindgen, it's not a dependency of the game wasm component being generated.

It is a dependency used within the cargo workspace I'm in, but I don't think that should import wasm bindgen

view this post on Zulip Ari Seyhun (Nov 23 2023 at 06:32):

output.txt

view this post on Zulip Ari Seyhun (Nov 23 2023 at 06:32):

I've just posted the output of running cargo tree -p game

view this post on Zulip Ari Seyhun (Nov 23 2023 at 07:40):

Ah I forgot to do --target wasm32-wasi when creating the tree! Looks like the bson crate was the issue, using wasm-bindgen.

view this post on Zulip Notification Bot (Nov 23 2023 at 07:40):

Ari Seyhun has marked this topic as resolved.

view this post on Zulip Ari Seyhun (Nov 23 2023 at 07:53):

https://github.com/mongodb/bson-rust/issues/441

Describe the bug js-sys brings in wasm-bindgen when targeting wasm32 architechture. However, wasm32-wasi targets should not use js-sys not wasm-bindgen. The cargo toml should be updated to be somet...

Last updated: Dec 23 2024 at 12:05 UTC