Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the WebAssembly story #14

Closed
ZoeyR opened this issue Aug 14, 2017 · 7 comments
Closed

Document the WebAssembly story #14

ZoeyR opened this issue Aug 14, 2017 · 7 comments

Comments

@ZoeyR
Copy link

ZoeyR commented Aug 14, 2017

As far as I can tell this library currently does not support wasm. But since Rust now supports wasm on stable it would be useful if documentation existed somewhere detailing this libraries future plans for supporting wasm, or if it already does and I missed that, there should be docs on how to use this library with wasm.

Edit: After fiddling a bit, I have determined that at the very least the todomvc example can run under wasm. This just means that it is unclear if wasm is actually supported or if this is something that is not guarenteed to work going forward.

@lilianmoraru
Copy link

I created a basic example of stdweb + wasm32: https://github.com/lilianmoraru/stdweb-alert-example

I did something wrong or the support is not great(stdweb or/and Rust + emscripten) but while trying to make todomvc to work, I had all kinds of missing symbols issues or things like that(even with the basic example sometimes - weird)...

@koute
Copy link
Owner

koute commented Nov 20, 2017

I created a basic example of stdweb + wasm32: https://github.com/lilianmoraru/stdweb-alert-example

I did something wrong or the support is not great(stdweb or/and Rust + emscripten) but while trying to make todomvc to work, I had all kinds of missing symbols issues or things like that(even with the basic example sometimes - weird)...

@lilianmoraru Yes, the way you're using it isn't really supported (yet).

Basically, Rust's Emscripten-based wasm target requires a hefty runtime which you can find in the .js file generated alongside the .wasm. That .js file already includes the code necessary to load the .js file, so right now you're supposed to just load that .js and it will fetch the .wasm by itself, not the other way around.

Rust is going to have a native wasm target where it'll only generate a standalone .wasm file; I'll add support for that (to both stdweb and cargo-web) once I'll be able to download a reasonably working toolchain through rustup.

@CryZe
Copy link

CryZe commented Nov 20, 2017

Is it even possible to support the new target without some help of the compiler, as I don‘t see how you could do the JavaScript literals without the emscripten API or the compiler support for it

@koute
Copy link
Owner

koute commented Nov 20, 2017

Currently it might not be, but I see no reason why we wouldn't be able to work something out. (I'll add it myself if I have to.)

@emosenkis
Copy link

I believe that wasm32-unknown-unknown is now available from rustup on nightly.

@lilianmoraru
Copy link

@emosenkis stweb wasm32-unknown-unknown does not currently work with it because it requires an event loop that is available only inside the emscripten environment.
wasm32-unknown-unknown is pretty basic right now, the std is mostly stubbed because compared to emscripten which offers File IO API for example(in RAM), this environment is basic, just wasm32.
If you want a crate to work under this target, the safest way is to not require std.

@koute
Copy link
Owner

koute commented Dec 16, 2017

Since WebAssembly is now supported on every target that Rust supports - closing!

@koute koute closed this as completed Dec 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants