Open olanod opened 2 years ago
This would be amazing. Not only for lazy loading components, but also hot swapping components that changed, and faster incremental builds. This could also open the door to bindings in other languages like go and assembly script.
I've been looking into this in the past few days. Here's what I found:
There are some downsides to dynamically linking mainly no optimization across the framework<->component boundary which would result in less optimized and larger binaries.
The wit-bindgen option is probably the best way :) A almost a year later and WebAssembly components are still a work in progress but it might be in a state where it's ok to try things out. The jco tool for example is a way to bridge the current compatibility gap and run the Rust component as JS but more future proof because if support (ever) lands natively in the browser the WASM component doesn't have to change. When running Dioxus natively we could also look into using a wasmtime or wasmer to run the components at near native speeds.
The wit-bindgen option is probably the best way :) A almost a year later and WebAssembly components are still a work in progress but it might be in a state where it's ok to try things out. The jco tool for example is a way to bridge the current compatibility gap and run the Rust component as JS but more future proof because if support (ever) lands natively in the browser the WASM component doesn't have to change. When running Dioxus natively we could also look into using a wasmtime or wasmer to run the components at near native speeds.
I have been planning to integrate this into Floneum to let components define their own UI. It uses wit bindgen. I'll try to remember to post here when I get that working, but I imagine it will work much like the liveview renderer today
I'm building an app where users can install "applets" that are pieces of UI built by third-parties, we are thinking of distributing them as WASM blobs as we can bundle not only data but logic in a compact format.
It would be great to find a way to create components as crates that can be compiled to a minimal WASM and be loaded dynamically by the main application that understands the WASM interface exposed by the component and can communicate with it in an efficient way.
I haven't digged much into the internals of dioxus so it would be nice to hear thoughts and comments about its feasibility :)