source: frontend/node_modules/webpack/hot/only-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: 3.0 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()
16 .then(function (updatedModules) {
17 if (!updatedModules) {
18 log("warning", "[HMR] Cannot find update. Need to do a full reload!");
19 log(
20 "warning",
21 "[HMR] (Probably because of restarting the webpack-dev-server)"
22 );
23 return;
24 }
25
26 return module.hot
27 .apply({
28 ignoreUnaccepted: true,
29 ignoreDeclined: true,
30 ignoreErrored: true,
31 onUnaccepted: function (data) {
32 log(
33 "warning",
34 "Ignored an update to unaccepted module " +
35 data.chain.join(" -> ")
36 );
37 },
38 onDeclined: function (data) {
39 log(
40 "warning",
41 "Ignored an update to declined module " +
42 data.chain.join(" -> ")
43 );
44 },
45 onErrored: function (data) {
46 log("error", data.error);
47 log(
48 "warning",
49 "Ignored an error while updating module " +
50 data.moduleId +
51 " (" +
52 data.type +
53 ")"
54 );
55 }
56 })
57 .then(function (renewedModules) {
58 if (!upToDate()) {
59 check();
60 }
61
62 require("./log-apply-result")(updatedModules, renewedModules);
63
64 if (upToDate()) {
65 log("info", "[HMR] App is up to date.");
66 }
67 });
68 })
69 .catch(function (err) {
70 var status = module.hot.status();
71 if (["abort", "fail"].indexOf(status) >= 0) {
72 log(
73 "warning",
74 "[HMR] Cannot check for update. Need to do a full reload!"
75 );
76 log("warning", "[HMR] " + log.formatError(err));
77 } else {
78 log("warning", "[HMR] Update check failed: " + log.formatError(err));
79 }
80 });
81 };
82 /** @type {EventTarget | NodeJS.EventEmitter} */
83 var hotEmitter = require("./emitter");
84 /**
85 * @param {CustomEvent<{ currentHash: string }>} event event or hash
86 */
87 var handler = function (event) {
88 lastHash = typeof event === "string" ? event : event.detail.currentHash;
89 if (!upToDate()) {
90 var status = module.hot.status();
91 if (status === "idle") {
92 log("info", "[HMR] Checking for updates on the server...");
93 check();
94 } else if (["abort", "fail"].indexOf(status) >= 0) {
95 log(
96 "warning",
97 "[HMR] Cannot apply update as a previous update " +
98 status +
99 "ed. Need to do a full reload!"
100 );
101 }
102 }
103 };
104
105 if (typeof EventTarget !== "undefined" && hotEmitter instanceof EventTarget) {
106 hotEmitter.addEventListener(
107 "webpackHotUpdate",
108 /** @type {EventListener} */
109 (handler)
110 );
111 } else {
112 hotEmitter.on("webpackHotUpdate", handler);
113 }
114
115 log("info", "[HMR] Waiting for update signal from WDS...");
116} else {
117 throw new Error("[HMR] Hot Module Replacement is disabled.");
118}
Note: See TracBrowser for help on using the repository browser.