For AI agents: the complete documentation index is available at /zh/llms.txt, the full documentation bundle is available at /zh/llms-full.txt, and this page is available as Markdown at /zh/api/plugin-api/context-module-factory-hooks.md.
close

ContextModuleFactory 钩子

Compiler 使用 ContextModuleFactory 模块从 require.context API 生成依赖关系。它会解析请求的目录,为每个文件生成请求,并依据传递来的 regExp 进行过滤。最后匹配成功的依赖关系将被传入 NormalModuleFactory

beforeResolve

AsyncSeriesWaterfallHook<[BeforeResolveResult]>

在解析请求的目录之前调用。通过返回 false 可以忽略该请求。

afterResolve

AsyncSeriesWaterfallHook<[AfterResolveResult]>

在请求的目录解析后调用。