linebender / xilem

An experimental Rust native UI framework
Apache License 2.0
3.51k stars 109 forks source link

Error: cannot call wasm-bindgen imported functions on non-wasm targets #297

Closed sowbug closed 4 months ago

sowbug commented 4 months ago
$ cargo run --bin todomvc
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
     Running `target/debug/todomvc`
panicked at [...]/js-sys-0.3.69/src/lib.rs:6013:9:
cannot call wasm-bindgen imported functions on non-wasm targets

$ neofetch --stdout
-------------------- 
OS: Ubuntu Cinnamon 22.04.4 LTS x86_64 
Host: SER V1 
Kernel: 6.5.0-28-generic 
Uptime: 3 days, 21 hours, 43 mins 
Packages: 2783 (dpkg), 16 (snap) 
Shell: bash 5.1.16 
Resolution: 3440x1440 
DE: Cinnamon 5.2.7 
WM: Mutter (Muffin) 
WM Theme: (Default) 
Theme: Adwaita [GTK2/3] 
Icons: gnome [GTK2/3] 
Terminal: gnome-terminal 
CPU: AMD Ryzen 7 7735HS with Radeon Graphics (16) @ 4.829GHz 
GPU: AMD ATI e5:00.0 Rembrandt 
Memory: 10790MiB / 59995MiB 
sowbug commented 4 months ago

I see this error at https://github.com/yewstack/yew/issues/1366. There's a suggestion about adding target wasm32-unknown-unknown, but I thought I was looking at a UI framework that also works on the desktop. Maybe I'm mistaken.

matthunz commented 4 months ago

It looks to me like you're running the web example as a desktop app.

You can run those web examples with trunk serve, otherwise from the root folder of the repo you can run cargo run --example to_do_mvc to try out the native version.

sowbug commented 4 months ago

Success! I guess I was just unlucky and picked the wrong binaries to try. So far all the examples I've tried have worked:

cargo run --example to_do_mvc
cargo run --example calc
cargo run --example hello_masonry
cargo run --example simple_image

Thanks!