ModulesInRootPlugin.js 689 B

12345678910111213141516171819202122232425
  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.getHook(this.source).tapAsync("ModulesInRootPlugin", (request, resolveContext, callback) => {
  15. const obj = Object.assign({}, request, {
  16. path: this.path,
  17. request: "./" + request.request
  18. });
  19. resolver.doResolve(target, obj, "looking for modules in " + this.path, resolveContext, callback);
  20. });
  21. }
  22. };