Skip to content

Commit 574026c

Browse files
fix: compatibility with event target and universal target and lazy compilation
1 parent c53955d commit 574026c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

client-src/index.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,22 @@ const reloadApp = ({ hot, liveReload }, currentStatus) => {
318318
if (hot && allowToHot) {
319319
log.info("App hot update...");
320320

321-
hotEmitter.emit("webpackHotUpdate", currentStatus.currentHash);
321+
if (
322+
typeof EventTarget !== "undefined" &&
323+
hotEmitter instanceof EventTarget
324+
) {
325+
const event = new CustomEvent("webpackHotUpdate", {
326+
detail: {
327+
currentHash: currentStatus.currentHash,
328+
},
329+
bubbles: true,
330+
cancelable: false,
331+
});
332+
333+
hotEmitter.dispatchEvent(event);
334+
} else {
335+
hotEmitter.emit("webpackHotUpdate", currentStatus.currentHash);
336+
}
322337

323338
if (typeof self !== "undefined" && self.window) {
324339
// broadcast update to window

0 commit comments

Comments
 (0)