| 
1 | 1 | var url = require('url');  | 
2 | 2 | var SockJS = require("sockjs-client");  | 
3 | 3 | var stripAnsi = require('strip-ansi');  | 
4 |  | -var scriptElements = document.getElementsByTagName("script");  | 
5 |  | -var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");  | 
6 |  | - | 
7 |  | -// If this bundle is inlined, use the resource query to get the correct url.  | 
8 |  | -// Else, get the url from the <script> this file was called with.  | 
9 |  | -var urlParts = url.parse(typeof __resourceQuery === "string" && __resourceQuery ?  | 
10 |  | -	__resourceQuery.substr(1) :  | 
11 |  | -	(scriptHost ? scriptHost : "/"), false, true  | 
12 |  | -);  | 
 | 4 | +var urlParts;  | 
 | 5 | +if (typeof __resourceQuery === "string" && __resourceQuery) {  | 
 | 6 | +	// If this bundle is inlined, use the resource query to get the correct url.  | 
 | 7 | +	urlParts = url.parse(__resourceQuery.substr(1));  | 
 | 8 | +} else {  | 
 | 9 | +	// Else, get the url from the <script> this file was called with.  | 
 | 10 | +	var scriptElements = document.getElementsByTagName("script");  | 
 | 11 | +	var scriptHost = scriptElements[scriptElements.length-1].getAttribute("src").replace(/\/[^\/]+$/, "");  | 
 | 12 | +	urlParts = url.parse((scriptHost ? scriptHost : "/"), false, true);  | 
 | 13 | +}  | 
13 | 14 | 
 
  | 
14 | 15 | var sock = null;  | 
15 | 16 | var hot = false;  | 
@@ -88,7 +89,12 @@ newConnection();  | 
88 | 89 | function reloadApp() {  | 
89 | 90 | 	if(hot) {  | 
90 | 91 | 		console.log("[WDS] App hot update...");  | 
91 |  | -		window.postMessage("webpackHotUpdate" + currentHash, "*");  | 
 | 92 | +		var hotEmitter = require("webpack/hot/emitter");  | 
 | 93 | +		hotEmitter.emit("webpackHotUpdate", currentHash);  | 
 | 94 | +		if(typeof window !== "undefined") {  | 
 | 95 | +			// broadcast update to window  | 
 | 96 | +			window.postMessage("webpackHotUpdate" + currentHash, "*");  | 
 | 97 | +		}  | 
92 | 98 | 	} else {  | 
93 | 99 | 		console.log("[WDS] App updated. Reloading...");  | 
94 | 100 | 		window.location.reload();  | 
 | 
0 commit comments