Skip to content

Commit

Permalink
docs: split plugins api (#6400)
Browse files Browse the repository at this point in the history
* docs: split plugins api

* docs: split plugins api en

* fix: dead link
  • Loading branch information
SyMind committed May 6, 2024
1 parent 42527c5 commit 7f83dee
Show file tree
Hide file tree
Showing 23 changed files with 501 additions and 495 deletions.
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.

0 comments on commit 7f83dee

Please sign in to comment.