diff --git a/lib/pkg.ts b/lib/pkg.ts index aa00b20c21..875f71bf8d 100644 --- a/lib/pkg.ts +++ b/lib/pkg.ts @@ -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; } -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,