AddBuildDependenciesPlugin.js 839 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. /** @typedef {import("../Compiler")} Compiler */
  7. const PLUGIN_NAME = "AddBuildDependenciesPlugin";
  8. class AddBuildDependenciesPlugin {
  9. /**
  10. * Creates an instance of AddBuildDependenciesPlugin.
  11. * @param {Iterable<string>} buildDependencies list of build dependencies
  12. */
  13. constructor(buildDependencies) {
  14. this.buildDependencies = new Set(buildDependencies);
  15. }
  16. /**
  17. * Applies the plugin by registering its hooks on the compiler.
  18. * @param {Compiler} compiler the compiler instance
  19. * @returns {void}
  20. */
  21. apply(compiler) {
  22. compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
  23. compilation.buildDependencies.addAll(this.buildDependencies);
  24. });
  25. }
  26. }
  27. module.exports = AddBuildDependenciesPlugin;