Skip to content

Commit

Permalink
feat: optimize lifecycle validation log (#2841)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghangit authored Dec 21, 2023
1 parent 1cb6529 commit b2d2c11
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
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')) {
queueSyncScript!();
}

Expand Down

0 comments on commit b2d2c11

Please sign in to comment.