You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FlagInitialModulesAsUsedPlugin.js 799B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. class FlagInitialModulesAsUsedPlugin {
  7. constructor(explanation) {
  8. this.explanation = explanation;
  9. }
  10. apply(compiler) {
  11. compiler.hooks.compilation.tap(
  12. "FlagInitialModulesAsUsedPlugin",
  13. compilation => {
  14. compilation.hooks.afterOptimizeChunks.tap(
  15. "FlagInitialModulesAsUsedPlugin",
  16. chunks => {
  17. for (const chunk of chunks) {
  18. if (!chunk.isOnlyInitial()) {
  19. return;
  20. }
  21. for (const module of chunk.modulesIterable) {
  22. module.used = true;
  23. module.usedExports = true;
  24. module.addReason(null, null, this.explanation);
  25. }
  26. }
  27. }
  28. );
  29. }
  30. );
  31. }
  32. }
  33. module.exports = FlagInitialModulesAsUsedPlugin;