Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = [
},
{
path: "packages/brick-kit/dist/index.esm.js",
limit: "110 KB",
limit: "111 KB",
},
{
path: "packages/brick-types/dist/index.esm.js",
Expand Down
11 changes: 9 additions & 2 deletions packages/brick-kit/src/core/Kernel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ describe("Kernel", () => {
const appHello: any = {
app: {
id: "hello",
defaultConfig: { configA: { key1: "value1" } },
},
};
mockStandaloneBootstrap.mockResolvedValueOnce({
Expand All @@ -519,7 +520,8 @@ describe("Kernel", () => {
},
],
userConfig: {
configA: "valueA",
configA: { key2: "value2" },
configB: "valueB",
},
});
spyOnCheckLogin.mockResolvedValueOnce({
Expand All @@ -538,7 +540,12 @@ describe("Kernel", () => {
expect(spyOnRuntimeMicroAppStandalone).toBeCalledTimes(1);

expect(kernel.bootstrapData.storyboards[0].app.userConfig).toEqual({
configA: "valueA",
configA: { key2: "value2" },
configB: "valueB",
});
expect(kernel.bootstrapData.storyboards[0].app.config).toEqual({
configA: { key1: "value1", key2: "value2" },
configB: "valueB",
});
});

Expand Down
10 changes: 7 additions & 3 deletions packages/brick-kit/src/core/Kernel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cloneDeep, pick } from "lodash";
import { cloneDeep, merge, pick } from "lodash";
import {
loadScript,
prefetchScript,
Expand All @@ -10,6 +10,7 @@ import {
getDllAndDepsByResource,
scanProcessorsInAny,
CustomApiInfo,
deepFreeze,
} from "@next-core/brick-utils";
import i18next from "i18next";
import * as AuthSdk from "@next-sdk/auth-sdk";
Expand Down Expand Up @@ -223,7 +224,7 @@ export class Kernel {
templatePackages: [],
...data,
} as BootstrapData;
// Merge `app.defaultConfig` and `app.userConfig` to `app.config`.
// Merge `app.defaultConfig` and `app.userConfig` to `app.config`. Should merge config again in standalone mode when doFulfilStoryboard because static bootstrap.json do not have userConfig.
processBootstrapResponse(bootstrapResponse);
this.bootstrapData = {
...bootstrapResponse,
Expand Down Expand Up @@ -279,11 +280,14 @@ export class Kernel {
);
}
if (appRuntimeData) {
// merge user config
// Merge `app.defaultConfig` and `app.userConfig` to `app.config`.
storyboard.app.userConfig = {
...storyboard.app.userConfig,
...appRuntimeData.userConfig,
};
storyboard.app.config = deepFreeze(
merge({}, storyboard.app.defaultConfig, storyboard.app.userConfig)
);
// get inject menus (Actually, appRuntimeData contains both main and inject menus)
storyboard.meta = {
...storyboard.meta,
Expand Down