webpack-dev-server 2.4.1 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client/index.js CHANGED
@@ -47,7 +47,7 @@ function log(level, msg) {
47
47
 
48
48
  // Send messages to the outside, so plugins can consume it.
49
49
  function sendMsg(type, data) {
50
- if(typeof self !== "undefined") {
50
+ if(typeof self !== "undefined" && self.window) {
51
51
  self.postMessage({
52
52
  type: "webpack" + type,
53
53
  data: data
@@ -157,12 +157,20 @@ var socketUrl = url.format({
157
157
 
158
158
  socket(socketUrl, onSocketMsg);
159
159
 
160
+ var isUnloading = false;
161
+ self.addEventListener("beforeunload", function() {
162
+ isUnloading = true;
163
+ });
164
+
160
165
  function reloadApp() {
166
+ if(isUnloading) {
167
+ return;
168
+ }
161
169
  if(hot) {
162
170
  log("info", "[WDS] App hot update...");
163
171
  var hotEmitter = require("webpack/hot/emitter");
164
172
  hotEmitter.emit("webpackHotUpdate", currentHash);
165
- if(typeof self !== "undefined") {
173
+ if(typeof self !== "undefined" && self.window) {
166
174
  // broadcast update to window
167
175
  self.postMessage("webpackHotUpdate" + currentHash, "*");
168
176
  }