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"
|
||||
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",
|
||||
|
||||
@ -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 }
|
||||
|
||||
2
Makefile
2
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."
|
||||
|
||||
@ -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 {},
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user