Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: improve platform checking logic for qiankun slave #12331

Merged
merged 7 commits into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions packages/plugins/src/qiankun/slave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ export interface IRuntimeConfig {
api.addEntryCode(() => [
`
const qiankun_noop = () => new Error('qiankun lifecycle is not available for server runtime!');
const ssrBuildTarget = process.env.SSR_BUILD_TARGET;
export const bootstrap = ssrBuildTarget ? qiankun_noop: qiankun_genBootstrap(render);
export const mount = ssrBuildTarget ? qiankun_noop : qiankun_genMount('${api.config.mountElementId}');
export const unmount = ssrBuildTarget ? qiankun_noop : qiankun_genUnmount('${api.config.mountElementId}');
export const update = ssrBuildTarget ? qiankun_noop : qiankun_genUpdate();
const isServer = typeof window === 'undefined';
export const bootstrap = isServer ? qiankun_noop: qiankun_genBootstrap(render);
export const mount = isServer ? qiankun_noop : qiankun_genMount('${api.config.mountElementId}');
export const unmount = isServer ? qiankun_noop : qiankun_genUnmount('${api.config.mountElementId}');
export const update = isServer ? qiankun_noop : qiankun_genUpdate();
// 增加 ssr 的判断
if (typeof window !== 'undefined' && !window.__POWERED_BY_QIANKUN__) {
if (!isServer && !window.__POWERED_BY_QIANKUN__) {
bootstrap().then(mount);
}
`,
Expand Down
Loading