saschagrunert / yew-router

Router extension to yew
MIT License
28 stars 6 forks source link

Unable to build yew-router without cargo-web #226

Open ffuugoo opened 4 years ago

ffuugoo commented 4 years ago

Basically, title.

I'm trying to build a simple web-app using yew (targeting wasm32-unknown-unknown). Right now I have a webpack-based build-system (more-or-less based on yew-wasm-pack-template).

Webpack wasm-pack-plugin, obviously, does not use cargo-web, but wasm-pack. And if I depend on yew-router in my Cargo.toml it fails during yew-router compilation with errors regarding js! macro.

I've fetched yew-router and tried to directy build it with cargo build --target wasm32-unknown-unknown and got the same errors. I've then installed cargo-web and successfully built it.

So, my questions is: Is it even possible to build yew-router without using cargo-web? Am I doing something wrong here?

ffuugoo commented 4 years ago

Here is the error log:

error[E0433]: failed to resolve: use of undeclared type or module `wasm_bindgen`
  --> src/router.rs:93:21
   |
93 |         T::try_from(js! { return history.state; }).unwrap_or_default()
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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`
  --> src/router.rs:93:21
   |
93 |         T::try_from(js! { return history.state; }).unwrap_or_default()
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
  --> src/router.rs:93:21
   |
93 |         T::try_from(js! { return history.state; }).unwrap_or_default()
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
  --> src/router.rs:93:21
   |
93 |         T::try_from(js! { return history.state; }).unwrap_or_default()
   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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
saschagrunert commented 4 years ago

Hm, thanks for the PR. I don't thought that it would build without cargo-web, but we may can find a way around it...