Skip to content

Commit 6db1526

Browse files
committed
Merge branch 'master' into next
2 parents 60fd7fa + 4af8819 commit 6db1526

File tree

10 files changed

+70
-51
lines changed

10 files changed

+70
-51
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ cache:
1414
matrix:
1515
include:
1616
- os: linux
17-
node_js: "7"
17+
node_js: "8"
1818
env: NO_WATCH_TESTS=1 JOB_PART=lint
1919
- os: linux
20-
node_js: "7"
20+
node_js: "8"
2121
env: NO_WATCH_TESTS=1 JOB_PART=test
2222
- os: linux
2323
node_js: "6"

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ clone_depth: 50
1414
# what combinations to test
1515
environment:
1616
matrix:
17-
- nodejs_version: 7
17+
- nodejs_version: 8
1818
job_part: test
1919
- nodejs_version: 6
2020
job_part: test

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ machine:
88

99
dependencies:
1010
pre:
11-
- case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=4 ;; 1) NODE_VERSION=7 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION
11+
- case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=4 ;; 1) NODE_VERSION=8 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION
1212
override:
1313
- yarn
1414
- yarn link || true && yarn link webpack

hot/dev-server.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ if(module.hot) {
88
var upToDate = function upToDate() {
99
return lastHash.indexOf(__webpack_hash__) >= 0;
1010
};
11+
var log = require("./log");
1112
var check = function check() {
1213
module.hot.check(true).then(function(updatedModules) {
1314
if(!updatedModules) {
14-
console.warn("[HMR] Cannot find update. Need to do a full reload!");
15-
console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
15+
log("warning", "[HMR] Cannot find update. Need to do a full reload!");
16+
log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
1617
window.location.reload();
1718
return;
1819
}
@@ -24,29 +25,29 @@ if(module.hot) {
2425
require("./log-apply-result")(updatedModules, updatedModules);
2526

2627
if(upToDate()) {
27-
console.log("[HMR] App is up to date.");
28+
log("info", "[HMR] App is up to date.");
2829
}
2930

3031
}).catch(function(err) {
3132
var status = module.hot.status();
3233
if(["abort", "fail"].indexOf(status) >= 0) {
33-
console.warn("[HMR] Cannot apply update. Need to do a full reload!");
34-
console.warn("[HMR] " + err.stack || err.message);
34+
log("warning", "[HMR] Cannot apply update. Need to do a full reload!");
35+
log("warning", "[HMR] " + err.stack || err.message);
3536
window.location.reload();
3637
} else {
37-
console.warn("[HMR] Update failed: " + err.stack || err.message);
38+
log("warning", "[HMR] Update failed: " + err.stack || err.message);
3839
}
3940
});
4041
};
4142
var hotEmitter = require("./emitter");
4243
hotEmitter.on("webpackHotUpdate", function(currentHash) {
4344
lastHash = currentHash;
4445
if(!upToDate() && module.hot.status() === "idle") {
45-
console.log("[HMR] Checking for updates on the server...");
46+
log("info", "[HMR] Checking for updates on the server...");
4647
check();
4748
}
4849
});
49-
console.log("[HMR] Waiting for update signal from WDS...");
50+
log("info", "[HMR] Waiting for update signal from WDS...");
5051
} else {
5152
throw new Error("[HMR] Hot Module Replacement is disabled.");
5253
}

hot/log-apply-result.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,26 @@ module.exports = function(updatedModules, renewedModules) {
66
var unacceptedModules = updatedModules.filter(function(moduleId) {
77
return renewedModules && renewedModules.indexOf(moduleId) < 0;
88
});
9+
var log = require("./log");
910

1011
if(unacceptedModules.length > 0) {
11-
console.warn("[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
12+
log("warning", "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
1213
unacceptedModules.forEach(function(moduleId) {
13-
console.warn("[HMR] - " + moduleId);
14+
log("warning", "[HMR] - " + moduleId);
1415
});
1516
}
1617

1718
if(!renewedModules || renewedModules.length === 0) {
18-
console.log("[HMR] Nothing hot updated.");
19+
log("info", "[HMR] Nothing hot updated.");
1920
} else {
20-
console.log("[HMR] Updated modules:");
21+
log("info", "[HMR] Updated modules:");
2122
renewedModules.forEach(function(moduleId) {
22-
console.log("[HMR] - " + moduleId);
23+
log("info", "[HMR] - " + moduleId);
2324
});
2425
var numberIds = renewedModules.every(function(moduleId) {
2526
return typeof moduleId === "number";
2627
});
2728
if(numberIds)
28-
console.log("[HMR] Consider using the NamedModulesPlugin for module names.");
29+
log("info", "[HMR] Consider using the NamedModulesPlugin for module names.");
2930
}
3031
};

hot/log.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var logLevel = "info";
2+
3+
module.exports = function(level, msg) {
4+
if(logLevel === "info" && level === "info")
5+
return console.log(msg);
6+
if(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning")
7+
return console.warn(msg);
8+
if(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error")
9+
return console.error(msg);
10+
};
11+
12+
module.exports.setLogLevel = function(level) {
13+
logLevel = level;
14+
};

hot/only-dev-server.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ if(module.hot) {
88
var upToDate = function upToDate() {
99
return lastHash.indexOf(__webpack_hash__) >= 0;
1010
};
11+
var log = require("./log");
1112
var check = function check() {
1213
module.hot.check().then(function(updatedModules) {
1314
if(!updatedModules) {
14-
console.warn("[HMR] Cannot find update. Need to do a full reload!");
15-
console.warn("[HMR] (Probably because of restarting the webpack-dev-server)");
15+
log("warning", "[HMR] Cannot find update. Need to do a full reload!");
16+
log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
1617
return;
1718
}
1819

@@ -21,14 +22,14 @@ if(module.hot) {
2122
ignoreDeclined: true,
2223
ignoreErrored: true,
2324
onUnaccepted: function(data) {
24-
console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
25+
log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
2526
},
2627
onDeclined: function(data) {
27-
console.warn("Ignored an update to declined module " + data.chain.join(" -> "));
28+
log("warning", "Ignored an update to declined module " + data.chain.join(" -> "));
2829
},
2930
onErrored: function(data) {
30-
console.error(data.error);
31-
console.warn("Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
31+
log("error", data.error);
32+
log("warning", "Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
3233
}
3334
}).then(function(renewedModules) {
3435
if(!upToDate()) {
@@ -38,16 +39,16 @@ if(module.hot) {
3839
require("./log-apply-result")(updatedModules, renewedModules);
3940

4041
if(upToDate()) {
41-
console.log("[HMR] App is up to date.");
42+
log("info", "[HMR] App is up to date.");
4243
}
4344
});
4445
}).catch(function(err) {
4546
var status = module.hot.status();
4647
if(["abort", "fail"].indexOf(status) >= 0) {
47-
console.warn("[HMR] Cannot check for update. Need to do a full reload!");
48-
console.warn("[HMR] " + err.stack || err.message);
48+
log("warning", "[HMR] Cannot check for update. Need to do a full reload!");
49+
log("warning", "[HMR] " + err.stack || err.message);
4950
} else {
50-
console.warn("[HMR] Update check failed: " + err.stack || err.message);
51+
log("warning", "[HMR] Update check failed: " + err.stack || err.message);
5152
}
5253
});
5354
};
@@ -57,14 +58,14 @@ if(module.hot) {
5758
if(!upToDate()) {
5859
var status = module.hot.status();
5960
if(status === "idle") {
60-
console.log("[HMR] Checking for updates on the server...");
61+
log("info", "[HMR] Checking for updates on the server...");
6162
check();
6263
} else if(["abort", "fail"].indexOf(status) >= 0) {
63-
console.warn("[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
64+
log("warning", "[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
6465
}
6566
}
6667
});
67-
console.log("[HMR] Waiting for update signal from WDS...");
68+
log("info", "[HMR] Waiting for update signal from WDS...");
6869
} else {
6970
throw new Error("[HMR] Hot Module Replacement is disabled.");
7071
}

hot/poll.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,25 @@
55
/*globals __resourceQuery */
66
if(module.hot) {
77
var hotPollInterval = +(__resourceQuery.substr(1)) || (10 * 60 * 1000);
8+
var log = require("./log");
89

910
var checkForUpdate = function checkForUpdate(fromUpdate) {
1011
if(module.hot.status() === "idle") {
1112
module.hot.check(true).then(function(updatedModules) {
1213
if(!updatedModules) {
13-
if(fromUpdate) console.log("[HMR] Update applied.");
14+
if(fromUpdate) log("info", "[HMR] Update applied.");
1415
return;
1516
}
1617
require("./log-apply-result")(updatedModules, updatedModules);
1718
checkForUpdate(true);
1819
}).catch(function(err) {
1920
var status = module.hot.status();
2021
if(["abort", "fail"].indexOf(status) >= 0) {
21-
console.warn("[HMR] Cannot apply update.");
22-
console.warn("[HMR] " + err.stack || err.message);
23-
console.warn("[HMR] You need to restart the application!");
22+
log("warning", "[HMR] Cannot apply update.");
23+
log("warning", "[HMR] " + err.stack || err.message);
24+
log("warning", "[HMR] You need to restart the application!");
2425
} else {
25-
console.warn("[HMR] Update failed: " + err.stack || err.message);
26+
log("warning", "[HMR] Update failed: " + err.stack || err.message);
2627
}
2728
});
2829
}

hot/signal.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44
*/
55
/*globals __resourceQuery */
66
if(module.hot) {
7+
var log = require("./log");
78
var checkForUpdate = function checkForUpdate(fromUpdate) {
89
module.hot.check().then(function(updatedModules) {
910
if(!updatedModules) {
1011
if(fromUpdate)
11-
console.log("[HMR] Update applied.");
12+
log("info", "[HMR] Update applied.");
1213
else
13-
console.warn("[HMR] Cannot find update.");
14+
log("warning", "[HMR] Cannot find update.");
1415
return;
1516
}
1617

1718
return module.hot.apply({
1819
ignoreUnaccepted: true,
1920
onUnaccepted: function(data) {
20-
console.warn("Ignored an update to unaccepted module " + data.chain.join(" -> "));
21+
log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
2122
},
2223
}).then(function(renewedModules) {
2324
require("./log-apply-result")(updatedModules, renewedModules);
@@ -27,19 +28,19 @@ if(module.hot) {
2728
}).catch(function(err) {
2829
var status = module.hot.status();
2930
if(["abort", "fail"].indexOf(status) >= 0) {
30-
console.warn("[HMR] Cannot apply update.");
31-
console.warn("[HMR] " + err.stack || err.message);
32-
console.warn("[HMR] You need to restart the application!");
31+
log("warning", "[HMR] Cannot apply update.");
32+
log("warning", "[HMR] " + err.stack || err.message);
33+
log("warning", "[HMR] You need to restart the application!");
3334
} else {
34-
console.warn("[HMR] Update failed: " + err.stack || err.message);
35+
log("warning", "[HMR] Update failed: " + err.stack || err.message);
3536
}
3637
});
3738
};
3839

3940
process.on(__resourceQuery.substr(1) || "SIGUSR2", function() {
4041
if(module.hot.status() !== "idle") {
41-
console.warn("[HMR] Got signal but currently in " + module.hot.status() + " state.");
42-
console.warn("[HMR] Need to be in idle state to start hot update.");
42+
log("warning", "[HMR] Got signal but currently in " + module.hot.status() + " state.");
43+
log("warning", "[HMR] Need to be in idle state to start hot update.");
4344
return;
4445
}
4546

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +89,23 @@
8989
"schemas/"
9090
],
9191
"scripts": {
92-
"test": "mocha test/*.test.js --harmony --check-leaks",
92+
"test": "mocha test/*.test.js --max_old_space_size=4096 --harmony --check-leaks",
9393
"travis:test": "npm run cover:min",
9494
"travis:lint": "npm run lint-files && npm run nsp",
9595
"travis:benchmark": "npm run benchmark",
96-
"appveyor:test": "node --max_old_space_size=4096 node_modules\\mocha\\bin\\mocha --harmony test/*.test.js",
96+
"appveyor:test": "node node_modules\\mocha\\bin\\mocha --max_old_space_size=4096 --harmony test/*.test.js",
9797
"appveyor:benchmark": "npm run benchmark",
98-
"circleci:test": "node --max_old_space_size=4096 node_modules/mocha/bin/mocha --harmony test/*.test.js",
98+
"circleci:test": "node node_modules/mocha/bin/mocha --max_old_space_size=4096 --harmony test/*.test.js",
9999
"circleci:lint": "npm run lint-files && npm run nsp",
100100
"build:examples": "cd examples && node buildAll.js",
101101
"pretest": "npm run lint-files",
102102
"lint-files": "npm run lint && npm run beautify-lint",
103103
"lint": "eslint lib bin hot buildin \"test/**/webpack.config.js\" \"test/binCases/**/test.js\" \"examples/**/webpack.config.js\"",
104104
"beautify-lint": "beautify-lint \"lib/**/*.js\" \"hot/**/*.js\" \"bin/**/*.js\" \"benchmark/*.js\" \"test/*.js\"",
105105
"nsp": "nsp check --output summary",
106-
"benchmark": "mocha test/*.benchmark.js --harmony -R spec",
107-
"cover": "node --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js",
108-
"cover:min": "node --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' --report lcovonly node_modules/mocha/bin/_mocha -- test/*.test.js",
106+
"benchmark": "mocha --max_old_space_size=4096 --harmony test/*.benchmark.js -R spec",
107+
"cover": "node --max_old_space_size=4096 --harmony ./node_modules/istanbul/lib/cli.js cover -x '**/*.runtime.js' node_modules/mocha/bin/_mocha -- test/*.test.js",
108+
"cover:min": "node --max_old_space_size=4096 --harmony ./node_modules/.bin/istanbul cover -x '**/*.runtime.js' --report lcovonly node_modules/mocha/bin/_mocha -- test/*.test.js",
109109
"publish-patch": "npm run lint && npm run beautify-lint && mocha && npm version patch && git push && git push --tags && npm publish"
110110
}
111111
}

0 commit comments

Comments
 (0)