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

js-sys should not be used when targeting wasm32-wasi #441

Closed
tqwewe opened this issue Nov 23, 2023 · 3 comments · Fixed by #442
Closed

js-sys should not be used when targeting wasm32-wasi #441

tqwewe opened this issue Nov 23, 2023 · 3 comments · Fixed by #442
Assignees
Labels

Comments

@tqwewe
Copy link

tqwewe commented Nov 23, 2023

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 something like [target.'cfg(target_arch = "wasm32", target_os = "unknown")'.dependencies] for js-sys.

This causes issues when compiling to wasm components, as when trying to convert a crate which uses wasm-bindgen to a wasm component results in the following error:

error: failed to encode a component from module

Caused by:
    0: module requires an import interface named `__wbindgen_placeholder__`
@abr-egn
Copy link
Contributor

abr-egn commented Nov 28, 2023

Thanks for bringing this to our attention!

I'm not very familiar with WASI - my understanding is that with your proposed change, when running under WASI the crate should be using the Rust stdlib which will itself do the work of using the WASI-exposed syscalls?

@tqwewe
Copy link
Author

tqwewe commented Nov 29, 2023

Yep exactly right! wasm-bindgen is for web browsers, so it gives some issues when compiling to wasm32-wasi which is meant to be used on the server side only with something like wasmtime.

@abr-egn
Copy link
Contributor

abr-egn commented Nov 29, 2023

I've submitted the fix for this in #442.

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

Successfully merging a pull request may close this issue.

3 participants