AddBuildDependenciesPlugin.js 862 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. /** @import Compiler from "../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. /** @type {Set<string>} */
  15. this.buildDependencies = new Set(buildDependencies);
  16. }
  17. /**
  18. * Applies the plugin by registering its hooks on the compiler.
  19. * @param {Compiler} compiler the compiler instance
  20. * @returns {void}
  21. */
  22. apply(compiler) {
  23. compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
  24. compilation.buildDependencies.addAll(this.buildDependencies);
  25. });
  26. }
  27. }
  28. module.exports = AddBuildDependenciesPlugin;