webpack-hot-client
webpack-hot-client copied to clipboard
Entry as an object-of-arrays-of-strings does not work
- Operating System: macOS High Sierra
- Node Version: 10.7.0
- NPM Version: Yarn 1.7.0
- webpack Version: 4.16.2
- webpack-hot-client Version: 4.1.1
Expected Behavior
When entry is configured as described in the README:
..., or an
Object
who's keys are set to anArray
ofString
.
HMR should detect and handle updates correctly.
Actual Behavior
HMR does not function as expected. Updates are shown in the console, but always show "No Modules Updated". Sample console log:
「hot」 Hot Module Replacement Enabled. Waiting for signal.
「hot」 WebSocket connected
「hot」 App updated. Recompiling src/style.scss
「hot」 webpack: Compiling (<unnamed compiler>)
「hot」 App Updated, Reloading Modules
「hot」 Checking for updates to the bundle.
「hot」 No Modules Updated.
「hot」 App is up to date.
In addition, this seems to prevent fallback to full-page reload from working. A manual reload is required to pick up the changes.
Code
Webpack config: https://gist.github.com/ezzatron/bb4f0609e513d75fd98d070b99fe83c2#file-webpack-config-js
How Do We Reproduce?
- Clone https://github.com/ezzatron/webpack-experiments
- Checkout the
webpack-hot-client-issue
branch - Run
make run
- Open http://localhost:8080/
- Edit
src/style.scss
, change the color value - Observe that the update is not picked up until the page is manually reloaded
I have since "fixed" the issue on the master branch of that same repo, but it required me to use a simple array-of-strings entry configuration, which has flow-on effects for my chunk splitting configuration, which was using the entrypoint name as a way to differentiate chunks.
Did you miss https://github.com/webpack-contrib/webpack-hot-client#allentries ?
@shellscape I wasn't setting that option, no. But I've just tried it, and it doesn't seem to make a difference unfortunately. I'm using webpack-serve
's config to set it, so I double checked that the setting was actually making its way to webpack-hot-client
with some console logging, and it's definitely receiving the setting.
I've also updated the example repo with allEntries: true
if that helps.
Welp, beyond that, happy to review a PR that resolves this condition.
I've been doing some digging on this issue. I found that HMR does seem to be working, but for the first endpoint only.
I can "fix" the issue, by hacking in these two fixes:
- Remove the check for
window.__webpackHotClient__
as mentioned in this comment in #93 - Remove the check for
server.clients.size === 1
in the server (similar to #96)
But based on the comments in #96, I understand that this would introduce a regression.
Am I right in assuming that:
- The client needs to run an instance for every entrypoint
- Multiple clients can't currently share a websocket, but they probably should
- The problem space is complicated by iframes (i.e. #61)
/cc @shellscape Maybe you'll all think about not merge PRs without tests in the future? Now webpack-hot-client
is broken with multiple entry points and watch content and you ignore my PR to revert incorrect fix.
Also, you ignore other people's opinions and discussions about solving problems and many features, this violates code of coduct. If you continue to communicate in this style, I'll file a complaint.
+1 on not getting HMR on anything but the first listed entry, also discussed on webpack-serve:
https://github.com/webpack-contrib/webpack-serve/issues/119#issuecomment-412071796
but I guess this is the correct place if @ezzatron verified the allEntries setting being passed correctly.