1 |
3a515b92
|
cagy
|
/*
|
2 |
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3 |
|
|
Author Tobias Koppers @sokra
|
4 |
|
|
*/
|
5 |
|
|
|
6 |
|
|
"use strict";
|
7 |
|
|
|
8 |
|
|
/** @typedef {import("./Compiler")} Compiler */
|
9 |
|
|
|
10 |
|
|
class FlagAllModulesAsUsedPlugin {
|
11 |
|
|
constructor(explanation) {
|
12 |
|
|
this.explanation = explanation;
|
13 |
|
|
}
|
14 |
|
|
|
15 |
|
|
/**
|
16 |
|
|
* @param {Compiler} compiler webpack compiler
|
17 |
|
|
* @returns {void}
|
18 |
|
|
*/
|
19 |
|
|
apply(compiler) {
|
20 |
|
|
compiler.hooks.compilation.tap(
|
21 |
|
|
"FlagAllModulesAsUsedPlugin",
|
22 |
|
|
compilation => {
|
23 |
|
|
compilation.hooks.optimizeDependencies.tap(
|
24 |
|
|
"FlagAllModulesAsUsedPlugin",
|
25 |
|
|
modules => {
|
26 |
|
|
for (const module of modules) {
|
27 |
|
|
module.used = true;
|
28 |
|
|
module.usedExports = true;
|
29 |
|
|
module.addReason(null, null, this.explanation);
|
30 |
|
|
}
|
31 |
|
|
}
|
32 |
|
|
);
|
33 |
|
|
}
|
34 |
|
|
);
|
35 |
|
|
}
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
module.exports = FlagAllModulesAsUsedPlugin;
|