Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add compiler.hooks.finishMake #9146

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions website/docs/en/api/plugin-api/compiler-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ HookThisCompilation --> HookCompilation(<a href="#compilation">hooks.compilation
HookCompilation --> HookMake(<a href="#make">hooks.make</a>)
HookMake --> CreateModuleGraph(Create module graph)
CreateModuleGraph <--> RunLoaders(Run loaders on modules)
CreateModuleGraph --> HookFinishMake(hooks.finishMake)
CreateModuleGraph --> HookFinishMake(<a href="#finishmake">hooks.finishMake</a>)
HookFinishMake --> CompilationFinish("compilation.finish()")
CompilationFinish --> CompilationSeal("compilation.seal()")
CompilationSeal --> HookAfterCompile(<a href="#aftercompile">hooks.afterCompile</a>)
Expand All @@ -67,8 +67,8 @@ HookAfterCompile --> Callback("callback()")
class Compile flow-start
class Callback,CloseCallback flow-end
class CompilationParams,Compilation,CreateModuleGraph,RunLoaders,CompilationFinish,CompilationSeal flow-process
class HookBeforeCompile,HookCompile,HookThisCompilation,HookCompilation,HookMake,HookAfterCompile flow-hook
class HookNormalModuleFactory,HookContextModuleFactory,HookFinishMake flow-hook-non-support
class HookBeforeCompile,HookCompile,HookThisCompilation,HookCompilation,HookMake,HookFinishMake,HookAfterCompile flow-hook
class HookNormalModuleFactory,HookContextModuleFactory flow-hook-non-support
`}

</Mermaid>
Expand Down Expand Up @@ -316,6 +316,26 @@ In the make phase, Rspack will build the module graph starting from the entry, a
</CollapsePanel>
</Collapse>

## `finishMake`

Called after finishing the make phase.

In the make phase, Rspack builds the module graph starting from the entry and uses loaders to handle each module. This hook is called when that process completes.

- **Type:** `AsyncSeriesHook<[Compilation]>`
- **Arguments:**
- `Compilation`: current [compilation](/api/javascript-api/compilation) object

<Collapse>
<CollapsePanel
className="collapse-code-panel"
header="Compilation.ts"
key="Compilation"
>
<CompilationType />
</CollapsePanel>
</Collapse>

## `afterCompile`

Called after the make phase and before the seal phase.
Expand Down
25 changes: 21 additions & 4 deletions website/docs/zh/api/plugin-api/compiler-hooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ HookThisCompilation --> HookCompilation(<a href="#compilation">hooks.compilation
HookCompilation --> HookMake(<a href="#make">hooks.make</a>)
HookMake --> CreateModuleGraph(创建模块图)
CreateModuleGraph <--> RunLoaders(执行 loader 编译模块)
CreateModuleGraph --> HookFinishMake(hooks.finishMake)
CreateModuleGraph --> HookFinishMake(<a href="#finishmake">hooks.finishMake</a>)
HookFinishMake --> CompilationFinish("compilation.finish()")
CompilationFinish --> CompilationSeal("compilation.seal()")
CompilationSeal --> HookAfterCompile(<a href="#aftercompile">hooks.afterCompile</a>)
Expand All @@ -68,8 +68,8 @@ HookAfterCompile --> Callback("callback()")
class Compile flow-start
class Callback,CloseCallback flow-end
class CompilationParams,Compilation,CreateModuleGraph,RunLoaders,CompilationFinish,CompilationSeal flow-process
class HookBeforeCompile,HookCompile,HookThisCompilation,HookCompilation,HookMake,HookAfterCompile flow-hook
class HookNormalModuleFactory,HookContextModuleFactory,HookFinishMake flow-hook-non-support
class HookBeforeCompile,HookCompile,HookThisCompilation,HookCompilation,HookMake,HookFinishMake,HookAfterCompile flow-hook
class HookNormalModuleFactory,HookContextModuleFactory flow-hook-non-support
`}

</Mermaid>
Expand Down Expand Up @@ -296,7 +296,6 @@ compilation 创建之后执行。
<CompilationType />
</CollapsePanel>
</Collapse>

## `make`

在 make 阶段开始前调用,在 make 阶段会以 entry 为起点构建模块依赖图,并使用 loader 处理各个模块。
Expand All @@ -315,6 +314,24 @@ compilation 创建之后执行。
</CollapsePanel>
</Collapse>

## `finishMake`

在 make 阶段结束后调用。在 make 阶段,Rspack 会以 entry 为起点构建模块依赖图,并使用 loader 处理各个模块,当这个过程完成时会触发此钩子。

- **类型:** `AsyncSeriesHook<[Compilation]>`
- **参数:**
- `Compilation`: 当前 [Compilation](/api/javascript-api/compilation) 对象

<Collapse>
<CollapsePanel
className="collapse-code-panel"
header="Compilation.ts"
key="Compilation"
>
<CompilationType />
</CollapsePanel>
</Collapse>

## `afterCompile`

在 make 阶段结束后 seal 阶段开始前调用,在 seal 阶段会从模块图优化并创建 chunk 图,以生成产物信息。
Expand Down
Loading