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.78k stars 146 forks source link

Add WASI support for gloo-history. #405

Closed langyo closed 1 year ago

langyo commented 1 year 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 1 year 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.