From 8baa21eb51bf58d9d209bdab7243e5fa49ebaf4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0?= Date: Fri, 29 Aug 2025 23:53:11 +0900 Subject: [PATCH 1/2] docs: clarify kind for `hotUpdate` / `handleHotUpdate` hooks (#20700) --- guide/api-environment-plugins.md | 1 + guide/api-plugin.md | 1 + 2 files changed, 2 insertions(+) diff --git a/guide/api-environment-plugins.md b/guide/api-environment-plugins.md index 8b3abd71..7a888cc2 100644 --- a/guide/api-environment-plugins.md +++ b/guide/api-environment-plugins.md @@ -70,6 +70,7 @@ Plugins should set default values using the `config` hook. To configure each env ## The `hotUpdate` Hook - **Type:** `(this: { environment: DevEnvironment }, options: HotUpdateOptions) => Array | void | Promise | void>` +- **Kind:** `async`, `sequential` - **See also:** [HMR API](./api-hmr) The `hotUpdate` hook allows plugins to perform custom HMR update handling for a given environment. When a file changes, the HMR algorithm is run for each environment in series according to the order in `server.environments`, so the `hotUpdate` hook will be called multiple times. The hook receives a context object with the following signature: diff --git a/guide/api-plugin.md b/guide/api-plugin.md index 3627a58c..2fa5318f 100644 --- a/guide/api-plugin.md +++ b/guide/api-plugin.md @@ -403,6 +403,7 @@ Vite plugins can also provide hooks that serve Vite-specific purposes. These hoo ### `handleHotUpdate` - **Type:** `(ctx: HmrContext) => Array | void | Promise | void>` +- **Kind:** `async`, `sequential` - **See also:** [HMR API](./api-hmr) Perform custom HMR update handling. The hook receives a context object with the following signature: From 9610a0e35ba4a751a1e2de63786b477f4433b452 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Sat, 30 Aug 2025 08:41:49 +0800 Subject: [PATCH 2/2] fix: resolved conflict --- guide/api-environment-plugins.md | 7 +------ guide/api-plugin.md | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/guide/api-environment-plugins.md b/guide/api-environment-plugins.md index c2e42c81..f0056624 100644 --- a/guide/api-environment-plugins.md +++ b/guide/api-environment-plugins.md @@ -69,14 +69,9 @@ Vite 服务器有一个共享的插件管道,但在处理模块时,它总是 ## `hotUpdate` 钩子 {#the-hotupdate-hook} -<<<<<<< HEAD - **类型:** `(this: { environment: DevEnvironment }, options: HotUpdateOptions) => Array | void | Promise | void>` +- **种类:** `async`, `sequential` - **查看:** [HMR API](./api-hmr) -======= -- **Type:** `(this: { environment: DevEnvironment }, options: HotUpdateOptions) => Array | void | Promise | void>` -- **Kind:** `async`, `sequential` -- **See also:** [HMR API](./api-hmr) ->>>>>>> 8baa21eb51bf58d9d209bdab7243e5fa49ebaf4e `hotUpdate` 钩子允许插件为特定环境执行自定义的 HMR 更新处理。当一个文件发生变化时,会按照 `server.environments` 中的顺序为每个环境依次运行 HMR 算法,因此 `hotUpdate` 钩子会被多次调用。这个钩子会接收一个带有以下签名的上下文对象: diff --git a/guide/api-plugin.md b/guide/api-plugin.md index 2bd86d8d..3618f110 100644 --- a/guide/api-plugin.md +++ b/guide/api-plugin.md @@ -402,14 +402,9 @@ Vite 插件也可以提供钩子来服务于特定的 Vite 目标。这些钩子 ### `handleHotUpdate` {#handlehotupdate} -<<<<<<< HEAD - **类型:** `(ctx: HmrContext) => Array | void | Promise | void>` +- **种类:** `async`, `sequential` - **参见:** [HMR API](./api-hmr) -======= -- **Type:** `(ctx: HmrContext) => Array | void | Promise | void>` -- **Kind:** `async`, `sequential` -- **See also:** [HMR API](./api-hmr) ->>>>>>> 8baa21eb51bf58d9d209bdab7243e5fa49ebaf4e 执行自定义 HMR 更新处理。钩子接收一个带有以下签名的上下文对象: