Skip to content
Source
Sign inSign up
TanStack/router

fix(router-core): treat Safari's module MIME-type error as a missing lazy chunk #8635

Openjrtell1(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/8635/headopened

Showing 4 changed files with 46 additions and 1 deletion (loading 1).

x
0 of 4 viewed, 4 left
6 additions and 0 deletions.changeset/safari-mime-chunk-reload.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/router-core': patch
+'@tanstack/vue-router': patch
+---
+​
+detect Safari's "not a valid JavaScript MIME type" error as a missing lazy chunk, so stale-deploy recovery also reloads when the server answers the chunk with an HTML fallback
4 additions and 1 deletionpackages/router-core/src/utils.tsModified
View file
@@ -508,11 +508,14 @@
// chrome: "Failed to fetch dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split"
// firefox: "error loading dynamically imported module: http://localhost:5173/src/routes/posts.index.tsx?tsr-split"
// safari: "Importing a module script failed."
+ // safari, when the missing chunk is answered with a non-JS fallback (e.g. an SPA's index.html):
+ // "'text/html' is not a valid JavaScript MIME type for module script 'http://localhost:5173/assets/posts-abc123.js'."
if (typeof error?.message !== 'string') return false
return (
error.message.startsWith('Failed to fetch dynamically imported module') ||
error.message.startsWith('error loading dynamically imported module') ||
- error.message.startsWith('Importing a module script failed')
+ error.message.startsWith('Importing a module script failed') ||
+ error.message.includes('is not a valid JavaScript MIME type')
​