v0.8.0 fails to build with wasm-pack
kvnallsn opened this issue · 10 comments
Describe the Bug
When building web assembly applications using wasm-pack yew-router 0.8.0 fails to compile. Seems to be missing the wasm-bindgen
dependency when the service
feature is enabled and the target is wasm32-unknown-unknown
. Most likely due to the addition of the js!
macro in yew_router/src/service.rs:165
. Adding wasm-bindgen
as a dependency fixes this issue.
The following error messages are produced:
Compiling yew-router v0.8.0
error[E0433]: failed to resolve: use of undeclared type or module `wasm_bindgen`
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-router-0.8.0/src/service.rs:165:5
|
165 | / js!(
166 | | return @{history}.state;
167 | | )
| |_____^ use of undeclared type or module `wasm_bindgen`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0433]: failed to resolve: use of undeclared type or module `WasmDescribe`
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-router-0.8.0/src/service.rs:165:5
|
165 | / js!(
166 | | return @{history}.state;
167 | | )
| |_____^ use of undeclared type or module `WasmDescribe`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0425]: cannot find function `inform` in this scope
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-router-0.8.0/src/service.rs:165:5
|
165 | / js!(
166 | | return @{history}.state;
167 | | )
| |_____^ not found in this scope
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0425]: cannot find value `FUNCTION` in this scope
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-router-0.8.0/src/service.rs:165:5
|
165 | / js!(
166 | | return @{history}.state;
167 | | )
| |_____^ not found in this scope
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error: aborting due to 4 previous errors
Some errors have detailed explanations: E0425, E0433.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `yew-router`.
To Reproduce
- Install wasm-pack per instructions at https://github.com/rustwasm/wasm-pack
- Extract code.tar.gz
- Run
wasm-pack build
in extracted directory
Related Info
-
rustc version: 1.40
-
yew version: 0.11.0
-
yew-router version: 0.8.0
-
build toolchain: wasm-pack
Same issue here
Working on it now.
Running cargo check --target wasm32-unknown-unknown
on the yew-router project produces the same error. This, at the very least should be added to the CI to prevent this from happening again.
Thank you @kvnallsn for the detailed bug report! Your writeup and suspected cause made it super easy for me to address the issue.
I've published 0.8.1 to crates.io and I'll get a GH release up soon.
Well, I've pushed out v0.8.1, but it appears to be broken in cases where RouterButton
and RouterAnchor
are used due to generic handling.
Static asserting implementations of those components implementing Component
yield successful tests, but the compiler throws errors when using them within the Yew macro.
Test indicating that the struct implements the correct trait.
#[test]
fn anchor_string_is_component() {
static_assertions::assert_impl_one!(RouterAnchor<String>: yew::Component);
}
Compiler output indicating not everything is fine.
--> examples/guide/src/guide.rs:103:18
|
103 | <RouterAnchor<String> route=props.page_url.clone()> {&props.title} </RouterAnchor<String>>
| ^^^^^^^^^^^^ the trait `yew::html::Component` is not implemented for `yew_router::components::router_link::RouterAnchor<std::string::String>`
I would suggest that you not upgrade to v0.8.1 for the moment if you make use of these generic components.
@trivigy do you have any insight into this issue? I recall you working around a regression in this feature recently.
Edit - ignore this, the error was on my end. Caused by me mixing the cargo dependency with the git/master dependency for yew between the project and example - causing an incompatibility.
Hi, @hgzimmerman
I still have build errors with 0.8.1
:
Code is here in upgrade_yew_0_11
branch : https://github.com/jetli/create-yew-app/tree/feature/upgrade_yew_0_11
Build steps: https://github.com/jetli/create-yew-app/tree/feature/upgrade_yew_0_11/crates/yew-app#readme
PR: jetli/create-yew-app#1
/Users/jetli/repos/3rdparty/create-yew-app/crates/yew-app/Cargo.toml: Command failed: wasm-pack build --dev
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling stdweb v0.4.20
error[E0463]: can't find crate for `stdweb_internal_macros`
--> /Users/jetli/.cargo/registry/src/github.com-1ecc6299db9ec823/stdweb-0.4.20/src/lib.rs:142:1
|
142 | extern crate stdweb_internal_macros;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
|
= note: extern location for stdweb_internal_macros is of an unknown type: /Users/jetli/repos/3rdparty/create-yew-app/target/debug/deps/libstdweb_internal_macros-514a12fe27aecec8.dylib
= help: file name should be lib*.rlib or *..wasm
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: could not compile `stdweb`.
To learn more, run the command again with --verbose.
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
crates:
[dependencies]
log = "0.4"
web_logger = "0.2"
yew = "0.11.0"
yew-router = "0.8.1"
wasm-bindgen = "0.2.58"
wee_alloc = "0.4.5"
[dev-dependencies]
wasm-bindgen-test = "0.3.8"
It's working now, I use cargo clean
to clean up and re-build again, Thanks!