Skip to content

Commit 6a1f424

Browse files
committed
Improvement: Ensure util.depracation use for deprecation warnings: revert NoErrors plugin
1 parent f14c301 commit 6a1f424

2 files changed

Lines changed: 27 additions & 26 deletions

File tree

‎lib/NoErrorsPlugin.js‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
*/
55
"use strict";
66

7-
const util = require("util");
7+
let deprecationReported = false;
88

99
class NoErrorsPlugin {
1010
apply(compiler) {
11-
compiler.plugin("should-emit", util.deprecate(
12-
(compilation) => {
13-
if(compilation.errors.length > 0)
14-
return false;
15-
},
16-
"webpack: Using NoErrorsPlugin is deprecated.\n" +
17-
"Use NoEmitOnErrorsPlugin instead.\n"
18-
));
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+
}
17+
if(compilation.errors.length > 0)
18+
return false;
19+
});
1920
compiler.plugin("compilation", (compilation) => {
2021
compilation.plugin("should-record", () => {
2122
if(compilation.errors.length > 0)

‎test/Errors.test.js‎

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,23 @@ describe("Errors", () => {
9494
done();
9595
});
9696
});
97-
// it("should warn about NoErrorsPlugin being deprecated in favor of NoEmitOnErrorsPlugin", (done) => {
98-
// getErrors({
99-
// entry: "./no-errors-deprecate",
100-
// plugins: [
101-
// new webpack.NoErrorsPlugin()
102-
// ]
103-
// }, (errors, warnings) => {
104-
// warnings.length.should.be.eql(1);
105-
// const lines = warnings[0].split("\n");
106-
// lines[0].should.match(/webpack/);
107-
// lines[0].should.match(/NoErrorsPlugin/);
108-
// lines[0].should.match(/deprecated/);
109-
// lines[1].should.match(/NoEmitOnErrorsPlugin/);
110-
// lines[1].should.match(/instead/);
111-
// done();
112-
// });
113-
// });
97+
it("should warn about NoErrorsPlugin being deprecated in favor of NoEmitOnErrorsPlugin", (done) => {
98+
getErrors({
99+
entry: "./no-errors-deprecate",
100+
plugins: [
101+
new webpack.NoErrorsPlugin()
102+
]
103+
}, (errors, warnings) => {
104+
warnings.length.should.be.eql(1);
105+
const lines = warnings[0].split("\n");
106+
lines[0].should.match(/webpack/);
107+
lines[0].should.match(/NoErrorsPlugin/);
108+
lines[0].should.match(/deprecated/);
109+
lines[1].should.match(/NoEmitOnErrorsPlugin/);
110+
lines[1].should.match(/instead/);
111+
done();
112+
});
113+
});
114114
it("should not warn if the NoEmitOnErrorsPlugin is used over the NoErrorsPlugin", (done) => {
115115
getErrors({
116116
entry: "./no-errors-deprecate",

0 commit comments

Comments
 (0)