> For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt.

# ContextModuleFactory

The `ContextModuleFactory` module is used by the `Compiler` to generate dependencies from [require.context](/api/runtime-api/module-methods.md#requirecontext) API. It resolves the requested directory, generates requests for each file and filters against passed regExp. Matching dependencies then passes through [NormalModuleFactory](/api/plugin-api/normal-module-factory-hooks.md).

## `beforeResolve`

`AsyncSeriesWaterfallHook<[BeforeResolveResult], BeforeResolveResult | void>`

Called before resolving the requested directory.

Callbacks can return the resolve data or modify it directly without returning a value. Return `false` to ignore the request.


BeforeResolveResult.ts

## `afterResolve`

`AsyncSeriesWaterfallHook<[AfterResolveResult], AfterResolveResult | void>`

Called after the requested directory has been resolved.

Callbacks can return the resolve data or modify it directly without returning a value. Return `false` to ignore the request.


AfterResolveResult.ts