-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
Webpack 4.10.x hot module reloading breaks with dynamic imports #7477
Comments
Thanks for your report. It would be great if you reduce your issue to a small reproducible example. Best put this example into a github repository together with instructions how to get to the problem. |
I'll see what I can put together from our current setup, and provide a repo. Thanks @sokra 👍 |
@sokra I've put together a test repo here, reducing it as much as I could: The Readme documents two helpful scripts to run (to install 4.9.2 or 4.10.2 depending on if you want to test it working or in a broken state), as well as which components to change to see things work (or not). Please let me know if I can help with any further diagnosis... Edit: And this is where it broke: |
Thanks for the great repro repo. It made it easy to find the problem. |
Bug report
What is the current behavior?
Hot module reloading does not work for dynamic imports, as of Webpack 4.10.0
If the current behavior is a bug, please provide the steps to reproduce.
I'm using https://github.com/smooth-code/loadable-components with React to do hot module reloading during development. Using Webpack 4.9.2 (or below), hot module reloading works with dynamic imports. Webpack 4.10.x (tested 4.10.0, 4.10.1 and 4.10.2) breaks this functionality and returns the "couldn't update the module, full reload needed" message.
It's a tricky one to isolate, as there's a lot of moving pieces including server-side rendering. However, I have been able to narrow it down to just the Webpack minor version change.
I've tried the
loadable-components
own provided example from their repo with an upgraded Webpack and it does seem to handle updates, but perhaps is implemented a bit differently.What is the expected behavior?
Dynamic imports should work with HMR. Something between 4.9.x and 4.10.x seems to have changed which has resulted in this now failing.
4.9.2 shows this in the console:
4.10.2 is less happy:
I've compared the XHR updates and the JS being generated; in both cases it appears to be identical between 4.9.2 and 4.10.2.
However, it's important to note that this is only an issue with dynamic
import()
HMR -- synchronous compile-time imports likeimport SomeComponent from 'some-component'
will hot-reload just fine in both 4.9.2 and 4.10.2 (with the hot-loader sitting at the top route level in both cases).I'm certainly not familiar with the Webpack code, but looking at v4.9.2...v4.10.0 there does seem to be a lot of changes that affect how requires are being handled... maybe something there has affected things?
Other relevant information:
webpack version: 4.10.2
Node.js version: 9.11.1
Operating System: MacOS 10.13.3
Additional tools:
The text was updated successfully, but these errors were encountered: