Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions framework/SimpleModule.Hosting/SimpleModuleHostExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
9 changes: 7 additions & 2 deletions template/SimpleModule.Host/ClientApp/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(<App {...props} />);
Expand Down
Loading