fix(package): import namespaces dynamically

This commit is contained in:
Stephen Zhou 2025-11-27 03:18:35 +08:00
parent 399627cb65
commit da5f5080fe
No known key found for this signature in database
1 changed files with 3 additions and 2 deletions

View File

@ -2,7 +2,6 @@ import { type ConfigEnv, setConfig } from '@/config';
import { Handler, Hono } from 'hono';
import type { RoutePath } from '@/../assets/build/route-paths';
import type { Data, Route, Namespace } from './types';
import { namespaces } from './registry';
export * from '@/types';
export { default as ofetch } from '@/utils/ofetch';
@ -35,9 +34,11 @@ export async function request(path: RoutePath | (string & {})) {
return res.json() as Promise<Data>;
}
export function registerRoute(namespace: string, route: Route, namespaceConfig?: Namespace) {
export async function registerRoute(namespace: string, route: Route, namespaceConfig?: Namespace) {
ensureAppInitialized(app);
const { namespaces } = await import('./registry');
if (!namespaces[namespace]) {
namespaces[namespace] = {
...namespaceConfig,