From 67b0b5bf18b2eb8076b58df16b0cad77bcc10c24 Mon Sep 17 00:00:00 2001 From: jinyangwang <214997474@qq.com> Date: Sat, 27 May 2023 08:46:37 +0800 Subject: [PATCH] fix: hmr request 404 (#531) Co-authored-by: Tom <21499747@qq.com> --- packages/platform-web/src/shuvi-app/dev/hotDevClient.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/platform-web/src/shuvi-app/dev/hotDevClient.ts b/packages/platform-web/src/shuvi-app/dev/hotDevClient.ts index a40429c65..9896e9919 100644 --- a/packages/platform-web/src/shuvi-app/dev/hotDevClient.ts +++ b/packages/platform-web/src/shuvi-app/dev/hotDevClient.ts @@ -335,8 +335,6 @@ async function tryApplyUpdates(onHotUpdateSuccess) { } function handleApplyUpdates(err, updatedModules) { - const hasUpdates = Boolean(updatedModules?.length); - if (hadRuntimeError) { hadRuntimeError = false; window.location.reload(); @@ -347,6 +345,13 @@ async function tryApplyUpdates(onHotUpdateSuccess) { hadRuntimeError = true; } + const hasUpdates = Boolean(updatedModules?.length); + + if (!hasUpdates) { + window.location.reload(); + return; + } + if (typeof onHotUpdateSuccess === 'function') { // Maybe we want to do something. onHotUpdateSuccess(hasUpdates);