From da5f5080fe0c65eec15b612d2416f651730e52d1 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 27 Nov 2025 03:18:35 +0800 Subject: [PATCH] fix(package): import namespaces dynamically --- lib/pkg.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/pkg.ts b/lib/pkg.ts index aa00b20c2..875f71bf8 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,