DelegatedPlugin.js 744 B

123456789101112131415161718192021222324252627
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const DelegatedModuleFactoryPlugin = require("./DelegatedModuleFactoryPlugin");
  7. const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDependency");
  8. class DelegatedPlugin {
  9. constructor(options) {
  10. this.options = options;
  11. }
  12. apply(compiler) {
  13. compiler.plugin("compilation", (compilation, params) => {
  14. compilation.dependencyFactories.set(DelegatedSourceDependency, params.normalModuleFactory);
  15. });
  16. compiler.plugin("compile", (params) => {
  17. params.normalModuleFactory.apply(new DelegatedModuleFactoryPlugin(this.options));
  18. });
  19. }
  20. }
  21. module.exports = DelegatedPlugin;