ModulesInRootPlugin.js 710 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. module.exports = class ModulesInRootPlugin {
  7. constructor(source, path, target) {
  8. this.source = source;
  9. this.path = path;
  10. this.target = target;
  11. }
  12. apply(resolver) {
  13. const target = resolver.ensureHook(this.target);
  14. resolver
  15. .getHook(this.source)
  16. .tapAsync("ModulesInRootPlugin", (request, resolveContext, callback) => {
  17. const obj = Object.assign({}, request, {
  18. path: this.path,
  19. request: "./" + request.request
  20. });
  21. resolver.doResolve(
  22. target,
  23. obj,
  24. "looking for modules in " + this.path,
  25. resolveContext,
  26. callback
  27. );
  28. });
  29. }
  30. };