ContextModuleFactory Hooks

The ContextModuleFactory module is used by the Compiler to generate dependencies from webpack specific require.context API. It resolves the requested directory, generates requests for each file and filters against passed regExp. Matching dependencies then passes through NormalModuleFactory.

The ContextModuleFactory class extends Tapable and provides the following lifecycle hooks. They can be tapped the same way as compiler hooks:

ContextModuleFactory.hooks.someHook.tap(/* ... */);

As with the compiler, tapAsync and tapPromise may also be available depending on the type of hook.

beforeResolve

AsyncSeriesWaterfallHook

Fired before resolving the requested directory. The request can be ignored by returning false.

  • Callback Parameters: data

afterResolve

AsyncSeriesWaterfallHook

Fired after resolving the requested directory.

  • Callback Parameters: data

contextModuleFiles

SyncWaterfallHook

Fired after directory contents are read. On recursive mode, fires for each sub-directory as well. Callback parameter is an array of all file and folder names in each directory.

  • Callback Parameters: fileNames

alternativeRequests

AsyncSeriesWaterfallHook

Fired for each file after the request is created but before filtering against regExp.

  • Callback Parameters: request options

Contributors