source: imaps-frontend/node_modules/enhanced-resolve/lib/ModulesInRootPlugin.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8/** @typedef {import("./Resolver")} Resolver */
9/** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
10/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
11
12module.exports = class ModulesInRootPlugin {
13 /**
14 * @param {string | ResolveStepHook} source source
15 * @param {string} path path
16 * @param {string | ResolveStepHook} target target
17 */
18 constructor(source, path, target) {
19 this.source = source;
20 this.path = path;
21 this.target = target;
22 }
23
24 /**
25 * @param {Resolver} resolver the resolver
26 * @returns {void}
27 */
28 apply(resolver) {
29 const target = resolver.ensureHook(this.target);
30 resolver
31 .getHook(this.source)
32 .tapAsync("ModulesInRootPlugin", (request, resolveContext, callback) => {
33 /** @type {ResolveRequest} */
34 const obj = {
35 ...request,
36 path: this.path,
37 request: "./" + request.request,
38 module: false
39 };
40 resolver.doResolve(
41 target,
42 obj,
43 "looking for modules in " + this.path,
44 resolveContext,
45 callback
46 );
47 });
48 }
49};
Note: See TracBrowser for help on using the repository browser.