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

[Question] Wasm / Node.js support #530

Closed
codetheweb opened this issue Oct 11, 2020 · 2 comments
Closed

[Question] Wasm / Node.js support #530

codetheweb opened this issue Oct 11, 2020 · 2 comments

Comments

@codetheweb
Copy link

I'm new to Rust, and I was wondering how hard it would be to compile this into WebAssembly for usage with Node.js / browsers. I tried briefly using wasm-pack build (after adding crate-type = ["cdylib"] to Cargo.toml) and it just spit out a bunch of errors. I'm not experience enough to know whether this is relatively easy with a little bit more configuration or if it would require rewriting code.

Any feedback / help is appreciated.

@codetheweb
Copy link
Author

After some more investigation, it seems that the main blocker on this is the fact that raw TCP sockets are used (which are supported in Node.js but not the browser).

If you want to run it in a browser, it might be possible to use Emcripten which polyfills sockets to web sockets. You'd also then need something like websockify on a server.

In theory it should be possible to run on Node.js using network calls from WASI but I'm not sure if WASM compilers work with that yet. This is a very rapidly changing space.

So TL;DR is that if you want Node.js support it looks like it might be easiest to just re-implement in JS.

@schickling
Copy link

Thanks for sharing your investigations @codetheweb.

Looks like there's some ongoing work on bringing socket support to Wasi.

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

2 participants