Skip to content

Commit f86dba2

Browse files
KimYangOfCatQC-Ljacob-lcs
authored
docs(cn): translate src/content/api/contextmodulefactory-hooks.md (#1077)
* translated ContextModuleFactoryHooks * Update src/content/api/contextmodulefactory-hooks.md Co-authored-by: QiChang Li <[email protected]> * Update src/content/api/contextmodulefactory-hooks.md Co-authored-by: QiChang Li <[email protected]> * Update src/content/api/contextmodulefactory-hooks.md Co-authored-by: QiChang Li <[email protected]> * Update src/content/api/contextmodulefactory-hooks.md Co-authored-by: QiChang Li <[email protected]> * Update src/content/api/contextmodulefactory-hooks.md Co-authored-by: QiChang Li <[email protected]> * Update src/content/api/contextmodulefactory-hooks.md Co-authored-by: QiChang Li <[email protected]> * Apply suggestions from code review Co-authored-by: QiChang Li <[email protected]> Co-authored-by: Jacob <[email protected]>
1 parent c58dbf1 commit f86dba2

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/content/api/contextmodulefactory-hooks.md

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,50 @@ group: Plugins
44
sort: 11
55
contributors:
66
- iguessitsokay
7+
translators:
8+
- KimYangOfCat
79
---
810

9-
The `ContextModuleFactory` module is used by the `Compiler` to generate dependencies from webpack specific [require.context](/api/module-methods/#requirecontext) API. It resolves the requested directory, generates requests for each file and filters against passed regExp. Matching dependencies then passes through [NormalModuleFactory](/api/normalmodulefactory-hooks).
11+
`Compiler` 使用 `ContextModuleFactory` 模块从 webpack 独特的 [require.context](/api/module-methods/#requirecontext) API 生成依赖关系。它会解析请求的目录,为每个文件生成请求,并依据传递来的 regExp 进行过滤。最后匹配成功的依赖关系将被传入 [NormalModuleFactory](/api/normalmodulefactory-hooks)
1012

11-
The `ContextModuleFactory` class extends `Tapable` and provides the following
12-
lifecycle hooks. They can be tapped the same way as compiler hooks:
13+
`ContextModuleFactory` 类扩展了 `Tapable` 并提供了以下的生命周期钩子。
14+
你可以像使用编译器钩子一样使用它们:
1315

1416
```js
1517
ContextModuleFactory.hooks.someHook.tap(/* ... */);
1618
```
1719

18-
As with the `compiler`, `tapAsync` and `tapPromise` may also be available
19-
depending on the type of hook.
20+
`compiler` 一样,`tapAsync` `tapPromise` 是否可用
21+
取决于钩子的类型。
2022

21-
### beforeResolve
23+
### beforeResolve {#beforeresolve}
2224

2325
`AsyncSeriesWaterfallHook`
2426

25-
Called before resolving the requested directory. The request can be ignored by returning `false`.
27+
在解析请求的目录之前调用。请求可以通过返回 `false` 来忽略。
2628

27-
- Callback Parameters: `data`
29+
- 回调参数:`data`
2830

29-
### afterResolve
31+
### afterResolve {#afterresolve}
3032

3133
`AsyncSeriesWaterfallHook`
3234

33-
Called after the requested directory resolved.
35+
在请求的目录解析后调用。
3436

35-
- Callback Parameters: `data`
37+
- 回调参数:`data`
3638

37-
### contextModuleFiles
39+
### contextModuleFiles {#contextmodulefiles}
3840

3941
`SyncWaterfallHook`
4042

41-
Called after directory contents are read. On recursive mode, calls for each sub-directory as well. Callback parameter is an array of all file and folder names in each directory.
43+
读取目录内容后调用。在递归模式下,也会读取每个子目录。回调参数是一个包含每个目录中所有文件和文件夹名称的数组。
4244

43-
- Callback Parameters: `fileNames`
45+
- 回调参数:`fileNames`
4446

45-
### alternativeRequests
47+
### alternativeRequests {#alternativerequests}
4648

4749
`AsyncSeriesWaterfallHook`
4850

49-
Called for each file after the request is created but before filtering against regExp.
51+
在创建请求之后但依据 regExp 进行过滤之前,为每个文件调用。
5052

51-
- Callback Parameters: `request` `options`
53+
- 回调参数:`request` `options`

0 commit comments

Comments
 (0)