Files
Atay-Makhzan/web_src/js/index.ts
T

30 lines
1.3 KiB
TypeScript
Raw Normal View History

// bootstrap module must be the first one to be imported, it handles webpack lazy-loading and global errors
import './bootstrap.ts';
// many users expect to use jQuery in their custom scripts (https://docs.gitea.com/administration/customizing-gitea#example-plantuml)
// so load globals (including jQuery) as early as possible
import './globals.ts';
2025-07-06 12:55:16 +08:00
import './webcomponents/index.ts';
import './modules/user-settings.ts'; // templates also need to use localUserSettings in inline scripts
2025-07-06 12:55:16 +08:00
import {onDomReady} from './utils/dom.ts';
2025-07-06 12:55:16 +08:00
// TODO: There is a bug in htmx, it incorrectly checks "readyState === 'complete'" when the DOM tree is ready and won't trigger DOMContentLoaded
// Then importing the htmx in our onDomReady will make htmx skip its initialization.
// If the bug would be fixed (https://github.com/bigskysoftware/htmx/pull/3365), then we can only import htmx in "onDomReady"
import 'htmx.org';
2022-06-12 14:08:23 +02:00
2025-07-06 12:55:16 +08:00
onDomReady(async () => {
2025-07-10 00:46:51 +08:00
// when navigate before the import complete, there will be an error from webpack chunk loader:
// JavaScript promise rejection: Loading chunk index-domready failed.
try {
await import(/* webpackChunkName: "index-domready" */'./index-domready.ts');
} catch (e) {
if (e.name === 'ChunkLoadError') {
console.error('Error loading index-domready:', e);
} else {
throw e;
}
}
2019-11-14 22:39:51 +01:00
});