Wasm splitting in yew
Description
Add a way to split the wasm bundle in multiple components. This modifies the build process, and uses relocation information emitted by llvm to identify where to "split". There's a bit of glue code in yew to ensure that messages sent to the lazy component are processed and properties are passed along without additional cloning.
The main part of the solution lives in https://github.com/WorldSEnder/wasm-split-prototype as of now. This was implemented in collaboration with the maintainer of leptos.
Checklist
- [x] I have reviewed my own code
- [x] I have added examples
The review pings are mostly because I think both of you will find this interesting, not necessarily as an invite to dig into the code and give meaningful suggestions for improvements (but feel free to if you have the time).
Benchmark - core
Yew Master
vnode fastest │ slowest │ median │ mean │ samples │ iters
╰─ vnode_clone 2.433 ns │ 2.548 ns │ 2.436 ns │ 2.439 ns │ 100 │ 1000000000
Pull Request
vnode fastest │ slowest │ median │ mean │ samples │ iters
╰─ vnode_clone 2.482 ns │ 2.645 ns │ 2.484 ns │ 2.489 ns │ 100 │ 1000000000
Benchmark - SSR
Yew Master
| Benchmark | Round | Min (ms) | Max (ms) | Mean (ms) | Standard Deviation |
|---|---|---|---|---|---|
| Baseline | 10 | 291.043 | 291.476 | 291.200 | 0.137 |
| Hello World | 10 | 493.135 | 503.324 | 496.541 | 3.407 |
| Function Router | 10 | 1623.159 | 1640.431 | 1628.389 | 5.161 |
| Concurrent Task | 10 | 1005.632 | 1006.962 | 1006.313 | 0.447 |
| Many Providers | 10 | 1121.940 | 1150.005 | 1131.421 | 8.492 |
Pull Request
| Benchmark | Round | Min (ms) | Max (ms) | Mean (ms) | Standard Deviation |
|---|---|---|---|---|---|
| Baseline | 10 | 310.426 | 310.973 | 310.812 | 0.184 |
| Hello World | 10 | 480.828 | 495.118 | 485.216 | 4.636 |
| Function Router | 10 | 1603.860 | 1627.602 | 1614.185 | 8.289 |
| Concurrent Task | 10 | 1005.786 | 1007.013 | 1006.487 | 0.420 |
| Many Providers | 10 | 1082.972 | 1143.054 | 1108.569 | 18.418 |
Visit the preview URL for this PR (updated for commit 3cf0e6e):
https://yew-rs-api--pr3932-split-wasm-8cld9gqn.web.app
(expires Wed, 29 Oct 2025 11:11:55 GMT)
🔥 via Firebase Hosting GitHub Action 🌎