-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The bundle is not recreated by webpack after source files change. #125
Comments
Can you try to add this ↓ too Webpack config? Will you check to see if that helps solve the problem?
I had the same problem. After investigating it, it turned out that webpack does not correctly detect changes when files in the pkg folder are created and deleted. If you add timeout, it works correctly. I haven't figured out exactly where the problem is, but it seems to be in the watchpack library. The code there is very tricky. |
i can confirm webpack v5 dev server doesn't notice changes after rebuild by wasm-pack v0.10.2 using webpack's polling watch option fixes it for me too. |
@SonyStone I can confirm that adding the config you mention solve the problem for me. Thank you! |
I was able to trace it a little further. It seems that watchpack is receiving a "rename" event for the files wasm-pack creates. This rename event is handled by: This And I believe that this is the reason it works well for the first 2 builds, as noted here: rustwasm/rust-webpack-template#180 If I believe this is most likely a A workaround I am using is to clean the pkg directory before build:
Also webpack.config.js: watchOptions: {
aggregateTimeout: 500
// poll: 200, is not necessary as long as you remove pkg/* before building your wasm files
} |
🐛 Bug description
The browser failed to reload after changing the source when using this plugin with
webpack-dev-server
. This only happens when using wasm-pack with version0.10.x
, but not0.9.x
(and the version ofwasm-pack-plugin
does not seems to affect the bug). See rustwasm/rust-webpack-template#180.🤔 Expected Behavior
When using
webpack-dev-server
withwasm-pack-plugin
, after the source files change andwasm-pack
recompiled the wasm file, the bundle should be recreated and the browser should reload.👟 Steps to reproduce
npm init rust-webpack my-app
to clone the template.cd my-app
and thennpm start
to start the dev server.src/lib.rs
, for example, duplicate the lineconsole::log_1(...)
. The browser will reload and we could seeHello world!
get print twice in the console.src/lib.rs
, for example, duplicate the lineconsole::log_1(...)
again.npm start
does not show the wasm file being rebundled and the browser does not reload.wasm-pack: "0.9.1"
indepDependencies
in thepackage.json
and webpack starts to reload browser when source files change.🌍 Your environment
wasm-pack version:
wasm-pack 0.10.2
rustc version:
rustc 1.56.1 (59eed8a2a 2021-11-01)
The text was updated successfully, but these errors were encountered: