Files
lobe-chat/src/initialize.ts
Innei 8cd03c8013 ️ perf: warm route chunks after idle (#15109)
* ️ perf: warm route chunks after idle

* 🐛 fix: normalize platform route chunk ids

* ️ perf: refine route chunk preloading

* 🔧 chore: keep desktop renderer preload unchanged

* ️ perf: skip renderer chunks in route warmup

* ️ perf: preload agent route dynamic chunks

* ️ perf: align route preload deployment urls

* ️ perf: coalesce stable vendor chunks

* ️ perf: group shared data runtime chunks

* ️ perf: group model runtime chunks

* ️ perf: trim initial route preloads

* ️ perf: limit idle route micro preloads

* ️ perf: strip tiny html modulepreloads

* ️ perf: prune redundant route chunk imports

* ️ perf: enable rolldown devtools

* ️ perf: gate vite devtools output

* ️ perf: optimize react-scan integration and update global types

Signed-off-by: Innei <tukon479@gmail.com>

* ️ perf: support cloud route chunk preload

---------

Signed-off-by: Innei <tukon479@gmail.com>
2026-05-23 01:00:53 +08:00

41 lines
1.1 KiB
TypeScript

import dayjs from 'dayjs';
import isToday from 'dayjs/plugin/isToday';
import isYesterday from 'dayjs/plugin/isYesterday';
import relativeTime from 'dayjs/plugin/relativeTime';
import utc from 'dayjs/plugin/utc';
import { enableMapSet, enablePatches } from 'immer';
import { isChunkLoadError, notifyChunkError } from '@/utils/chunkError';
enablePatches();
enableMapSet();
// Dayjs plugins - extend once at app init to avoid duplicate extensions in components
dayjs.extend(relativeTime);
dayjs.extend(utc);
dayjs.extend(isToday);
dayjs.extend(isYesterday);
// Global fallback: catch async chunk-load failures that escape Error Boundaries
if (typeof window !== 'undefined') {
window.addEventListener('vite:preloadError', (event) => {
if (isChunkLoadError((event as any).payload)) {
event.preventDefault();
notifyChunkError();
}
});
window.addEventListener('unhandledrejection', (event) => {
if (isChunkLoadError(event.reason)) {
event.preventDefault();
notifyChunkError();
}
});
}
if (__DEV__) {
void import('react-scan').then(({ scan }) => {
scan({ enabled: true });
});
}