diff --git a/packages/plugins/libs/qiankun/master/masterRuntimePlugin.tsx b/packages/plugins/libs/qiankun/master/masterRuntimePlugin.tsx index d9bf8b3e43d2..d8a70444f40d 100644 --- a/packages/plugins/libs/qiankun/master/masterRuntimePlugin.tsx +++ b/packages/plugins/libs/qiankun/master/masterRuntimePlugin.tsx @@ -77,6 +77,10 @@ function patchMicroAppRouteComponent(routes: any[]) { } export async function render(oldRender: typeof noop) { + // 在 ssr 的场景下,直接返回旧的 render + if (typeof window === 'undefined') { + return oldRender(); + } const runtimeOptions = await getMasterRuntime(); let masterOptions: MasterOptions = { ...getMasterOptions(), diff --git a/packages/plugins/libs/qiankun/slave/slaveRuntimePlugin.ts b/packages/plugins/libs/qiankun/slave/slaveRuntimePlugin.ts index e16244405db5..bd81f6bfc2e1 100644 --- a/packages/plugins/libs/qiankun/slave/slaveRuntimePlugin.ts +++ b/packages/plugins/libs/qiankun/slave/slaveRuntimePlugin.ts @@ -3,6 +3,10 @@ import { createHistory } from '@@/core/history'; import qiankunRender, { contextOptsStack } from './lifecycles'; export function render(oldRender: any) { + // 在 ssr 的场景下,直接返回旧的 render + if (typeof window === 'undefined') { + return oldRender(); + } return qiankunRender().then(oldRender); } diff --git a/packages/plugins/src/qiankun/master.ts b/packages/plugins/src/qiankun/master.ts index b3729fe2f22a..30ff0a914f43 100644 --- a/packages/plugins/src/qiankun/master.ts +++ b/packages/plugins/src/qiankun/master.ts @@ -220,7 +220,6 @@ export { MicroAppWithMemoHistory } from './MicroAppWithMemoHistory'; ...originalExternals, qiankun: 'fs', }); - return config; } return config;