@module-federation/runtime-core 0.0.0-next-20250328031116 → 0.0.0-next-20250328075155

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1227,14 +1227,23 @@ let Module = class Module {
1227
1227
  const remoteEntryExports = await this.getEntry();
1228
1228
  if (!this.inited) {
1229
1229
  const localShareScopeMap = this.host.shareScopeMap;
1230
- const remoteShareScope = this.remoteInfo.shareScope || 'default';
1231
- if (!localShareScopeMap[remoteShareScope]) {
1232
- localShareScopeMap[remoteShareScope] = {};
1230
+ const shareScopeKeys = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
1231
+ this.remoteInfo.shareScope
1232
+ ];
1233
+ if (!shareScopeKeys.length) {
1234
+ shareScopeKeys.push('default');
1233
1235
  }
1234
- const shareScope = localShareScopeMap[remoteShareScope];
1236
+ shareScopeKeys.forEach((shareScopeKey)=>{
1237
+ if (!localShareScopeMap[shareScopeKey]) {
1238
+ localShareScopeMap[shareScopeKey] = {};
1239
+ }
1240
+ });
1241
+ // TODO: compate legacy init params, should use shareScopeMap if exist
1242
+ const shareScope = localShareScopeMap[shareScopeKeys[0]];
1235
1243
  const initScope = [];
1236
1244
  const remoteEntryInitOptions = {
1237
- version: this.remoteInfo.version || ''
1245
+ version: this.remoteInfo.version || '',
1246
+ shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? shareScopeKeys : this.remoteInfo.shareScope || 'default'
1238
1247
  };
1239
1248
  // Help to find host instance
1240
1249
  Object.defineProperty(remoteEntryInitOptions, 'shareScopeMap', {
@@ -1226,14 +1226,23 @@ let Module = class Module {
1226
1226
  const remoteEntryExports = await this.getEntry();
1227
1227
  if (!this.inited) {
1228
1228
  const localShareScopeMap = this.host.shareScopeMap;
1229
- const remoteShareScope = this.remoteInfo.shareScope || 'default';
1230
- if (!localShareScopeMap[remoteShareScope]) {
1231
- localShareScopeMap[remoteShareScope] = {};
1229
+ const shareScopeKeys = Array.isArray(this.remoteInfo.shareScope) ? this.remoteInfo.shareScope : [
1230
+ this.remoteInfo.shareScope
1231
+ ];
1232
+ if (!shareScopeKeys.length) {
1233
+ shareScopeKeys.push('default');
1232
1234
  }
1233
- const shareScope = localShareScopeMap[remoteShareScope];
1235
+ shareScopeKeys.forEach((shareScopeKey)=>{
1236
+ if (!localShareScopeMap[shareScopeKey]) {
1237
+ localShareScopeMap[shareScopeKey] = {};
1238
+ }
1239
+ });
1240
+ // TODO: compate legacy init params, should use shareScopeMap if exist
1241
+ const shareScope = localShareScopeMap[shareScopeKeys[0]];
1234
1242
  const initScope = [];
1235
1243
  const remoteEntryInitOptions = {
1236
- version: this.remoteInfo.version || ''
1244
+ version: this.remoteInfo.version || '',
1245
+ shareScopeKeys: Array.isArray(this.remoteInfo.shareScope) ? shareScopeKeys : this.remoteInfo.shareScope || 'default'
1237
1246
  };
1238
1247
  // Help to find host instance
1239
1248
  Object.defineProperty(remoteEntryInitOptions, 'shareScopeMap', {
@@ -6,7 +6,7 @@ export type PartialOptional<T, K extends keyof T> = Omit<T, K> & {
6
6
  };
7
7
  export interface RemoteInfoCommon {
8
8
  alias?: string;
9
- shareScope?: string;
9
+ shareScope?: string | string[];
10
10
  type?: RemoteEntryType;
11
11
  entryGlobalName?: string;
12
12
  }
@@ -26,7 +26,7 @@ export interface RemoteInfo {
26
26
  entry: string;
27
27
  type: RemoteEntryType;
28
28
  entryGlobalName: string;
29
- shareScope: string;
29
+ shareScope: string | string[];
30
30
  }
31
31
  export type HostInfo = Pick<Options, 'name' | 'version' | 'remotes' | 'version'>;
32
32
  export interface SharedConfig {
@@ -34,6 +34,7 @@ export interface SharedConfig {
34
34
  requiredVersion: false | string;
35
35
  eager?: boolean;
36
36
  strictVersion?: boolean;
37
+ layer?: string | null;
37
38
  }
38
39
  type SharedBaseArgs = {
39
40
  version?: string;
@@ -100,7 +101,8 @@ export type LoadModuleOptions = {
100
101
  };
101
102
  export type RemoteEntryInitOptions = {
102
103
  version: string;
103
- shareScopeMap: ShareScopeMap;
104
+ shareScopeMap?: ShareScopeMap;
105
+ shareScopeKeys: string | string[];
104
106
  };
105
107
  export type InitTokens = Record<string, Record<string, any>>;
106
108
  export type InitScope = InitTokens[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime-core",
3
- "version": "0.0.0-next-20250328031116",
3
+ "version": "0.0.0-next-20250328075155",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.mjs",
@@ -36,7 +36,7 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@module-federation/sdk": "0.0.0-next-20250328031116",
40
- "@module-federation/error-codes": "0.0.0-next-20250328031116"
39
+ "@module-federation/sdk": "0.0.0-next-20250328075155",
40
+ "@module-federation/error-codes": "0.0.0-next-20250328075155"
41
41
  }
42
42
  }