* Creates an instance of ContextModuleFactory. * @param {ResolverFactory} resolverFactory resolverFactory
(resolverFactory)
| 57 | * @param {ResolverFactory} resolverFactory resolverFactory |
| 58 | */ |
| 59 | constructor(resolverFactory) { |
| 60 | super(); |
| 61 | /** @type {AsyncSeriesWaterfallHook<[ContextAlternativeRequest[], ContextModuleOptions]>} */ |
| 62 | const alternativeRequests = new AsyncSeriesWaterfallHook([ |
| 63 | "modules", |
| 64 | "options" |
| 65 | ]); |
| 66 | this.hooks = Object.freeze({ |
| 67 | /** @type {AsyncSeriesWaterfallHook<[BeforeContextResolveData], BeforeContextResolveData | false | void>} */ |
| 68 | beforeResolve: new AsyncSeriesWaterfallHook(["data"]), |
| 69 | /** @type {AsyncSeriesWaterfallHook<[AfterContextResolveData], AfterContextResolveData | false | void>} */ |
| 70 | afterResolve: new AsyncSeriesWaterfallHook(["data"]), |
| 71 | /** @type {SyncWaterfallHook<[string[]]>} */ |
| 72 | contextModuleFiles: new SyncWaterfallHook(["files"]), |
| 73 | /** @type {FakeHook<Pick<AsyncSeriesWaterfallHook<[ContextAlternativeRequest[]]>, "tap" | "tapAsync" | "tapPromise" | "name">>} */ |
| 74 | alternatives: createFakeHook( |
| 75 | { |
| 76 | name: "alternatives", |
| 77 | /** @type {AsyncSeriesWaterfallHook<[ContextAlternativeRequest[]]>["intercept"]} */ |
| 78 | intercept: (interceptor) => { |
| 79 | throw new Error( |
| 80 | "Intercepting fake hook ContextModuleFactory.hooks.alternatives is not possible, use ContextModuleFactory.hooks.alternativeRequests instead" |
| 81 | ); |
| 82 | }, |
| 83 | /** @type {AsyncSeriesWaterfallHook<[ContextAlternativeRequest[]]>["tap"]} */ |
| 84 | tap: (options, fn) => { |
| 85 | alternativeRequests.tap(options, fn); |
| 86 | }, |
| 87 | /** @type {AsyncSeriesWaterfallHook<[ContextAlternativeRequest[]]>["tapAsync"]} */ |
| 88 | tapAsync: (options, fn) => { |
| 89 | alternativeRequests.tapAsync(options, (items, _options, callback) => |
| 90 | fn(items, callback) |
| 91 | ); |
| 92 | }, |
| 93 | /** @type {AsyncSeriesWaterfallHook<[ContextAlternativeRequest[]]>["tapPromise"]} */ |
| 94 | tapPromise: (options, fn) => { |
| 95 | alternativeRequests.tapPromise(options, fn); |
| 96 | } |
| 97 | }, |
| 98 | "ContextModuleFactory.hooks.alternatives has deprecated in favor of ContextModuleFactory.hooks.alternativeRequests with an additional options argument.", |
| 99 | "DEP_WEBPACK_CONTEXT_MODULE_FACTORY_ALTERNATIVES" |
| 100 | ), |
| 101 | alternativeRequests |
| 102 | }); |
| 103 | /** @type {ResolverFactory} */ |
| 104 | this.resolverFactory = resolverFactory; |
| 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Processes the provided data. |