diff --git a/framework/SimpleModule.Hosting/SimpleModuleHostExtensions.cs b/framework/SimpleModule.Hosting/SimpleModuleHostExtensions.cs index b6eaa933..5aef2348 100644 --- a/framework/SimpleModule.Hosting/SimpleModuleHostExtensions.cs +++ b/framework/SimpleModule.Hosting/SimpleModuleHostExtensions.cs @@ -188,10 +188,9 @@ public static async Task UseSimpleModuleInfrastructure(this WebApplication app) UseStaticFileCaching(app); app.MapStaticAssets(); - // Fallback for dynamically generated .mjs chunks (Vite watch rebuilds) - // MapStaticAssets only knows about files present at build time; - // Vite generates new hash-named chunks at runtime that need correct MIME types - if (app.Environment.IsDevelopment()) + // Fallback for .mjs chunks not in the MapStaticAssets manifest. + // MapStaticAssets only knows about files present at publish time; + // mismatched builds or Vite watch rebuilds can produce chunks it misses. { var provider = new FileExtensionContentTypeProvider(); provider.Mappings[".mjs"] = "application/javascript"; diff --git a/template/SimpleModule.Host/ClientApp/app.tsx b/template/SimpleModule.Host/ClientApp/app.tsx index 48051a40..48f58be3 100644 --- a/template/SimpleModule.Host/ClientApp/app.tsx +++ b/template/SimpleModule.Host/ClientApp/app.tsx @@ -135,8 +135,13 @@ function showErrorToast(message: string) { createInertiaApp({ resolve: async (name) => { - const page = await resolvePage(name); - return resolveLayout(page); + try { + const page = await resolvePage(name); + return resolveLayout(page); + } catch (err) { + showErrorToast(`Failed to load page "${name}". Try refreshing the page.`); + throw err; + } }, setup({ el, App, props }) { createRoot(el).render();