AddManagedPathsPlugin.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. class AddManagedPathsPlugin {
  8. /**
  9. * Creates an instance of AddManagedPathsPlugin.
  10. * @param {Iterable<string | RegExp>} managedPaths list of managed paths
  11. * @param {Iterable<string | RegExp>} immutablePaths list of immutable paths
  12. * @param {Iterable<string | RegExp>} unmanagedPaths list of unmanaged paths
  13. */
  14. constructor(managedPaths, immutablePaths, unmanagedPaths) {
  15. /** @type {Set<string | RegExp>} */
  16. this.managedPaths = new Set(managedPaths);
  17. /** @type {Set<string | RegExp>} */
  18. this.immutablePaths = new Set(immutablePaths);
  19. /** @type {Set<string | RegExp>} */
  20. this.unmanagedPaths = new Set(unmanagedPaths);
  21. }
  22. /**
  23. * Applies the plugin by registering its hooks on the compiler.
  24. * @param {Compiler} compiler the compiler instance
  25. * @returns {void}
  26. */
  27. apply(compiler) {
  28. for (const managedPath of this.managedPaths) {
  29. compiler.managedPaths.add(managedPath);
  30. }
  31. for (const immutablePath of this.immutablePaths) {
  32. compiler.immutablePaths.add(immutablePath);
  33. }
  34. for (const unmanagedPath of this.unmanagedPaths) {
  35. compiler.unmanagedPaths.add(unmanagedPath);
  36. }
  37. }
  38. }
  39. module.exports = AddManagedPathsPlugin;