From 918bfd0cf75f6bf6c5e045722c9b2f831dbc310c Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Fri, 22 Jul 2022 10:44:34 +0200 Subject: [PATCH] fix: reload the page during dev when no cache entry is available --- src/data-fetching/defineLoader.ts | 7 ++++++- tsconfig.json | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/data-fetching/defineLoader.ts b/src/data-fetching/defineLoader.ts index 88e2dc645..667f02fcd 100644 --- a/src/data-fetching/defineLoader.ts +++ b/src/data-fetching/defineLoader.ts @@ -30,9 +30,14 @@ export function defineLoader

>( // TODO: dev only if (!entry) { + if (import.meta.hot) { + // reload the page if the loader is new + // TODO: test with webpack + import.meta.hot.invalidate() + } // with HMR, if the user changes the script section, there is a new cache entry // we need to transfer the old cache and call refresh - throw new Error('no cache entry') + throw new Error('No cache entry: reloading the page') } const { data, pending, error } = entry diff --git a/tsconfig.json b/tsconfig.json index c71553de9..d3aa44822 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,6 +8,7 @@ "esModuleInterop": true, "strict": true, "strictNullChecks": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "types": ["vite/client"] } }