webpack / webpack-dev-server

Serves a webpack app. Updates the browser on changes. Documentation https://webpack.js.org/configuration/dev-server/.
MIT License
7.8k stars 1.44k forks source link

HMR not updating modules (WP4) #1367

Closed dlmiles closed 6 years ago

dlmiles commented 6 years ago

https://github.com/webpack/webpack-dev-server/blob/3d3d912a69aadc8c5f0c92119dd25100338acd8f/client-src/default/index.js#L219 This looks the wrong format.

The correct format maybe: self.postMessage({type:'webpackHotUpdate',hash:currentHash}, '*'); This copies the sendMsg() function way of doing it. This can be seen here: https://github.com/webpack/webpack-dev-server/blob/3d3d912a69aadc8c5f0c92119dd25100338acd8f/client-src/default/index.js#L67-L70

... ALSO ...

https://github.com/webpack/webpack-dev-server/blob/3d3d912a69aadc8c5f0c92119dd25100338acd8f/lib/Server.js#L673 stats.hash is always undefined for me

I change at https://github.com/webpack/webpack-dev-server/blob/3d3d912a69aadc8c5f0c92119dd25100338acd8f/lib/Server.js#L74 this._sendStats(this.sockets, this._buildStats(stats, clientStats));

I change at https://github.com/webpack/webpack-dev-server/blob/3d3d912a69aadc8c5f0c92119dd25100338acd8f/lib/Server.js#L610 this._sendStats([conn], this._buildStats(this._stats, clientStats), true);

I add new method at https://github.com/webpack/webpack-dev-server/blob/3d3d912a69aadc8c5f0c92119dd25100338acd8f/lib/Server.js#L676

Server.prototype._buildStats = function(stats, clientStats) { var o = stats.toJson(clientStats); if(stats.hash) o.hash = stats.hash; return o; };

... I THINK THE 2 THINGS TOGETHER STOP "[HMR] Updated modules: ..." from working

"webpack": "^4.5.0", "webpack-dev-server": "^3.1.2"

SpaceK33z commented 6 years ago

This was fixed in v3.1.3.