From e257e3b7fa48427aa30450d5a9b0e13151df5f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnaud=20Barr=C3=A9?= Date: Sat, 3 Dec 2022 21:10:24 +0100 Subject: [PATCH] chore(client)!: remove never implemented hot.decline (#11036) --- docs/guide/api-hmr.md | 3 +-- packages/vite/src/client/client.ts | 3 ++- packages/vite/types/hot.d.ts | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/guide/api-hmr.md b/docs/guide/api-hmr.md index 59a689c6ca2223..e160810301dcf8 100644 --- a/docs/guide/api-hmr.md +++ b/docs/guide/api-hmr.md @@ -30,7 +30,6 @@ interface ViteHotContext { dispose(cb: (data: any) => void): void prune(cb: (data: any) => void): void - decline(): void invalidate(message?: string): void // `InferCustomEventPayload` provides types for built-in Vite events @@ -139,7 +138,7 @@ The `import.meta.hot.data` object is persisted across different instances of the ## `hot.decline()` -Calling `import.meta.hot.decline()` indicates this module is not hot-updatable, and the browser should perform a full reload if this module is encountered while propagating HMR updates. +This is currently a noop and is there for backward compatibility. This could change in the future if there is a new usage for it. To indicate that the module is not hot-updatable, use `hot.invalidate()`. ## `hot.invalidate(message?: string)` diff --git a/packages/vite/src/client/client.ts b/packages/vite/src/client/client.ts index 18ee738f36d4e1..479f49fea53c98 100644 --- a/packages/vite/src/client/client.ts +++ b/packages/vite/src/client/client.ts @@ -550,7 +550,8 @@ export function createHotContext(ownerPath: string): ViteHotContext { pruneMap.set(ownerPath, cb) }, - // TODO + // Kept for backward compatibility (#11036) + // @ts-expect-error untyped // eslint-disable-next-line @typescript-eslint/no-empty-function decline() {}, diff --git a/packages/vite/types/hot.d.ts b/packages/vite/types/hot.d.ts index 76d054c3125651..03f96d196e2099 100644 --- a/packages/vite/types/hot.d.ts +++ b/packages/vite/types/hot.d.ts @@ -22,7 +22,6 @@ export interface ViteHotContext { dispose(cb: (data: any) => void): void prune(cb: (data: any) => void): void - decline(): void invalidate(message?: string): void on(