Skip to content

Commit

Permalink
feat: use plugin for chunk error detection in addition to nuxt built-in
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Sep 16, 2024
1 parent 3c563c9 commit a9a92e9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/plugins/0.chunkerror.client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Modified version based on https://github.com/nuxt/nuxt/pull/19086#issuecomment-1553385289
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.hook('app:chunkError', ({ error }) => {
const error_list = [
'error loading dynamically imported module',
'Importing a module script failed',
'Failed to fetch dynamically imported module',
];

if (typeof error.message === 'string')
for (const message of error_list) {
if (message.indexOf(error.message) > -1) {
reloadNuxtApp({ persistState: true });
}
}
});
});
File renamed without changes.

0 comments on commit a9a92e9

Please sign in to comment.