Skip to content

Commit db47209

Browse files
fix: initial reloading for lazy compilation
1 parent f1fdaa7 commit db47209

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

client-src/index.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* global __resourceQuery */
1+
/* global __resourceQuery, __webpack_hash__ */
22

33
import webpackHotLog from "webpack/hot/log.js";
44
import stripAnsi from "./modules/strip-ansi/index.js";
@@ -10,11 +10,10 @@ import sendMessage from "./utils/sendMessage.js";
1010
import reloadApp from "./utils/reloadApp.js";
1111
import createSocketURL from "./utils/createSocketURL.js";
1212

13-
const status = { isUnloading: false, currentHash: "" };
13+
const status = { isUnloading: false, currentHash: __webpack_hash__ };
1414
const options = {
1515
hot: false,
1616
liveReload: false,
17-
initial: true,
1817
progress: false,
1918
overlay: false,
2019
};
@@ -110,10 +109,6 @@ const onSocketMessage = {
110109
hide();
111110
}
112111

113-
if (options.initial) {
114-
return (options.initial = false);
115-
}
116-
117112
reloadApp(options, status);
118113
},
119114
// TODO: remove in v5 in favor of 'static-changed'
@@ -157,10 +152,6 @@ const onSocketMessage = {
157152
show(warnings, "warnings");
158153
}
159154

160-
if (options.initial) {
161-
return (options.initial = false);
162-
}
163-
164155
reloadApp(options, status);
165156
},
166157
errors(errors) {
@@ -184,8 +175,6 @@ const onSocketMessage = {
184175
if (needShowOverlay) {
185176
show(errors, "errors");
186177
}
187-
188-
options.initial = false;
189178
},
190179
error(error) {
191180
log.error(error);

client-src/utils/reloadApp.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global __webpack_hash__ */
2+
13
import hotEmitter from "webpack/hot/emitter.js";
24
import { log } from "./log.js";
35

@@ -6,6 +8,12 @@ function reloadApp({ hot, liveReload }, { isUnloading, currentHash }) {
68
return;
79
}
810

11+
const isInitial = currentHash.indexOf(__webpack_hash__) === 0;
12+
13+
if (isInitial) {
14+
return;
15+
}
16+
917
function applyReload(rootWindow, intervalId) {
1018
clearInterval(intervalId);
1119

0 commit comments

Comments
 (0)