rustwasm / gloo

A modular toolkit for building fast, reliable Web applications and libraries with Rust and WASM
https://gloo-rs.web.app
Apache License 2.0
1.76k stars 146 forks source link

Add WASI support for gloo-history. #405

Closed langyo closed 10 months ago

langyo commented 10 months ago

I've been trying to use yew to render the page into the static HTML string on WASI. However, gloo-history cannot distinguish the browser WASM target (wasm32-unknown-unknown with wasm-bindgen) and WASI target (wasm32-wasi), and it would choose wrong functions for wasm32-*.

I have fixed it by using target_os, and it would fix the problem.

langyo commented 10 months ago

Can you make it use cfg(target_os = "wasi") instead of a feature image

That should make the wasi feature unnecessary and handle the compilation accordingly. Other than that, it looks good.

It would be great if you could also update CI to run tests on WASI target (using wasmtime) though

It's so new that when I looked through the documentation, it didn't even mention that the value of target_os can be wasi...

I tested it on the latest stable compiler and it works. I'll push the modified version later.