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: split plugins api #6400

Merged
merged 3 commits into from
May 6, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion website/docs/en/api/_meta.json
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
["index", "cli", "modules", "node-api", "hmr", "loader-api", "plugin-api"]
[
"index",
"cli",
"modules",
"node-api",
"hmr",
"loader-api",
{
"type": "dir",
"name": "plugin-api",
"label": "Plugin API"
}
]
2 changes: 1 addition & 1 deletion website/docs/en/api/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ Loaders are transformations that are applied to the source code of a module. The

The plugin interface allows users to tap directly into the compilation process. Plugins can register handlers on lifecycle hooks that run at different points throughout a compilation. When each hook is executed, the plugin will have full access to the current state of the compilation.

[Learn more about the plugins!](/api/plugin-api)
[Learn more about the plugins!](/api/plugin-api/index)
233 changes: 0 additions & 233 deletions website/docs/en/api/plugin-api.mdx

This file was deleted.

7 changes: 7 additions & 0 deletions website/docs/en/api/plugin-api/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
"index",
"compiler-hooks",
"compilation-hooks",
"normal-module-factory-hooks",
"context-module-factory-hooks"
]
43 changes: 43 additions & 0 deletions website/docs/en/api/plugin-api/compilation-hooks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Compilation Hooks

## `buildModule`

`SyncHook<[JsModule]>`

Triggered before a module build has started, can be used to modify the module (Rspack currently only support reading the module, modifying is not supported yet).

## `processAssets`

`AsyncSeriesHook<[CompilationAssets]>`

Process the assets before emit.

## `optimizeModules`

`SyncBailHook<[JsModule[]]>`

Called at the beginning of the module optimization phase. A plugin can tap into this hook to perform optimizations on modules.

## `optimizeChunkModule`

`AsyncSeriesBailHook<[JsModule[]]>`

Called after the tree optimization, at the beginning of the chunk modules optimization. A plugin can tap into this hook to perform optimizations of chunk modules.

## `succeedModule`

`SyncHook<[JsModule]>`

Executed when a module has been built successfully.

## `finishModules`

`AsyncSeriesHook<[JsModule[]]>`

Called when all modules have been built without errors.

## `chunkAsset`

`SyncHook<[JsChunk[], string /** filename*/ ]>`

Triggered when an asset from a chunk was added to the compilation.