FlagInitialModulesAsUsedPlugin.js 552 B

123456789101112131415161718192021222324
  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. apply(compiler) {
  8. compiler.plugin("compilation", (compilation) => {
  9. compilation.plugin("after-optimize-chunks", (chunks) => {
  10. chunks.forEach((chunk) => {
  11. if(!chunk.isInitial()) {
  12. return;
  13. }
  14. chunk.modules.forEach((module) => {
  15. module.usedExports = true;
  16. });
  17. });
  18. });
  19. });
  20. }
  21. }
  22. module.exports = FlagInitialModulesAsUsedPlugin;