wasm-pack icon indicating copy to clipboard operation
wasm-pack copied to clipboard

[DRAFT] add support for wasm32-unknown-emscripten

Open walkingeyerobot opened this issue 1 year ago • 1 comments

This is an early draft PR for the purposes of gathering feedback early. There are also pending changes to wasm-bindgen and Emscripten. This is for issue #1468.

This PR does a few things:

  1. Removes hard coded references to wasm32-unknown-unknown, instead reading .cargo/config.toml to determine what the target triple is. If this file isn't present or a triple isn't specified, wasm32-unknown-unknown is used as the default.
  2. When targeting -emscripten, run the wasm-bindgen install step before building. This makes sure it's available for Emscripten during link time.

TODOs:

  1. Change the -o argument being passed to Emscripten. The default way this is set up passes a full filename ending in .wasm, which causes Emscripten to not even attempt to emit JS. This might need a change to rustc.
  2. Once -o is taken care of, actually copy the final files to pkg.
  3. After wasm-bindgen is installed, ensure Emscripten can find it. Emscripten is currently reading the location from its own config file, but we might want to set up an environment variable or something to make sure it's using the copy installed by wasm-pack.

walkingeyerobot avatar Jan 25 '25 22:01 walkingeyerobot

I'll also note that some of the infrastructure here will be useful for adding wasm64 support per #1464

walkingeyerobot avatar Jan 26 '25 20:01 walkingeyerobot