UNPKG

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