Conversation
|
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 - coreYew MasterPull Request |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
|
Visit the preview URL for this PR (updated for commit 26921f8): https://yew-rs-api--pr3932-split-wasm-ahe0tdp5.web.app (expires Tue, 24 Mar 2026 15:29:37 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
don't start fetching once per component, cache the vtable.
makes it possible to implement a helper macro without the user pulling in an extra dependency and has tighter version requirements.
Size ComparisonDetails
|
we accept the penalty of running a lot of lifecycle hooks twice: once for the Lazy<_> component, once for the inner one, and just forward messages and other things, instead of hacking around in Scope.
|
I want to say that having wasm split support would probably cut down the size of all these different bundles in the current "Yew.rs in Yew" push. |
Madoshakalaka
left a comment
There was a problem hiding this comment.
Looks really good now. I can't spot anything wrong.
can you suppress the warnings though?
➜ split-wasm git:(split-wasm) ✗ ./build.sh
/home/maa/.cache/trunk/wasm-bindgen-0.2.114/wasm-bindgen
warning: function `start_now` is never used
--> packages/yew/src/scheduler.rs:214:15
|
214 | pub(crate) fn start_now() {
| ^^^^^^^^^
|
= note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
warning: `yew` (lib) generated 1 warning
Finished `release` profile [optimized] target(s) in 0.11s
running wasm-bindgen
running wasm-opt
warning: unknown name subsection with id 3 at 25937
moving to dist dir
yeeaah It'd be nice if you could add some wasm-split docs in the mdx files too. It will take a while for the rewrite to land anyway. I'll sync the docs there. |
| #[cfg(any( | ||
| test, | ||
| feature = "test", | ||
| not(target_arch = "wasm32"), | ||
| target_os = "wasi", | ||
| feature = "not_browser_env" | ||
| ))] |
There was a problem hiding this comment.
I find this very unreadable. Unifying the entry points into the scheduler might make it more clear which target uses which loop.
The yield strategy in #4033 does not take the LOCK to prevent recursive re-entry, but duplicates code from here. This method is now basically only used in tests as a substitute for a sync flush (which should be fine). Nevertheless, I would try to clean this up in a follow up PR.
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