Test case: https://github.com/rustwasm/wasm_game_of_life/tree/d1d20e6b8ffe9f63e8a058055d5696ede0a41927
Modifying the .wasm triggers a refresh of the page with the new .wasm modifications reflected, just like modifying JS files does.
The .wasm seems to be too aggressively cached by webpack-dev-server, and changes to it are not reflected on the page unless the server is restarted.
(Note: I verified that disabling the network cache in the browser results in fresh 200 requests for the .wasm but that the response payload is not the modified .wasm on disk, ergo this bug is not the browser's network cache acting up.)
Install the rust toolchain so you can modify and recompile the .wasm, as described in https://rust-lang-nursery.github.io/rust-wasm/game-of-life/setup.html
cd wasm_game_of_life
npm install
npm run serve in a new terminal, so it will keep running
verify that the game of life is working at http://localhost:8080
In src/lib.rs, find the pub fn new() -> Universe method. Replace its body with panic!():
pub fn new() -> Universe {
panic!()
}
npm run build-debug to rebuild the .wasm with the panic changes
refresh http://localhost:8080 -- it should not have a working game of life anymore, and there should be an error in the console from the panic. If it is still working, then that means the new .wasm was not loaded.
For a slightly more self-contained reprodution:
cd into checkout directorynpm installcp add1.wasm add.wasmnpm run servenpm run serve is still running), execute cp add2.wasm add.wasmwebpack-dev-server rebuilds... something?npm run serveJust ran into this too. If someone can point me to the relevant module(s) for webpack I can take a look.
I think this is an issue in webpack itself rather than webpack-dev-server.
Steps to reproduce without using dev server:
package.json and add this to scripts: "build": "webpack"cp add1.wasm add.wasmnpm run build - shows 8272f8059cff031ea68e.module.wasm in bundlegit grep --untracked '{"./add.wasm":' dist/ - shows 8272f8059cff031ea68e in bundlecp add2.wasm add.wasmnpm run build - shows 767437f29c6ec784dbb9.module.wasm in bundlegit grep --untracked '{"./add.wasm":' dist/ - shows 767437f29c6ec784dbb9 in bundlenpm run build -- --watch and leave it runningcp add1.wasm add.wasm - shows 8272f8059cff031ea68e.module.wasm in bundle git grep --untracked '{"./add.wasm":' dist/ - shows 767437f29c6ec784dbb9 in bundle@glenjamin Nice catch.
cc: @xtuc & @sokra do you guys have any idea about this?
I don't know how works the caching strategy in Webpack. Maybe it can not compare binary files?
This is fixed in the "next" branch in webpack/webpack. We are working on upgrading the WASM pipeline and will merge this to master in a few days.
Awesome, thanks so much @sokra!
@xtuc whether the other issue fixes (which we were discussing) landed in next already ?
I can confirm this is now fixed on Webpack 4.8
Nice!
Looks like we can close issue! Please upgrade to webpack4.8. If problem still exists after upgrade feel free reopen :+1: