rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.81k stars 1.08k forks source link

Development server #2359

Open MarcAntoine-Arnaud opened 3 years ago

MarcAntoine-Arnaud commented 3 years ago

Motivation

Wasm-bindgen provide all requirements to generate Wasm application. Including the startup with the #[wasm_bindgen(start)] attribute. It miss a very little portion of code to:

Today, it requires an external tool, hot reloading is not provided etc. It can be with WebPack: Paint example Or using the wasm-bindgen-cli GFX example

One of the paint/complex work is to manage cross target libraries. For example the Quad example from GFX is a main as it can run on all platforms. But the same code can also run for Web with WebAssembly. I have tried to manage that in that issue: https://github.com/gfx-rs/gfx/pull/3475 It works using 2 Cargo manifests, requires to duplicate dependencies and do some tricks.

Proposed Solution

Improve the CLI crate to add a mode to serve the application. maybe to provide a command like: wasm-bindgen --server Or maybe add a server target.

alexcrichton commented 3 years ago

Thanks for the report! This is something I'd be happy to help design and take a PR for, but I don't really know of a great design or how it would fit into wasm-bindgen myself. There's already basically a server for wasm-bindgen-test so that can probably be reused.

This would be a great feature to have though!

MarcAntoine-Arnaud commented 3 years ago

Hello,

I wanna to work on it, @alexcrichton do you have some advices ? Do you have idea what I need to check first ?

For me it means:

Thank you, Marc-Antoine

alexcrichton commented 3 years ago

Yeah that's the rough shape of ideally what this would look like. I think it'd be good though to make a proposal for the interface for this and how it's expected to be used, though.