JoinRequestPlugin.js 744 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 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.getHook(this.source).tapAsync("JoinRequestPlugin", (request, resolveContext, callback) => {
  14. const obj = Object.assign({}, request, {
  15. path: resolver.join(request.path, request.request),
  16. relativePath: request.relativePath && resolver.join(request.relativePath, request.request),
  17. request: undefined
  18. });
  19. resolver.doResolve(target, obj, null, resolveContext, callback);
  20. });
  21. }
  22. };