diff --git a/src/utils/module.ts b/src/utils/module.ts index d47d526..48543a7 100644 --- a/src/utils/module.ts +++ b/src/utils/module.ts @@ -59,6 +59,23 @@ export type ModuleWithComponent< PropsType = any > = Promise<{ [K in ComponentName]: React.ComponentType }> +// export const createDynamicComponent = (basePath: string) => { +// /** +// * 与import作用相同 +// * @param path 相对路径 +// * @returns +// */ +// return = { default: any }>( +// path: string +// ): Promise<{ [K in keyof T]: React.ComponentType }> => +// import( +// new URL( +// `${path}${process.env.NODE_ENV == 'production' ? '' : now()}`, +// basePath +// ).href +// ) +// } + /** * @param basePath import.meta.url * @returns @@ -73,7 +90,7 @@ export const createDynamicComponent = (basePath: string) => { * @param path 相对路径 * @returns */ - return (path: string): ModuleWithComponent => + return (path: string): Promise => import( new URL( `${path}${process.env.NODE_ENV == 'production' ? '' : now()}`,