diff --git a/Cargo.lock b/Cargo.lock index c519ade..58671f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -69,6 +69,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3df27b8d5ddb458c5fb1bbc1ce172d4a38c614a97d550b0ac89003897fb01de4" +[[package]] +name = "async-once-cell" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4288f83726785267c6f2ef073a3d83dc3f9b81464e9f99898240cced85fce35a" + [[package]] name = "async-stream" version = "0.3.6" @@ -849,6 +855,7 @@ dependencies = [ "serde", "subsecond", "warnings", + "wasm-splitter", ] [[package]] @@ -4489,6 +4496,30 @@ dependencies = [ "wasmparser", ] +[[package]] +name = "wasm-split-macro" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "540776437e21577983e166d89a0c65f355c0409a20e27ca79f72798d7192f0a3" +dependencies = [ + "base16", + "digest 0.10.7", + "proc-macro2", + "quote", + "sha2 0.10.9", + "syn", +] + +[[package]] +name = "wasm-splitter" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e70a57a19a59bd771cd2db8320d6a65de1763995e9fbdc0d1508301138526231" +dependencies = [ + "async-once-cell", + "wasm-split-macro", +] + [[package]] name = "wasm-streams" version = "0.4.2" @@ -5011,6 +5042,7 @@ dependencies = [ "chrono", "deadpool-postgres", "dioxus", + "dioxus-router", "dotenvy", "getrandom 0.2.17", "http", diff --git a/Cargo.toml b/Cargo.toml index ee6b615..e5cba55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,8 @@ version = "0.1.0" edition = "2021" [dependencies] -dioxus = { version = "0.7.9", features = ["fullstack", "router"] } +dioxus = { version = "0.7.9", features = ["fullstack", "router", "wasm-split"] } +dioxus-router = { version = "0.7.9", features = ["wasm-split"] } serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.52", features = ["full"], optional = true } tokio-postgres = { version = "0.7", features = ["with-chrono-0_4"], optional = true } diff --git a/Makefile b/Makefile index ce6421a..b0e1475 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ build: @$(MAKE) build-editor @$(MAKE) highlight-css @tailwindcss -i input.css -o public/style.css --minify - @dx build --release + @dx build --release --wasm-split @echo "Fixing WASM paths for production..." @python3 scripts/fix-wasm-paths.py @echo "WASM paths fixed." diff --git a/src/router.rs b/src/router.rs index 5e5e131..0e9e0fd 100644 --- a/src/router.rs +++ b/src/router.rs @@ -23,34 +23,34 @@ pub enum Route { Home {}, #[route("/page/:page")] HomePage { page: i32 }, - #[route("/archives", wasm_split)] + #[route("/archives")] Archives {}, - #[route("/tags", wasm_split)] + #[route("/tags")] Tags {}, - #[route("/tags/:tag", wasm_split)] + #[route("/tags/:tag")] TagDetail { tag: String }, #[route("/post/:slug")] PostDetail { slug: String }, - #[route("/search", wasm_split)] + #[route("/search")] Search {}, - #[route("/about", wasm_split)] + #[route("/about")] About {}, #[end_layout] #[nest("/admin")] #[layout(AdminLayout)] - #[route("/", wasm_split)] + #[route("/")] Admin {}, - #[route("/write", wasm_split)] + #[route("/write")] Write {}, - #[route("/posts", wasm_split)] + #[route("/posts")] Posts {}, #[end_layout] #[end_nest] - #[route("/login", wasm_split)] + #[route("/login")] Login {}, - #[route("/register", wasm_split)] + #[route("/register")] Register {}, }