Rust And WebAssembly - 8 part series

2 Likes

I feel like a lot of tutorials skim over the requirements for a good http server to test your code. You cannot 'just' do $ py -3 -m http.server because you need at least;

  • a secure connection
  • a server that provides the correct mime-type for the webassembly file

In my experience finding an easy tool for this is hard, due to transparency and discoverability problems.
I'm not affiliated with the crate, but i found this one very easy to use; https://crates.io/crates/https

Another thing i'd mention is to use host lvh.me if localhost or 127.0.0.1 causes issues. Ofcourse, you need to provide the https protocol and proper port number to reach your dev server.

If you are just testing in localhost, you do not need any secure connection and mime type. I agree this was a concern before but not anymore. (I can see it working at least in my mac in all 4 major browsers)

I'd also add "reload on recompile" to the list of requirements. fwiw I just use the JS solutions - so browsersync (for vanilla js) or webpack dev server (for typescript that'll need bundling anyway)

The other article in the series are infact using webpack for automatic reloading and compilation. Haven't added typescript support but it is straight forward.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.