source: frontend/node_modules/webpack/hot/dev-server.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5/* globals __webpack_hash__ */
6if (module.hot) {
7 /** @type {undefined|string} */
8 var lastHash;
9 var upToDate = function upToDate() {
10 return /** @type {string} */ (lastHash).indexOf(__webpack_hash__) >= 0;
11 };
12 var log = require("./log");
13 var check = function check() {
14 module.hot
15 .check(true)
16 .then(function (updatedModules) {
17 if (!updatedModules) {
18 log(
19 "warning",
20 "[HMR] Cannot find update. " +
21 (typeof window !== "undefined"
22 ? "Need to do a full reload!"
23 : "Please reload manually!")
24 );
25 log(
26 "warning",
27 "[HMR] (Probably because of restarting the webpack-dev-server)"
28 );
29 if (typeof window !== "undefined") {
30 window.location.reload();
31 }
32 return;
33 }
34
35 if (!upToDate()) {
36 check();
37 }
38
39 require("./log-apply-result")(updatedModules, updatedModules);
40
41 if (upToDate()) {
42 log("info", "[HMR] App is up to date.");
43 }
44 })
45 .catch(function (err) {
46 var status = module.hot.status();
47 if (["abort", "fail"].indexOf(status) >= 0) {
48 log(
49 "warning",
50 "[HMR] Cannot apply update. " +
51 (typeof window !== "undefined"
52 ? "Need to do a full reload!"
53 : "Please reload manually!")
54 );
55 log("warning", "[HMR] " + log.formatError(err));
56 if (typeof window !== "undefined") {
57 window.location.reload();
58 }
59 } else {
60 log("warning", "[HMR] Update failed: " + log.formatError(err));
61 }
62 });
63 };
64 /** @type {EventTarget | NodeJS.EventEmitter} */
65 var hotEmitter = require("./emitter");
66 /**
67 * @param {CustomEvent<{ currentHash: string }>} event event or hash
68 */
69 var handler = function (event) {
70 lastHash = typeof event === "string" ? event : event.detail.currentHash;
71 if (!upToDate() && module.hot.status() === "idle") {
72 log("info", "[HMR] Checking for updates on the server...");
73 check();
74 }
75 };
76
77 if (typeof EventTarget !== "undefined" && hotEmitter instanceof EventTarget) {
78 hotEmitter.addEventListener(
79 "webpackHotUpdate",
80 /** @type {EventListener} */
81 (handler)
82 );
83 } else {
84 hotEmitter.on("webpackHotUpdate", handler);
85 }
86
87 log("info", "[HMR] Waiting for update signal from WDS...");
88} else {
89 throw new Error("[HMR] Hot Module Replacement is disabled.");
90}
Note: See TracBrowser for help on using the repository browser.