Skip to content

Commit f5b4b46

Browse files
authored
Merge pull request webpack#4027 from carloscuatin/refactor-no-errors-plugin
refactor(es6) upgrade NoErrorsPlugin to ES6 class
2 parents c1ce496 + 283169a commit f5b4b46

1 file changed

Lines changed: 20 additions & 17 deletions

File tree

lib/NoErrorsPlugin.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,28 @@
22
MIT License http://www.opensource.org/licenses/mit-license.php
33
Author Tobias Koppers @sokra
44
*/
5-
function NoErrorsPlugin() {}
5+
"use strict";
66

7-
var deprecationReported = false;
7+
let deprecationReported = false;
88

9-
module.exports = NoErrorsPlugin;
10-
NoErrorsPlugin.prototype.apply = function(compiler) {
11-
compiler.plugin("should-emit", function(compilation) {
12-
if(!deprecationReported) {
13-
compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" +
14-
"Use NoEmitOnErrorsPlugin instead.\n");
15-
deprecationReported = true;
16-
}
17-
if(compilation.errors.length > 0)
18-
return false;
19-
});
20-
compiler.plugin("compilation", function(compilation) {
21-
compilation.plugin("should-record", function() {
9+
class NoErrorsPlugin {
10+
apply(compiler) {
11+
compiler.plugin("should-emit", (compilation) => {
12+
if(!deprecationReported) {
13+
compilation.warnings.push("webpack: Using NoErrorsPlugin is deprecated.\n" +
14+
"Use NoEmitOnErrorsPlugin instead.\n");
15+
deprecationReported = true;
16+
}
2217
if(compilation.errors.length > 0)
2318
return false;
2419
});
25-
});
26-
};
20+
compiler.plugin("compilation", (compilation) => {
21+
compilation.plugin("should-record", () => {
22+
if(compilation.errors.length > 0)
23+
return false;
24+
});
25+
});
26+
}
27+
}
28+
29+
module.exports = NoErrorsPlugin;

0 commit comments

Comments
 (0)