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: rename HotUpdateContext to HotUpdateOptions #18718

Merged
merged 1 commit into from
Nov 20, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/changes/hotupdate-hook.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ interface HmrContext {

This hook is called once for all environments, and the passed modules have mixed information from the Client and SSR environments only. Once frameworks move to custom environments, a new hook that is called for each of them is needed.

The new `hotUpdate` hook works in the same way as `handleHotUpdate` but it is called for each environment and receives a new `HotUpdateContext` instance:
The new `hotUpdate` hook works in the same way as `handleHotUpdate` but it is called for each environment and receives a new `HotUpdateOptions` instance:

```ts
interface HotUpdateContext {
interface HotUpdateOptions {
type: 'create' | 'update' | 'delete'
file: string
timestamp: number
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/api-environment-plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Plugins should set default values using the `config` hook. To configure each env
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:
```ts
interface HotUpdateContext {
interface HotUpdateOptions {
type: 'create' | 'update' | 'delete'
file: string
timestamp: number
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ export async function handleHMRUpdate(
const options = {
...contextMeta,
modules: [...mods],
// later on hotUpdate will be called for each runtime with a new HotUpdateContext
// later on hotUpdate will be called for each runtime with a new HotUpdateOptions
environment,
}
hotMap.set(environment, { options })
Expand Down