feat: enable wasm-split for route-based code splitting
Enable Dioxus 0.7 automatic WASM bundle splitting by route: - Add wasm-split feature to dioxus and dioxus-router in Cargo.toml - Add --wasm-split flag to dx build in Makefile - Router definitions stay as plain #[route] — splitting is automatic Dioxus 0.7.9 handles splitting automatically when the feature and CLI flag are enabled. Per-route #[wasm_split] attributes are not required (and not supported by this version's derive macro).
This commit is contained in:
parent
c44f37e9ec
commit
a282d1dd29
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -69,6 +69,12 @@ version = "0.13.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3df27b8d5ddb458c5fb1bbc1ce172d4a38c614a97d550b0ac89003897fb01de4"
|
checksum = "3df27b8d5ddb458c5fb1bbc1ce172d4a38c614a97d550b0ac89003897fb01de4"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "async-once-cell"
|
||||||
|
version = "0.5.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4288f83726785267c6f2ef073a3d83dc3f9b81464e9f99898240cced85fce35a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-stream"
|
name = "async-stream"
|
||||||
version = "0.3.6"
|
version = "0.3.6"
|
||||||
@ -849,6 +855,7 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"subsecond",
|
"subsecond",
|
||||||
"warnings",
|
"warnings",
|
||||||
|
"wasm-splitter",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -4489,6 +4496,30 @@ dependencies = [
|
|||||||
"wasmparser",
|
"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]]
|
[[package]]
|
||||||
name = "wasm-streams"
|
name = "wasm-streams"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
@ -5011,6 +5042,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"deadpool-postgres",
|
"deadpool-postgres",
|
||||||
"dioxus",
|
"dioxus",
|
||||||
|
"dioxus-router",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
"getrandom 0.2.17",
|
"getrandom 0.2.17",
|
||||||
"http",
|
"http",
|
||||||
|
|||||||
@ -4,7 +4,8 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[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"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tokio = { version = "1.52", features = ["full"], optional = true }
|
tokio = { version = "1.52", features = ["full"], optional = true }
|
||||||
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4"], optional = true }
|
tokio-postgres = { version = "0.7", features = ["with-chrono-0_4"], optional = true }
|
||||||
|
|||||||
2
Makefile
2
Makefile
@ -4,7 +4,7 @@ build:
|
|||||||
@$(MAKE) build-editor
|
@$(MAKE) build-editor
|
||||||
@$(MAKE) highlight-css
|
@$(MAKE) highlight-css
|
||||||
@tailwindcss -i input.css -o public/style.css --minify
|
@tailwindcss -i input.css -o public/style.css --minify
|
||||||
@dx build --release
|
@dx build --release --wasm-split
|
||||||
@echo "Fixing WASM paths for production..."
|
@echo "Fixing WASM paths for production..."
|
||||||
@python3 scripts/fix-wasm-paths.py
|
@python3 scripts/fix-wasm-paths.py
|
||||||
@echo "WASM paths fixed."
|
@echo "WASM paths fixed."
|
||||||
|
|||||||
@ -23,34 +23,34 @@ pub enum Route {
|
|||||||
Home {},
|
Home {},
|
||||||
#[route("/page/:page")]
|
#[route("/page/:page")]
|
||||||
HomePage { page: i32 },
|
HomePage { page: i32 },
|
||||||
#[route("/archives", wasm_split)]
|
#[route("/archives")]
|
||||||
Archives {},
|
Archives {},
|
||||||
#[route("/tags", wasm_split)]
|
#[route("/tags")]
|
||||||
Tags {},
|
Tags {},
|
||||||
#[route("/tags/:tag", wasm_split)]
|
#[route("/tags/:tag")]
|
||||||
TagDetail { tag: String },
|
TagDetail { tag: String },
|
||||||
#[route("/post/:slug")]
|
#[route("/post/:slug")]
|
||||||
PostDetail { slug: String },
|
PostDetail { slug: String },
|
||||||
#[route("/search", wasm_split)]
|
#[route("/search")]
|
||||||
Search {},
|
Search {},
|
||||||
#[route("/about", wasm_split)]
|
#[route("/about")]
|
||||||
About {},
|
About {},
|
||||||
#[end_layout]
|
#[end_layout]
|
||||||
|
|
||||||
#[nest("/admin")]
|
#[nest("/admin")]
|
||||||
#[layout(AdminLayout)]
|
#[layout(AdminLayout)]
|
||||||
#[route("/", wasm_split)]
|
#[route("/")]
|
||||||
Admin {},
|
Admin {},
|
||||||
#[route("/write", wasm_split)]
|
#[route("/write")]
|
||||||
Write {},
|
Write {},
|
||||||
#[route("/posts", wasm_split)]
|
#[route("/posts")]
|
||||||
Posts {},
|
Posts {},
|
||||||
#[end_layout]
|
#[end_layout]
|
||||||
#[end_nest]
|
#[end_nest]
|
||||||
|
|
||||||
#[route("/login", wasm_split)]
|
#[route("/login")]
|
||||||
Login {},
|
Login {},
|
||||||
#[route("/register", wasm_split)]
|
#[route("/register")]
|
||||||
Register {},
|
Register {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user