koute / cargo-web

A Cargo subcommand for the client-side Web
Apache License 2.0
1.11k stars 80 forks source link

cargo web doesn't serve or deploy Emscripten .data files #254

Open KeyboardDanni opened 3 years ago

KeyboardDanni commented 3 years ago

When using --preload-file in the Emscripten target linker arguments, the toolchain will generate a file called crate-name.data containing the specified files to serve alongside the .js and .wasm files. However, cargo web doesn't seem to be aware of this as it only copies the .js and .wasm to the output directory, and the .data file is effectively missing when using cargo web start or cargo web deploy. The .data file is left within deps/ and while you can copy it into static/ as a workaround, it is easy to end up with a stale version of this file, which can cause problems if the generated .js file is newer than the .data file (since the .js file contains the offsets into the .data file for each virtual file).