webpack-hot-middleware icon indicating copy to clipboard operation
webpack-hot-middleware copied to clipboard

HMR stopped work after webpack upgrade from 3 to 4

Open Yizhachok opened this issue 6 years ago • 6 comments

HMR was broken for me after webpack upgrade from 3 to 4. Here small repo with reproduction of behaviour (I'v got [HMR] Nothing hot updated. message) https://github.com/Yizhachok/project-hmr

Here I have webpack configuration: https://github.com/Yizhachok/project-hmr/tree/master/dev/client/webpack Here I subscribe to HMR events: https://github.com/Yizhachok/project-hmr/blob/master/client/environments/environment.hmr.ts#L36 console.log('Here'); never fired

Yizhachok avatar Mar 24 '18 01:03 Yizhachok

Same here. I'm not able to make it work :(

TheMechanic avatar Apr 24 '18 13:04 TheMechanic

Also getting same error. Using with Express and webpack-dev-middleware. Here is the error I am receiving in the browser:

Uncaught ReferenceError: require is not defined
    at Object.webpack-hot-middleware/client (client":1)
    at __webpack_require__ (bootstrap:673)
    at fn (bootstrap:53)
    at Object.0 (client.js:802)
    at __webpack_require__ (bootstrap:673)
    at ./src/css/style.css (bootstrap:728)
    at bootstrap:728

Looks like something similar is occurring with Webpack Node Externals: https://github.com/liady/webpack-node-externals/issues/17

Here is a link to my code: https://github.com/bengrunfeld/app-engine-test-apps/blob/master/vanillajs-app/webpack.dev.config.js

Code is in webpack.dev.config.js

bengrunfeld avatar May 09 '18 05:05 bengrunfeld

whats the solution ??

farhanaslam5151 avatar Jul 22 '18 16:07 farhanaslam5151

if I inject "webpack-hot-middleware/client" to each entry, I got ReferenceError: installedChunks is not defined but if I inject a js file (hot-client.js):

var hotClient = require('webpack-hot-middleware/client' + __resourceQuery)
hotClient.subscribe(function (event) {
  if (event.action === 'reload') {
    window.location.reload()
  }
})

There was not error and page reloaded, but HMR does not work.

aztack avatar Oct 29 '18 15:10 aztack

Was this ever solved?

lampshaj avatar Jun 04 '19 16:06 lampshaj

Just wanted to mention that I got an error related to the "__resourceQuery" being empty for webpack-dev-server, and eventually realized it was due to an update in webpack-dev-server that makes it automatically require the "webpack-dev-server" module when you call new WebpackDevServer().

I don't have time to go into it all, but here is the commit where I solved my issue: https://github.com/Venryx/mobx-devtools-advanced/commit/d1fdb0dd37de9e5ffc5f720d920d45552f6a5803#diff-2c81437e455a833c25e31879ed05c465

A (brief) explanation of the change seems to be here: https://github.com/webpack/webpack-dev-server/issues/1802#issuecomment-484049451

Venryx avatar Nov 12 '19 06:11 Venryx

Closing due to inactivity. Please test with latest version and feel free to reopen if still regressions. Thanks!

alexander-akait avatar Nov 08 '22 17:11 alexander-akait