1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | "use strict";
|
7 |
|
8 | const WebpackError = require("./WebpackError");
|
9 |
|
10 |
|
11 |
|
12 | class WarnDeprecatedOptionPlugin {
|
13 | |
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | constructor(option, value, suggestion) {
|
20 | this.option = option;
|
21 | this.value = value;
|
22 | this.suggestion = suggestion;
|
23 | }
|
24 |
|
25 | |
26 |
|
27 |
|
28 |
|
29 |
|
30 | apply(compiler) {
|
31 | compiler.hooks.thisCompilation.tap(
|
32 | "WarnDeprecatedOptionPlugin",
|
33 | compilation => {
|
34 | compilation.warnings.push(
|
35 | new DeprecatedOptionWarning(this.option, this.value, this.suggestion)
|
36 | );
|
37 | }
|
38 | );
|
39 | }
|
40 | }
|
41 |
|
42 | class DeprecatedOptionWarning extends WebpackError {
|
43 | constructor(option, value, suggestion) {
|
44 | super();
|
45 |
|
46 | this.name = "DeprecatedOptionWarning";
|
47 | this.message =
|
48 | "configuration\n" +
|
49 | `The value '${value}' for option '${option}' is deprecated. ` +
|
50 | `Use '${suggestion}' instead.`;
|
51 |
|
52 | Error.captureStackTrace(this, this.constructor);
|
53 | }
|
54 | }
|
55 |
|
56 | module.exports = WarnDeprecatedOptionPlugin;
|