thaw-ui / thaw

An easy to use leptos component library
https://thawui.vercel.app
MIT License
206 stars 21 forks source link

Building thaw with latest leptos and rust does not work #177

Closed LordGaav closed 2 months ago

LordGaav commented 2 months ago

I'm trying to follow along with the examples, and I can't get cargo leptos watch to run when adding thaw. This is my entire log to reproduce the problem on my system:

$ cargo leptos new --git leptos-rs/start-axum
🤷   Project Name: foo-app
🔧   Destination: /home/lordgaav/workspace/foo-app ...
🔧   project-name: foo-app ...
🔧   Generating template ...
...
\💡   Initializing a fresh Git repository
✨   Done! New project created /home/lordgaav/workspace/foo-app

$ cargo add thaw -F ssr
    Updating crates.io index
      Adding thaw v0.3.0 to dependencies
             Features:
             + ssr
             - csr
             - hydrate
    Updating crates.io index
     Locking 260 packages to latest compatible versions
      Adding addr2line v0.21.0 (latest: v0.22.0)
      Adding bitflags v1.3.2 (latest: v2.5.0)
      Adding cached v0.45.1 (latest: v0.49.3)
      Adding cached_proc_macro v0.18.1 (latest: v0.20.0)
      Adding darling v0.14.4 (latest: v0.20.8)
      Adding darling_core v0.14.4 (latest: v0.20.8)
      Adding darling_macro v0.14.4 (latest: v0.20.8)
      Adding gimli v0.28.1 (latest: v0.29.0)
      Adding hashbrown v0.13.2 (latest: v0.14.3)
      Adding http v0.2.12 (latest: v1.1.0)
      Adding lru v0.11.1 (latest: v0.12.3)
      Adding manyhow v0.10.4 (latest: v0.11.1)
      Adding manyhow-macros v0.10.4 (latest: v0.11.0)
      Adding matchit v0.7.3 (latest: v0.8.0)
      Adding object v0.32.2 (latest: v0.35.0)
      Adding proc-macro-utils v0.8.0 (latest: v0.9.1)
      Adding redox_syscall v0.4.1 (latest: v0.5.1)
      Adding serde_qs v0.12.0 (latest: v0.13.0)
      Adding siphasher v0.3.11 (latest: v1.0.1)
      Adding strsim v0.10.0 (latest: v0.11.1)
      Adding syn v1.0.109 (latest: v2.0.60)
      Adding sync_wrapper v0.1.2 (latest: v1.0.1)
      Adding wasi v0.11.0+wasi-snapshot-preview1 (latest: v0.13.0+wasi-0.2.0)
      Adding windows-core v0.52.0 (latest: v0.56.0)
      Adding windows-sys v0.48.0 (latest: v0.52.0)
      Adding windows-targets v0.48.5 (latest: v0.52.5)
      Adding windows_aarch64_gnullvm v0.48.5 (latest: v0.52.5)
      Adding windows_aarch64_msvc v0.48.5 (latest: v0.52.5)
      Adding windows_i686_gnu v0.48.5 (latest: v0.52.5)
      Adding windows_i686_msvc v0.48.5 (latest: v0.52.5)
      Adding windows_x86_64_gnu v0.48.5 (latest: v0.52.5)
      Adding windows_x86_64_gnullvm v0.48.5 (latest: v0.52.5)
      Adding windows_x86_64_msvc v0.48.5 (latest: v0.52.5)

$ cargo leptos watch                         
   Compiling proc-macro2 v1.0.81
   Compiling unicode-ident v1.0.12
...
   Compiling linear-map v1.2.0
   Compiling leptos_macro v0.6.11
   Compiling toml v0.8.12
   Compiling config v0.14.0
   Compiling leptos_config v0.6.11
   Compiling gloo-utils v0.2.0
   Compiling leptos_reactive v0.6.11
   Compiling gloo-net v0.5.0
   Compiling wasm-streams v0.4.0
   Compiling server_fn v0.6.11
   Compiling leptos_dom v0.6.11
   Compiling leptos_server v0.6.11
error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:628:30
    |
628 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:838:30
    |
838 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:902:30
    |
902 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:929:30
    |
929 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                              ^^^^^^^^ unknown field
    |
    = note: available fields are: `span`, `element`, `view_marker`

error[E0609]: no field `children` on type `html::HtmlElement<El>`
    --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:1044:30
     |
1044 |             if matches!(self.children, ElementChildren::Chunks(_)) {
     |                              ^^^^^^^^ unknown field
     |
     = note: available fields are: `span`, `element`, `view_marker`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:628:40
    |
628 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:838:40
    |
838 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:902:40
    |
902 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
   --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:929:40
    |
929 |             if matches!(self.children, ElementChildren::Chunks(_)) {
    |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

error[E0433]: failed to resolve: use of undeclared type `ElementChildren`
    --> /home/lordgaav/.cargo/registry/src/index.crates.io-6f17d22bba15001f/leptos_dom-0.6.11/src/html.rs:1044:40
     |
1044 |             if matches!(self.children, ElementChildren::Chunks(_)) {
     |                                        ^^^^^^^^^^^^^^^ use of undeclared type `ElementChildren`

Some errors have detailed explanations: E0433, E0609.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `leptos_dom` (lib) due to 10 previous errors
      Notify watching paths style, src, public

I've tried running the example with nightly rust (the default from cargo leptos new), stable rust. I also tried installing -F hydrate,ssr. Adding thaw/ssr and thaw/hydrate to the [features] section also doesn't seem to help. Removing thaw with cargo remove thaw immediately fixes the above errors.

I'm stumped, am I doing something wrong or am I running into a bug?

luoxiaozero commented 2 months ago

Change the Settings for thaw to the following:

tracing = { version = "0.1", optional = true }
http = "1"
thaw = "0.3.0"

[features]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate", "thaw/hydrate"]
ssr = [
    "dep:axum",
    "dep:tokio",
    "dep:tower",
    "dep:tower-http",
    "dep:leptos_axum",
    "leptos/ssr",
    "leptos_meta/ssr",
    "leptos_router/ssr",
    "dep:tracing",
    "thaw/ssr",
]
LordGaav commented 2 months ago

That seems to work :+1:

What part was the solution? Not installing the ssr feature of thaw? Why does that help in this case?

luoxiaozero commented 2 months ago

CSR, SSR and hydrate are mutually exclusive, I guess your previous configuration was the following:

tracing = { version = "0.1", optional = true }
http = "1"
thaw = { version = "0.3.0", features = ["ssr"] }

[features]
hydrate = ["leptos/hydrate", "leptos_meta/hydrate", "leptos_router/hydrate", "thaw/hydrate"]
ssr = [
    "dep:axum",
    "dep:tokio",
    "dep:tower",
    "dep:tower-http",
    "dep:leptos_axum",
    "leptos/ssr",
    "leptos_meta/ssr",
    "leptos_router/ssr",
    "dep:tracing",
    "thaw/ssr",
]

The SSR is enabled by default on Thaw configuration.

When cargo leptos watch is executed, the following action is performed:

cargo build ... --target=wasm32-unknown-unknown --no-default-features --features=hydrate

cargo-leptos helps you turn on hydrate feature again, SSR and hydrate are turned on at the same time, there will be problems.

LordGaav commented 2 months ago

Ah, now I understand the purpose of the [features] block. Thanks for the help :ok_hand: