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

feat: optimize lifecycle validation log #2841

Merged
merged 8 commits into from
Dec 21, 2023
6 changes: 6 additions & 0 deletions .changeset/smart-scissors-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'qiankun': patch
'@qiankunjs/sandbox': patch
---

feat: optimize lifecycle validate log
12 changes: 7 additions & 5 deletions packages/qiankun/src/core/loadApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { LoaderOpts } from '@qiankunjs/loader';
import { loadEntry } from '@qiankunjs/loader';
import type { Sandbox } from '@qiankunjs/sandbox';
import { createSandboxContainer } from '@qiankunjs/sandbox';
import { moduleResolver as defaultModuleResolver, transpileAssets, wrapFetchWithCache } from '@qiankunjs/shared';
import { moduleResolver as defaultModuleResolver, transpileAssets, warn, wrapFetchWithCache } from '@qiankunjs/shared';
import { concat, isFunction, mergeWith } from 'lodash';
import type { ParcelConfigObject } from 'single-spa';
import getAddOns from '../addons';
Expand Down Expand Up @@ -225,9 +225,7 @@ function getLifecyclesFromExports(
}

if (process.env.NODE_ENV === 'development') {
console.warn(
`[qiankun] lifecycle not found from ${appName} entry exports, fallback to get from window['${appName}']`,
);
warn(`lifecycle not found from ${appName} entry exports, fallback to get from window['${appName}']`);
}

// fallback to globalContext variable who named with ${appName} while module exports not found
Expand All @@ -237,7 +235,11 @@ function getLifecyclesFromExports(
return globalVariableExports;
}

throw new QiankunError(`You need to export lifecycle functions in ${appName} entry`);
throw new QiankunError(
`You need to export lifecycle functions in ${appName} entry as neither globalLatestSetProp ${String(
globalLatestSetProp,
)} nor window['${appName}'] export correctly`,
);
}

function calcPublicPath(entry: string): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/sandbox/src/patchers/dynamicAppend/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function getOverwrittenAppendChildOrInsertBefore(
const result = appendChild.call(this, transpiledScriptElement, refChild) as T;

// the script have no src attribute after transpile, indicating that the script needs to wait for the src to be filled
if (externalSyncMode && !transpiledScriptElement.hasAttribute('scr')) {
if (externalSyncMode && !transpiledScriptElement.hasAttribute('src')) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里看代码应该是拼错顺手改了

queueSyncScript!();
}

Expand Down