seed-rs / seed

A Rust framework for creating web apps
MIT License
3.81k stars 155 forks source link

Cannot use subs (subs::UrlChanged) #714

Closed MahdiBaghbani closed 1 year ago

MahdiBaghbani commented 1 year ago

I'm following seed examples, my setup is: rustc 1.68.0 (2c8cc3432 2023-03-06)

Cargo.toml

[package]
name = "frontend"
version = "0.1.0"
edition = "2021"

[lib]
# cdylib stands for "C dynamic library" — a WASM module is kind of like a dynamic library, and
# "C" should be understood as just meaning "native format, no Rust-specific conventions".
# In order to get a .wasm file, you must request a crate-type of cdylib in your configuration
# (and this is also standard when using wasm-pack)
crate-type = ["lib", "cdylib"]

[profile.release]
# Do not perform backtrace for panic on release builds.
panic = "abort"
# Perform optimizations on all codegen units.
codegen-units = 1
# "s" for normal optimize or "z" to optimize "aggressively" for size.
opt-level = "z"
# Enable link time optimization.
lto = true

[package.metadata.wasm-pack.profile.release]
# "s" for normal optimize or "z" to optimize "aggressively" for size.
wasm-opt = ["-Oz"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
seed = "0.10.0"
serde = "1.0"
wasm-bindgen = "0.2"

[dependencies.web-sys]
version = "0.3"
features = [
    "Blob",
    "Event",
    "EventTarget",
    "File",
    "FileList",
    "FormData",
    "HtmlInputElement",
]

I'm following this example: https://github.com/seed-rs/seed/blob/release-v0.10.0/examples/pages_hash_routing/src/lib.rs

and I do see this error:

error[E0433]: failed to resolve: use of undeclared crate or module `subs`
   --> frontend/src/lib.rs:148:16
    |
148 |     UrlChanged(subs::UrlChanged),
    |                ^^^^ use of undeclared crate or module `subs`

what am I doing wrong?

oussama commented 1 year ago

You need to add feature "routing", it is a change in 0.10

On Fri, Apr 7, 2023, 1:21 PM Mohammad Mahdi Baghbani Pourvahid < @.***> wrote:

I'm following seed examples, my setup is: rustc 1.68.0 (2c8cc3432 2023-03-06)

Cargo.toml

[package] name = "frontend" version = "0.1.0" edition = "2021"

[lib]

cdylib stands for "C dynamic library" — a WASM module is kind of like a dynamic library, and

"C" should be understood as just meaning "native format, no Rust-specific conventions".

In order to get a .wasm file, you must request a crate-type of cdylib in your configuration

(and this is also standard when using wasm-pack)

crate-type = ["lib", "cdylib"]

[profile.release]

Do not perform backtrace for panic on release builds.

panic = "abort"

Perform optimizations on all codegen units.

codegen-units = 1

"s" for normal optimize or "z" to optimize "aggressively" for size.

opt-level = "z"

Enable link time optimization.

lto = true

[package.metadata.wasm-pack.profile.release]

"s" for normal optimize or "z" to optimize "aggressively" for size.

wasm-opt = ["-Oz"]

See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies] seed = "0.10.0" serde = "1.0" wasm-bindgen = "0.2"

[dependencies.web-sys] version = "0.3" features = [ "Blob", "Event", "EventTarget", "File", "FileList", "FormData", "HtmlInputElement", ]

I'm following this example: https://github.com/seed-rs/seed/blob/release-v0.10.0/examples/pages_hash_routing/src/lib.rs

and I do see this error:

error[E0433]: failed to resolve: use of undeclared crate or module subs --> frontend/src/lib.rs:148:16 | 148 | UrlChanged(subs::UrlChanged), | ^^^^ use of undeclared crate or module subs

what am I doing wrong?

— Reply to this email directly, view it on GitHub https://github.com/seed-rs/seed/issues/714, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXS22YDTZQ6PLKC2ITMO23XAABENANCNFSM6AAAAAAWWQNDCM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

MahdiBaghbani commented 1 year ago

@oussama Thanks! it solved the issue and now I can compile it.