Skip to content

Commit

Permalink
feat: add global insulation variable (#664)
Browse files Browse the repository at this point in the history
* feat: add global insulation variable

* chore: add merge logic
  • Loading branch information
zhoushaw authored Mar 22, 2024
1 parent 95c6901 commit b6e058f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,28 @@ export const getAppConfig = (
return mergeResult;
};

function getGlobalInsulationVariable() {
return window['__GARFISH_INSULATION_VARIABLE__'] || [];
}

export const generateAppOptions = (
appName: string,
garfish: interfaces.Garfish,
options?: Partial<Omit<AppInfo, 'name'>>,
): AppInfo => {
let appInfo: AppInfo = garfish.appInfos[appName] || { name: appName };
const insulationVariable = Array.from(
new Set([
...getGlobalInsulationVariable(),
...(appInfo?.insulationVariable || []),
]),
);

// Merge register appInfo config and loadApp config
appInfo = getAppConfig(garfish.options, {
...appInfo,
...options,
insulationVariable,
props: {
...(appInfo.props || {}),
...(options?.props || {}),
Expand Down

0 comments on commit b6e058f

Please sign in to comment.