yewstack / yew

Rust / Wasm framework for creating reliable and efficient web applications
https://yew.rs
Apache License 2.0
30.5k stars 1.42k forks source link

Compile yew-macro to WebAssembly. #1264

Open teymour-aldridge opened 4 years ago

teymour-aldridge commented 4 years ago

Is your feature request related to a problem? Please describe. A way to speed up yew-macro's compilation time would be to compile it to WebAssembly, ship the WASM binaries with the crate and then run them.

Describe the solution you'd like I imagine that this would be achieved with dtonlay's watt library.

Describe alternatives you've considered This could initially be placed behind a feature flag.

Additional context I'd like to do this, just wondering whether it was something worth doing before writing any code!

teymour-aldridge commented 3 years ago

I've made a stab at this on this branch https://github.com/teymour-aldridge/yew/tree/watt

Xavientois commented 3 years ago

So, instead of the users of the crate compiling to their native target when they build the crate, it would be built ahead of time and just run when the user uses the macro crate?

Wouldn't that only improve performance the first time the crate would have been built? After that the natively compiled crate would be faster, no?

Maybe I'm just not understanding the impacts of this

teymour-aldridge commented 3 years ago

https://github.com/dtolnay/watt lays out more of the specifics. Generally the macro is compiled in release mode, so it's faster.

Xavientois commented 3 years ago

https://github.com/dtolnay/watt lays out more of the specifics. Generally the macro is compiled in release mode, so it's faster.

Would adding the following line to packages/yew/Cargo.toml achieve a similar effect?

[profile.dev.package.yew-macro]
opt-level = 3

Because its WASM, it will work on any machine?