Add WASI support for server-side rendering.#3534
Conversation
It would be modified later after the corresponding library branches are merged.
Benchmark - coreYew MasterPull Request |
|
Visit the preview URL for this PR (updated for commit 4a3b79f): https://yew-rs--pr3534-wasi-support-test-8w8rolp5.web.app (expires Mon, 02 Sep 2024 02:55:49 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Benchmark - SSRYew MasterDetails
Pull RequestDetails
|
Size ComparisonDetails
✅ None of the examples has changed their size significantly. |
…browser environment.
5cc0207 to
4a3b79f
Compare
ranile
left a comment
There was a problem hiding this comment.
Thanks so much for your patience. My apologies for how long it took to review
|
@WorldSEnder this is pending your review. If you're unable to review, I'll dismiss the previous (now-resolved) review and get this merged |
|
@langyo can you please undo the formatting changes your editor did in the meantime? I'll merge this PR on Monday if @WorldSEnder doesn't respond by then |
8d07370 to
6155846
Compare
6155846 to
cc486a4
Compare
Review already addressed, need to dismiss to merge PR
|
Merging this (finally!). Any changes needed can come in further PRs |
* Try to add wasi feature to avoid browser's ABI. * Add async render for single-threaded env. * Temporarily enable my own patch branch. It would be modified later after the corresponding library branches are merged. * add example for WASI SSR. * Ready to run WASI on wasmtime. * complete the example * fix fmt * fix fmt * I made a mistake..sry * add yew-router suites for demo * fix typo * Make the async render stream function public * Use target_os instead of feature. * Renew gloo-history's patch. * Exclude WASI example to avoid web-sys. * Try to add CI for WASI example. * Fix CI. * Fix CI that requires compiler 1.67 or newer. * Use CLI's flag instead of exclude example. bytecodealliance/wasmtime#4312 * Remove patchs. * Use LocalServerRenderer instead of ServerRenderer. yewstack/tokise#11 (comment) * Remove unused exports. * Add description about `LocalServerRenderer`. * fix fmt * fix fmt * Update Cargo.lock * Bump rust compiler's version to 1.67... * Exclude WASI on yew-router browser interfaces. * fix fmt * Wait for gloo's PR dealed. * Rollback to rust compiler 1.64. cc ranile/gloo#423 (comment) * Fix lock file. * Downgrade `toml_datetime` version. * Fix enum for `gloo-history`. * Well, it seems there is no way to avoid the MSRV upgrade.... * fix: Replace feature = "wasi" to target_os = "wasi". * Remove tips for rust version. * Bump `gloo` to 0.11. * Try to test yew-macro on compiler 1.67. * Try to use compiler 1.68 instead. * Try to use compiler 1.69 instead...... * Revert MSRV back * Pin the oldest Cargo.lock. * Downgrade deps for MSRV. * Bump benchmark tool's tokio to 1.35 * Try to write WASI CI. * Rollback the quotes * Combine CI files... * Rollback the use that gloo-history has fixed it. * fix * Bump gloo-history version. * Block raw html update tests on WASI. * Rollback indexmap's version. * fix CI * fix CI * Update some SSR test suites that replace ServerRender instead of LocalServerRender. * Remove yew-router's cfg macro * Fix fmt * Try to fix CI * Update examples/wasi_ssr_module/README.md Co-authored-by: Elina <imelina@elina.website> * Revert back some unnecessary changes. * Clippy * fmt * Fix CI. * Fix CI. * Try to fix clippy. * Fix `ToString` trait. * Remove pin version of WASI CI test. * Pin the newer version. * Fix typo. * Bump `wasm-bindgen`. * Fix SSR example. * Fix typo. * Try to support non-browser environments. * Update wasm-bindgen-test to 0.3.43 refer to wasm-bindgen/wasm-bindgen#4083 * fix doc test running on nightly * Update website/docs/advanced-topics/server-side-rendering.md Co-authored-by: WorldSEnder <WorldSEnder@users.noreply.github.com> * Update WASI CI. * Remove WASI test for rustc 1.76. * Try to let `wasmtime` CLI can be executed. * Limit the function `decode_base64` that it shouldn't runnable in non-browser environment. * Remove WASI example test for rustc 1.76. * Revert changes. * Fix CI * Fix Cargo.lock * Remove unused deps * Undo the formatting changes. * Undo the formatting changes. --------- Co-authored-by: Elina <imelina@elina.website> Co-authored-by: Martin Molzer <WorldSEnder@users.noreply.github.com>
Description
I've been trying to use
yewto render the page into the static HTML string on WASI. However,yewcannot distinguish the browser WASM target (wasm32-unknown-unknownwithwasm-bindgen) and WASI target (wasm32-wasi), and it would choose wrong modules forwasm32-*.In addition, since the current SSR implementation will create new tasks directly in the asynchronous context directly (based on
prokio). It only allowed in a multi-threaded environment that it is not compatible with WASI. So I added a dedicated one for a single-threaded environment that rendering function to support single-threaded scenes.To support this new feature, I have also made changes along with some other upstream dependencies. I've created some PRs for these upstream dependencies, and added a temporary patch entry to the root Cargo.toml for this PR. If the upstream branch can be processed, these temporary patch entries could be replaced.
I also wrote a short example for this new feature.
CC @futursolo 😉
Checklist