FlagInitialModulesAsUsedPlugin.js 550B

12345678910111213141516171819202122232425
  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.forEachModule((module) => {
  15. module.usedExports = true;
  16. });
  17. });
  18. });
  19. });
  20. }
  21. }
  22. module.exports = FlagInitialModulesAsUsedPlugin;