Fix Vite asset preload recovery (#399)

## Summary
- detect Vite CSS preload failures as chunk load errors
- reuse existing one-shot reload recovery for stale asset failures

Fixes PHP-LARAVEL-29
Fixes PHP-LARAVEL-27

## Tests
- npm run test -- resources/js/lib/chunk-load-recovery.test.ts
- npm run types *(fails: existing unrelated TypeScript errors in
accounts, charts, transactions, crypto, etc.)*
This commit is contained in:
Víctor Falcón 2026-05-14 14:59:08 +01:00 committed by GitHub
parent 9b4f0ab422
commit a1648fc4c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -15,6 +15,16 @@ describe('isChunkLoadError', () => {
).toBe(true);
});
it('detects Vite CSS preload failures', () => {
expect(
isChunkLoadError(
new Error(
'Unable to preload CSS for /build/assets/app-BpqbLMXP.css',
),
),
).toBe(true);
});
it('ignores unrelated errors', () => {
expect(isChunkLoadError(new Error('Validation failed'))).toBe(false);
});

View File

@ -6,6 +6,7 @@ const CHUNK_LOAD_ERROR_PATTERNS = [
/error loading dynamically imported module/i,
/Importing a module script failed/i,
/Load failed for module script/i,
/Unable to preload CSS/i,
/ChunkLoadError/i,
/Loading chunk \d+ failed/i,
];