Skip to content

Commit 7905bf5

Browse files
committed
Warnings and Errors contribute to hash
1 parent f7bcba7 commit 7905bf5

9 files changed

Lines changed: 43 additions & 2 deletions

File tree

‎lib/Compilation.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,17 @@ class Compilation extends Tapable {
11031103
for(let indexChunk = 0; indexChunk < chunks.length; indexChunk++) {
11041104
chunks[indexChunk].sortItems();
11051105
}
1106+
1107+
const byMessage = (a, b) => {
1108+
const ma = `${a.message}`;
1109+
const mb = `${b.message}`;
1110+
if(ma < mb) return -1;
1111+
if(mb < ma) return 1;
1112+
return 0;
1113+
}
1114+
1115+
this.errors.sort(byMessage);
1116+
this.warnings.sort(byMessage);
11061117
}
11071118

11081119
summarizeDependencies() {
@@ -1171,6 +1182,12 @@ class Compilation extends Tapable {
11711182
this.children.forEach(function(child) {
11721183
hash.update(child.hash);
11731184
});
1185+
this.warnings.forEach(function(warning) {
1186+
hash.update(`${warning.message}`);
1187+
});
1188+
this.errors.forEach(function(warning) {
1189+
hash.update(`${warning.message}`);
1190+
});
11741191
// clone needed as sort below is inplace mutation
11751192
const chunks = this.chunks.slice();
11761193
/**

‎test/statsCases/module-trace-disabled-in-error/expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hash: 6e950f2e83663cb6e9a6
1+
Hash: 96df8294017a444709b1
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
main.js 2.65 kB 0 [emitted] main

‎test/statsCases/module-trace-enabled-in-error/expected.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Hash: 6e950f2e83663cb6e9a6
1+
Hash: d59adee54681f1f3ab37
22
Time: Xms
33
Asset Size Chunks Chunk Names
44
main.js 2.65 kB 0 [emitted] main
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Warning1
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
require("./warning-loader!./changing-file");
2+
3+
it("should detect a change on warnings change", function() {
4+
switch(WATCH_STEP) {
5+
case "0":
6+
STATE.hash = STATS_JSON.hash;
7+
break;
8+
case "1":
9+
STATS_JSON.hash.should.be.not.eql(STATE.hash);
10+
break;
11+
}
12+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = function(source) {
2+
this.emitWarning(new Error(source.trim()));
3+
return "";
4+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = [
2+
[/Warning1/]
3+
];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
New Warning
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = [
2+
[/New Warning/]
3+
];

0 commit comments

Comments
 (0)