Open hydroper opened 1 year ago
I have the same issue too. I'm developing a project that will run within Internet Computer, which compiles in WASM, but not for browsers. I can not deploy anything that is using wasm-bindgen, web-sys, or js-sys.
IMO, wasm32
should be considered only as architecture and browser
the environment.
Another solution is to simply take a default feature wasmbind
, just like the chrono
crate! Then anyone can go ahead and put default-features = false
on the dependency and, if desired, use a conditional feature using features."reqwest/wasmbind"
It's a fair point, and I generally agree! I don't really have much personal use with any of the WASM environments, so we would need someone with such experience to help figure out how to make it work in other envs, while still working correctly in the browser (and hopefully keeping the exposed part in reqwest to a minimum, since if we have to change things we don't want to break people).
This library is very useful, but the way it detects the browser may be problematic if you need WebAssembly for another purpose other than the browser, such as futurely compiling Rust to wasm32 to anything else that isn't supported officially by
rustup
(such as Nintendo Switch, which uses a very specific chip by Nvidia).LLVM is harder to work with I think
In my case I'm planning to use two Cargo features for my generic graphical framework when running
rialight run
andrialight export
:rialight_default_export
: indicates that the target platform is multi-threaded and uses the Tokio asynchronous runtimerialight_browser_export
: indicates that the target platform is the browser and uses a thread-local asynchronous runtimeMy current plan is to wrap reqwest or hyper inside a called "network API". I wonder if there's a way to create two additional submodules into
reqwest
like these:reqwest::browser
(similiar toreqwest
, but used within the browser only)reqwest::tokio
(similiar toreqwest
, but used within Tokio only)So I'll be able to perform a
#[cfg(feature = "...")]
in my end by using these 2 modules instead.From Quora: