From 1a7cb5b42c691b395fc3ad0686bfac4285c47d89 Mon Sep 17 00:00:00 2001 From: weareoutman Date: Mon, 2 Sep 2024 17:15:22 +0800 Subject: [PATCH 1/2] fix(): add "$fullMerged" in RuntimeStoryboard --- packages/types/src/manifest.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/types/src/manifest.ts b/packages/types/src/manifest.ts index 1db8618679..f2fc0b38fb 100644 --- a/packages/types/src/manifest.ts +++ b/packages/types/src/manifest.ts @@ -249,6 +249,7 @@ export interface RuntimeStoryboard extends Storyboard { $$registerCustomTemplateProcessed?: boolean; $$fulfilled?: boolean; $$fulfilling?: Promise; + $$fullMerged?: boolean; $$i18nFulfilled?: boolean; $$deadConditionsRemoved?: boolean; } From a238d37c3fc0ca603b5af1a6366a371fb6c690f3 Mon Sep 17 00:00:00 2001 From: weareoutman Date: Mon, 2 Sep 2024 17:15:26 +0800 Subject: [PATCH 2/2] feat(): support setting merge method in app user config --- .../brick-container/src/loadBootstrapData.spec.ts | 11 +++++++++++ packages/brick-container/src/loadBootstrapData.ts | 11 ++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/brick-container/src/loadBootstrapData.spec.ts b/packages/brick-container/src/loadBootstrapData.spec.ts index 3966b846e8..2724ae0104 100644 --- a/packages/brick-container/src/loadBootstrapData.spec.ts +++ b/packages/brick-container/src/loadBootstrapData.spec.ts @@ -84,9 +84,12 @@ jest.spyOn(http, "get").mockImplementation(async (url) => { }, defaultConfig: { defaultConf: 7, + array: [1, 2], }, userConfig: { + __merge_method: "override", userConf: 8, + array: [3], }, menuIcon: { imgSrc: @@ -325,9 +328,12 @@ describe("loadBootstrapData", () => { }, defaultConfig: { defaultConf: 7, + array: [1, 2], }, userConfig: { + __merge_method: "override", userConf: 8, + array: [3], }, menuIcon: { imgSrc: @@ -365,15 +371,20 @@ describe("loadBootstrapData", () => { }, defaultConfig: { defaultConf: 7, + array: [1, 2], }, userConfig: { + __merge_method: "override", userConf: 8, + array: [3], runtimeUserConf: 9, }, config: { + __merge_method: "override", defaultConf: 7, userConf: 8, runtimeUserConf: 9, + array: [3], }, menuIcon: { imgSrc: diff --git a/packages/brick-container/src/loadBootstrapData.ts b/packages/brick-container/src/loadBootstrapData.ts index 2aa1f5665b..3391481436 100644 --- a/packages/brick-container/src/loadBootstrapData.ts +++ b/packages/brick-container/src/loadBootstrapData.ts @@ -279,7 +279,16 @@ export async function fulfilStoryboard(storyboard: RuntimeStoryboard) { } function initializeAppConfig(app: MicroApp) { - app.config = deepFreeze(merge({}, app.defaultConfig, app.userConfig)); + // Manually add `__merge_method: override` to avoid being deep merged. + const mergedConfig = + (app.userConfig?.__merge_method ?? app.defaultConfig?.__merge_method) === + "override" + ? { + ...app.defaultConfig, + ...app.userConfig, + } + : merge({}, app.defaultConfig, app.userConfig); + app.config = deepFreeze(mergedConfig); } function initializeAppLocales(app: MicroApp) {