aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack/hot
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/webpack/hot')
-rw-r--r--node_modules/webpack/hot/dev-server.js17
-rw-r--r--node_modules/webpack/hot/log-apply-result.js20
-rw-r--r--node_modules/webpack/hot/log.js44
-rw-r--r--node_modules/webpack/hot/only-dev-server.js26
-rw-r--r--node_modules/webpack/hot/poll.js11
-rw-r--r--node_modules/webpack/hot/signal.js19
6 files changed, 97 insertions, 40 deletions
diff --git a/node_modules/webpack/hot/dev-server.js b/node_modules/webpack/hot/dev-server.js
index da39afedd..95894674d 100644
--- a/node_modules/webpack/hot/dev-server.js
+++ b/node_modules/webpack/hot/dev-server.js
@@ -8,11 +8,12 @@ if(module.hot) {
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
+ var log = require("./log");
var check = function check() {
module.hot.check(true).then(function(updatedModules) {
if(!updatedModules) {
- console.warn("[HMR] Cannot find update. Need to do a full reload!");
- console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
+ log("warning", "[HMR] Cannot find update. Need to do a full reload!");
+ log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
window.location.reload();
return;
}
@@ -24,17 +25,17 @@ if(module.hot) {
require("./log-apply-result")(updatedModules, updatedModules);
if(upToDate()) {
- console.log("[HMR] App is up to date.");
+ log("info", "[HMR] App is up to date.");
}
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update. Need to do a full reload!");
- console.warn("[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] Cannot apply update. Need to do a full reload!");
+ log("warning", "[HMR] " + err.stack || err.message);
window.location.reload();
} else {
- console.warn("[HMR] Update failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
};
@@ -42,11 +43,11 @@ if(module.hot) {
hotEmitter.on("webpackHotUpdate", function(currentHash) {
lastHash = currentHash;
if(!upToDate() && module.hot.status() === "idle") {
- console.log("[HMR] Checking for updates on the server...");
+ log("info", "[HMR] Checking for updates on the server...");
check();
}
});
- console.log("[HMR] Waiting for update signal from WDS...");
+ log("info", "[HMR] Waiting for update signal from WDS...");
} else {
throw new Error("[HMR] Hot Module Replacement is disabled.");
}
diff --git a/node_modules/webpack/hot/log-apply-result.js b/node_modules/webpack/hot/log-apply-result.js
index 96c900b9f..8a312b3c6 100644
--- a/node_modules/webpack/hot/log-apply-result.js
+++ b/node_modules/webpack/hot/log-apply-result.js
@@ -6,25 +6,33 @@ module.exports = function(updatedModules, renewedModules) {
var unacceptedModules = updatedModules.filter(function(moduleId) {
return renewedModules && renewedModules.indexOf(moduleId) < 0;
});
+ var log = require("./log");
if(unacceptedModules.length > 0) {
- console.warn("[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
+ log("warning", "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
unacceptedModules.forEach(function(moduleId) {
- console.warn("[HMR] - " + moduleId);
+ log("warning", "[HMR] - " + moduleId);
});
}
if(!renewedModules || renewedModules.length === 0) {
- console.log("[HMR] Nothing hot updated.");
+ log("info", "[HMR] Nothing hot updated.");
} else {
- console.log("[HMR] Updated modules:");
+ log("info", "[HMR] Updated modules:");
renewedModules.forEach(function(moduleId) {
- console.log("[HMR] - " + moduleId);
+ if(typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
+ var parts = moduleId.split("!");
+ log.groupCollapsed("info", "[HMR] - " + parts.pop());
+ log("info", "[HMR] - " + moduleId);
+ log.groupEnd("info");
+ } else {
+ log("info", "[HMR] - " + moduleId);
+ }
});
var numberIds = renewedModules.every(function(moduleId) {
return typeof moduleId === "number";
});
if(numberIds)
- console.log("[HMR] Consider using the NamedModulesPlugin for module names.");
+ log("info", "[HMR] Consider using the NamedModulesPlugin for module names.");
}
};
diff --git a/node_modules/webpack/hot/log.js b/node_modules/webpack/hot/log.js
new file mode 100644
index 000000000..2ade0511d
--- /dev/null
+++ b/node_modules/webpack/hot/log.js
@@ -0,0 +1,44 @@
+var logLevel = "info";
+
+function dummy() {}
+
+function shouldLog(level) {
+ var shouldLog = (logLevel === "info" && level === "info") ||
+ (["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") ||
+ (["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error");
+ return shouldLog;
+}
+
+function logGroup(logFn) {
+ return function(level, msg) {
+ if(shouldLog(level)) {
+ logFn(msg);
+ }
+ };
+}
+
+module.exports = function(level, msg) {
+ if(shouldLog(level)) {
+ if(level === "info") {
+ console.log(msg);
+ } else if(level === "warning") {
+ console.warn(msg);
+ } else if(level === "error") {
+ console.error(msg);
+ }
+ }
+};
+
+var group = console.group || dummy;
+var groupCollapsed = console.groupCollapsed || dummy;
+var groupEnd = console.groupEnd || dummy;
+
+module.exports.group = logGroup(group);
+
+module.exports.groupCollapsed = logGroup(groupCollapsed);
+
+module.exports.groupEnd = logGroup(groupEnd);
+
+module.exports.setLogLevel = function(level) {
+ logLevel = level;
+};
diff --git a/node_modules/webpack/hot/only-dev-server.js b/node_modules/webpack/hot/only-dev-server.js
index 214f757f6..252df58fd 100644
--- a/node_modules/webpack/hot/only-dev-server.js
+++ b/node_modules/webpack/hot/only-dev-server.js
@@ -8,11 +8,12 @@ if(module.hot) {
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
+ var log = require("./log");
var check = function check() {
module.hot.check().then(function(updatedModules) {
if(!updatedModules) {
- console.warn("[HMR] Cannot find update. Need to do a full reload!");
- console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
+ log("warning", "[HMR] Cannot find update. Need to do a full reload!");
+ log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
return;
}
@@ -21,13 +22,14 @@ if(module.hot) {
ignoreDeclined: true,
ignoreErrored: true,
onUnaccepted: function(data) {
- console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
+ log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
},
onDeclined: function(data) {
- console.warn("Ignored an update to declined module " + data.chain.join(" -> "));
+ log("warning", "Ignored an update to declined module " + data.chain.join(" -> "));
},
onErrored: function(data) {
- console.warn("Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
+ log("error", data.error);
+ log("warning", "Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
}
}).then(function(renewedModules) {
if(!upToDate()) {
@@ -37,16 +39,16 @@ if(module.hot) {
require("./log-apply-result")(updatedModules, renewedModules);
if(upToDate()) {
- console.log("[HMR] App is up to date.");
+ log("info", "[HMR] App is up to date.");
}
});
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot check for update. Need to do a full reload!");
- console.warn("[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] Cannot check for update. Need to do a full reload!");
+ log("warning", "[HMR] " + err.stack || err.message);
} else {
- console.warn("[HMR] Update check failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update check failed: " + err.stack || err.message);
}
});
};
@@ -56,14 +58,14 @@ if(module.hot) {
if(!upToDate()) {
var status = module.hot.status();
if(status === "idle") {
- console.log("[HMR] Checking for updates on the server...");
+ log("info", "[HMR] Checking for updates on the server...");
check();
} else if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
+ log("warning", "[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
}
}
});
- console.log("[HMR] Waiting for update signal from WDS...");
+ log("info", "[HMR] Waiting for update signal from WDS...");
} else {
throw new Error("[HMR] Hot Module Replacement is disabled.");
}
diff --git a/node_modules/webpack/hot/poll.js b/node_modules/webpack/hot/poll.js
index a4bc7ccab..75e3a2b67 100644
--- a/node_modules/webpack/hot/poll.js
+++ b/node_modules/webpack/hot/poll.js
@@ -5,12 +5,13 @@
/*globals __resourceQuery */
if(module.hot) {
var hotPollInterval = +(__resourceQuery.substr(1)) || (10 * 60 * 1000);
+ var log = require("./log");
var checkForUpdate = function checkForUpdate(fromUpdate) {
if(module.hot.status() === "idle") {
module.hot.check(true).then(function(updatedModules) {
if(!updatedModules) {
- if(fromUpdate) console.log("[HMR] Update applied.");
+ if(fromUpdate) log("info", "[HMR] Update applied.");
return;
}
require("./log-apply-result")(updatedModules, updatedModules);
@@ -18,11 +19,11 @@ if(module.hot) {
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update.");
- console.warn("[HMR] " + err.stack || err.message);
- console.warn("[HMR] You need to restart the application!");
+ log("warning", "[HMR] Cannot apply update.");
+ log("warning", "[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] You need to restart the application!");
} else {
- console.warn("[HMR] Update failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
}
diff --git a/node_modules/webpack/hot/signal.js b/node_modules/webpack/hot/signal.js
index fffd35075..77ec94d4a 100644
--- a/node_modules/webpack/hot/signal.js
+++ b/node_modules/webpack/hot/signal.js
@@ -4,20 +4,21 @@
*/
/*globals __resourceQuery */
if(module.hot) {
+ var log = require("./log");
var checkForUpdate = function checkForUpdate(fromUpdate) {
module.hot.check().then(function(updatedModules) {
if(!updatedModules) {
if(fromUpdate)
- console.log("[HMR] Update applied.");
+ log("info", "[HMR] Update applied.");
else
- console.warn("[HMR] Cannot find update.");
+ log("warning", "[HMR] Cannot find update.");
return;
}
return module.hot.apply({
ignoreUnaccepted: true,
onUnaccepted: function(data) {
- console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
+ log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
},
}).then(function(renewedModules) {
require("./log-apply-result")(updatedModules, renewedModules);
@@ -27,19 +28,19 @@ if(module.hot) {
}).catch(function(err) {
var status = module.hot.status();
if(["abort", "fail"].indexOf(status) >= 0) {
- console.warn("[HMR] Cannot apply update.");
- console.warn("[HMR] " + err.stack || err.message);
- console.warn("[HMR] You need to restart the application!");
+ log("warning", "[HMR] Cannot apply update.");
+ log("warning", "[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] You need to restart the application!");
} else {
- console.warn("[HMR] Update failed: " + err.stack || err.message);
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
}
});
};
process.on(__resourceQuery.substr(1) || "SIGUSR2", function() {
if(module.hot.status() !== "idle") {
- console.warn("[HMR] Got signal but currently in " + module.hot.status() + " state.");
- console.warn("[HMR] Need to be in idle state to start hot update.");
+ log("warning", "[HMR] Got signal but currently in " + module.hot.status() + " state.");
+ log("warning", "[HMR] Need to be in idle state to start hot update.");
return;
}