You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
747 B

4 years ago
  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 JoinRequestPlugin {
  7. constructor(source, target) {
  8. this.source = source;
  9. this.target = target;
  10. }
  11. apply(resolver) {
  12. const target = resolver.ensureHook(this.target);
  13. resolver
  14. .getHook(this.source)
  15. .tapAsync("JoinRequestPlugin", (request, resolveContext, callback) => {
  16. const obj = Object.assign({}, request, {
  17. path: resolver.join(request.path, request.request),
  18. relativePath:
  19. request.relativePath &&
  20. resolver.join(request.relativePath, request.request),
  21. request: undefined
  22. });
  23. resolver.doResolve(target, obj, null, resolveContext, callback);
  24. });
  25. }
  26. };