@module-federation/runtime 0.0.0-next-20240102063242 → 0.0.0-next-20240103035759

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.esm.js CHANGED
@@ -1,7 +1,6 @@
1
- import { g as getGlobalHostPlugins, D as DEFAULT_REMOTE_TYPE, a as DEFAULT_SCOPE, b as globalLoading, c as getRemoteEntryExports, d as assert, s as safeToString, G as Global, e as getFMId, i as isObject, f as error, w as warn, h as isPlainObject, j as isRemoteInfoWithEntry, k as isPureRemoteEntry, l as getRegisteredShare, m as getInfoWithoutType, n as getPreloaded, o as setPreloaded, p as getGlobalSnapshotInfoByModuleInfo, q as setGlobalSnapshotInfoByModuleInfo, r as getGlobalSnapshot, t as getGlobalShareScope, u as addUniqueItem, v as formatShareConfigs, x as isBrowserEnv, y as getBuilderId, z as setGlobalFederationConstructor, A as getGlobalFederationInstance, B as getGlobalFederationConstructor, C as setGlobalFederationInstance } from './share.esm.js';
1
+ import { g as getGlobalHostPlugins, D as DEFAULT_REMOTE_TYPE, a as DEFAULT_SCOPE, b as globalLoading, c as getRemoteEntryExports, d as assert, s as safeToString, G as Global, e as getFMId, i as isObject, f as error, w as warn, h as isPlainObject, j as isRemoteInfoWithEntry, k as isPureRemoteEntry, l as getGlobalShare, m as getInfoWithoutType, n as getPreloaded, o as setPreloaded, p as getGlobalSnapshotInfoByModuleInfo, q as setGlobalSnapshotInfoByModuleInfo, r as getGlobalSnapshot, t as addUniqueItem, u as formatShareConfigs, v as isBrowserEnv, x as getGlobalShareScope, y as getBuilderId, z as setGlobalFederationConstructor, A as getGlobalFederationInstance, B as getGlobalFederationConstructor, C as setGlobalFederationInstance } from './share.esm.js';
2
2
  export { E as registerGlobalPlugins } from './share.esm.js';
3
- import { composeKeyWithSeparator, loadScriptNode, loadScript, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest } from '@module-federation/sdk';
4
- export { loadScript } from '@module-federation/sdk';
3
+ import { composeKeyWithSeparator, loadScript, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest } from '@module-federation/sdk';
5
4
 
6
5
  // Function to match a remote with its name and expose
7
6
  // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
@@ -119,27 +118,6 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
119
118
  if (remoteEntryExports) {
120
119
  return remoteEntryExports;
121
120
  }
122
- if (typeof document === 'undefined') {
123
- return loadScriptNode(entry, {
124
- attrs: {
125
- name,
126
- globalName
127
- },
128
- createScriptHook
129
- }).then(()=>{
130
- const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
131
- assert(entryExports, `
132
- Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
133
- Possible reasons could be:\n
134
- 1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
135
- 2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
136
- `);
137
- console.log(entryExports);
138
- return entryExports;
139
- }).catch((e)=>{
140
- return e;
141
- });
142
- }
143
121
  return loadScript(entry, {
144
122
  attrs: {},
145
123
  createScriptHook
@@ -152,8 +130,6 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
152
130
  2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
153
131
  `);
154
132
  return entryExports;
155
- }).catch((e)=>{
156
- return e;
157
133
  });
158
134
  }
159
135
  async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook }) {
@@ -212,13 +188,9 @@ let Module = class Module {
212
188
  remoteInfo: this.remoteInfo,
213
189
  remoteEntryExports: this.remoteEntryExports,
214
190
  createScriptHook: (url)=>{
215
- const res = this.loaderHook.lifecycle.createScript.emit({
191
+ const res = this.host.loaderHook.lifecycle.createScript.emit({
216
192
  url
217
193
  });
218
- if (typeof document === 'undefined') {
219
- //todo: needs real fix
220
- return res;
221
- }
222
194
  if (res instanceof HTMLScriptElement) {
223
195
  return res;
224
196
  }
@@ -234,38 +206,30 @@ let Module = class Module {
234
206
  const { loadFactory = true } = options || {
235
207
  loadFactory: true
236
208
  };
237
- this.hostInfo.name;
238
209
  // Get remoteEntry.js
239
210
  const remoteEntryExports = await this.getEntry();
240
211
  if (!this.inited) {
241
- const localShareScopeMap = this.shareScopeMap;
212
+ const globalShareScope = Global.__FEDERATION__.__SHARE__;
242
213
  const remoteShareScope = this.remoteInfo.shareScope || 'default';
243
- if (!localShareScopeMap[remoteShareScope]) {
244
- localShareScopeMap[remoteShareScope] = {};
214
+ if (!globalShareScope[remoteShareScope]) {
215
+ globalShareScope[remoteShareScope] = {};
245
216
  }
246
- const shareScope = localShareScopeMap[remoteShareScope];
247
- // TODO: compat logic , it could be moved after providing startup hooks
217
+ const shareScope = globalShareScope[remoteShareScope];
218
+ const initScope = [];
248
219
  const remoteEntryInitOptions = {
249
- version: this.remoteInfo.version || '',
250
- // @ts-ignore it will be passed by startup hooks
251
- region: this.hostInfo.region
220
+ version: this.remoteInfo.version || ''
252
221
  };
253
- remoteEntryExports.init(shareScope, [], remoteEntryInitOptions);
254
- const federationInstance = Global.__FEDERATION__.__INSTANCES__.find((i)=>i.options.id === composeKeyWithSeparator(this.remoteInfo.name, this.remoteInfo.buildVersion));
255
- if (federationInstance) {
256
- // means the instance is prev vmok instance
257
- if (!federationInstance.releaseNumber || Number(federationInstance.releaseNumber) <= 100) {
258
- // 兼容旧的生产者传参
259
- federationInstance.initOptions(_extends$4({}, remoteEntryInitOptions, {
260
- remotes: [],
261
- name: this.remoteInfo.name
262
- }));
263
- if (!__FEDERATION__.__SHARE__['default'] && this.shareScopeMap && this.shareScopeMap['default']) {
264
- // @ts-ignore compat prev logic , and it will be optimized by supporting startup hook
265
- __FEDERATION__.__SHARE__['default'] = this.shareScopeMap['default'];
266
- }
267
- }
268
- }
222
+ const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
223
+ shareScope,
224
+ remoteEntryInitOptions,
225
+ initScope,
226
+ remoteInfo: this.remoteInfo,
227
+ origin: this.host
228
+ });
229
+ remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
230
+ await this.host.hooks.lifecycle.initContainer.emit(_extends$4({}, initContainerOptions, {
231
+ remoteEntryExports
232
+ }));
269
233
  }
270
234
  this.lib = remoteEntryExports;
271
235
  this.inited = true;
@@ -278,16 +242,11 @@ let Module = class Module {
278
242
  const exposeContent = await moduleFactory();
279
243
  return exposeContent;
280
244
  }
281
- // loading: Record<string, undefined | Promise<RemoteEntryExports | void>> = {};
282
- constructor({ hostInfo, remoteInfo, shared, loaderHook, shareScopeMap }){
245
+ constructor({ remoteInfo, host }){
283
246
  this.inited = false;
284
- this.shared = {};
285
247
  this.lib = undefined;
286
- this.hostInfo = hostInfo;
287
248
  this.remoteInfo = remoteInfo;
288
- this.shared = shared;
289
- this.loaderHook = loaderHook;
290
- this.shareScopeMap = shareScopeMap;
249
+ this.host = host;
291
250
  }
292
251
  };
293
252
 
@@ -814,9 +773,9 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
814
773
  if (!shareInfo) {
815
774
  return;
816
775
  }
817
- const registeredShared = getRegisteredShare(origin.shareScopeMap, shared.sharedName, shareInfo, origin.hooks.lifecycle.resolveShare);
776
+ const globalShare = getGlobalShare(shared.sharedName, shareInfo);
818
777
  // If the global share does not exist, or the lib function does not exist, it means that the shared has not been loaded yet and can be preloaded.
819
- if (registeredShared && typeof registeredShared.lib === 'function') {
778
+ if (globalShare && typeof globalShare.lib === 'function') {
820
779
  shared.assets.js.sync.forEach((asset)=>{
821
780
  loadedSharedJsAssets.add(asset);
822
781
  });
@@ -1143,13 +1102,6 @@ function _object_without_properties_loose(source, excluded) {
1143
1102
  return target;
1144
1103
  }
1145
1104
  class FederationHost {
1146
- _setGlobalShareScopeMap() {
1147
- const globalShareScopeMap = getGlobalShareScope();
1148
- const identifier = this.options.id || this.options.name;
1149
- if (identifier && !globalShareScopeMap[identifier]) {
1150
- globalShareScopeMap[identifier] = this.shareScopeMap;
1151
- }
1152
- }
1153
1105
  initOptions(userOptions) {
1154
1106
  this.registerPlugins(userOptions.plugins);
1155
1107
  const options = this.formatOptions(this.options, userOptions);
@@ -1164,11 +1116,6 @@ class FederationHost {
1164
1116
  // 2. Searches globally for a matching share, if found, it uses it directly
1165
1117
  // 3. If not found, it retrieves it from the current share and stores the obtained share globally.
1166
1118
  const shareInfo = Object.assign({}, (_this_options_shared = this.options.shared) == null ? void 0 : _this_options_shared[pkgName], customShareInfo);
1167
- if (shareInfo == null ? void 0 : shareInfo.scope) {
1168
- shareInfo.scope.forEach((shareScope)=>{
1169
- this.initializeSharing(shareScope, shareInfo.strategy);
1170
- });
1171
- }
1172
1119
  const loadShareRes = await this.hooks.lifecycle.beforeLoadShare.emit({
1173
1120
  pkgName,
1174
1121
  shareInfo,
@@ -1179,42 +1126,30 @@ class FederationHost {
1179
1126
  // Assert that shareInfoRes exists, if not, throw an error
1180
1127
  assert(shareInfoRes, `Cannot find ${pkgName} Share in the ${this.options.name}. Please ensure that the ${pkgName} Share parameters have been injected`);
1181
1128
  // Retrieve from cache
1182
- const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
1183
- const addUseIn = (shared)=>{
1184
- if (!shared.useIn) {
1185
- shared.useIn = [];
1186
- }
1187
- addUniqueItem(shared.useIn, this.options.name);
1188
- };
1189
- if (registeredShared && registeredShared.lib) {
1190
- addUseIn(registeredShared);
1191
- return registeredShared.lib;
1192
- } else if (registeredShared && registeredShared.loading && !registeredShared.loaded) {
1193
- const factory = await registeredShared.loading;
1194
- registeredShared.loaded = true;
1195
- if (!registeredShared.lib) {
1196
- registeredShared.lib = factory;
1197
- }
1198
- addUseIn(registeredShared);
1129
+ const globalShare = getGlobalShare(pkgName, shareInfoRes);
1130
+ if (globalShare && globalShare.lib) {
1131
+ addUniqueItem(globalShare.useIn, this.options.name);
1132
+ return globalShare.lib;
1133
+ } else if (globalShare && globalShare.loading) {
1134
+ const factory = await globalShare.loading;
1135
+ addUniqueItem(globalShare.useIn, this.options.name);
1199
1136
  return factory;
1200
- } else if (registeredShared) {
1137
+ } else if (globalShare) {
1201
1138
  const asyncLoadProcess = async ()=>{
1202
- const factory = await registeredShared.get();
1139
+ const factory = await globalShare.get();
1203
1140
  shareInfoRes.lib = factory;
1204
- shareInfoRes.loaded = true;
1205
- addUseIn(shareInfoRes);
1206
- const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
1141
+ addUniqueItem(shareInfoRes.useIn, this.options.name);
1142
+ const gShared = getGlobalShare(pkgName, shareInfoRes);
1207
1143
  if (gShared) {
1208
1144
  gShared.lib = factory;
1209
- gShared.loaded = true;
1210
1145
  }
1211
1146
  return factory;
1212
1147
  };
1213
1148
  const loading = asyncLoadProcess();
1214
1149
  this.setShared({
1215
1150
  pkgName,
1216
- loaded: false,
1217
- shared: registeredShared,
1151
+ loaded: true,
1152
+ shared: shareInfoRes,
1218
1153
  from: this.options.name,
1219
1154
  lib: null,
1220
1155
  loading
@@ -1227,19 +1162,17 @@ class FederationHost {
1227
1162
  const asyncLoadProcess = async ()=>{
1228
1163
  const factory = await shareInfoRes.get();
1229
1164
  shareInfoRes.lib = factory;
1230
- shareInfoRes.loaded = true;
1231
- addUseIn(shareInfoRes);
1232
- const gShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfoRes, this.hooks.lifecycle.resolveShare);
1165
+ addUniqueItem(shareInfoRes.useIn, this.options.name);
1166
+ const gShared = getGlobalShare(pkgName, shareInfoRes);
1233
1167
  if (gShared) {
1234
1168
  gShared.lib = factory;
1235
- gShared.loaded = true;
1236
1169
  }
1237
1170
  return factory;
1238
1171
  };
1239
1172
  const loading = asyncLoadProcess();
1240
1173
  this.setShared({
1241
1174
  pkgName,
1242
- loaded: false,
1175
+ loaded: true,
1243
1176
  shared: shareInfoRes,
1244
1177
  from: this.options.name,
1245
1178
  lib: null,
@@ -1255,16 +1188,16 @@ class FederationHost {
1255
1188
  loadShareSync(pkgName) {
1256
1189
  var _this_options_shared;
1257
1190
  const shareInfo = (_this_options_shared = this.options.shared) == null ? void 0 : _this_options_shared[pkgName];
1258
- const registeredShared = getRegisteredShare(this.shareScopeMap, pkgName, shareInfo, this.hooks.lifecycle.resolveShare);
1259
- if (registeredShared && typeof registeredShared.lib === 'function') {
1260
- addUniqueItem(registeredShared.useIn, this.options.name);
1261
- if (!registeredShared.loaded) {
1262
- registeredShared.loaded = true;
1263
- if (registeredShared.from === this.options.name) {
1191
+ const globalShare = getGlobalShare(pkgName, shareInfo);
1192
+ if (globalShare && typeof globalShare.lib === 'function') {
1193
+ addUniqueItem(globalShare.useIn, this.options.name);
1194
+ if (!globalShare.loaded) {
1195
+ globalShare.loaded = true;
1196
+ if (globalShare.from === this.options.name) {
1264
1197
  shareInfo.loaded = true;
1265
1198
  }
1266
1199
  }
1267
- return registeredShared.lib;
1200
+ return globalShare.lib;
1268
1201
  }
1269
1202
  if (shareInfo.lib) {
1270
1203
  if (!shareInfo.loaded) {
@@ -1328,15 +1261,8 @@ class FederationHost {
1328
1261
  assert(remote && expose, `The 'beforeRequest' hook was executed, but it failed to return the correct 'remote' and 'expose' values while loading ${idRes}.`);
1329
1262
  let module = this.moduleCache.get(remote.name);
1330
1263
  const moduleOptions = {
1331
- hostInfo: {
1332
- name: this.options.name,
1333
- version: this.options.version || 'custom'
1334
- },
1335
- remoteInfo,
1336
- shared: this.options.shared || {},
1337
- plugins: this.options.plugins,
1338
- loaderHook: this.loaderHook,
1339
- shareScopeMap: this.shareScopeMap
1264
+ host: this,
1265
+ remoteInfo
1340
1266
  };
1341
1267
  if (!module) {
1342
1268
  module = new Module(moduleOptions);
@@ -1378,19 +1304,11 @@ class FederationHost {
1378
1304
  });
1379
1305
  return moduleOrFactory;
1380
1306
  } catch (error) {
1381
- const { from = 'runtime' } = options || {
1382
- from: 'runtime'
1383
- };
1384
- const failOver = await this.hooks.lifecycle.errorLoadRemote.emit({
1307
+ this.hooks.lifecycle.errorLoadRemote.emit({
1385
1308
  id,
1386
- error,
1387
- from,
1388
- origin: this
1309
+ error
1389
1310
  });
1390
- if (!failOver) {
1391
- throw error;
1392
- }
1393
- return failOver;
1311
+ throw error;
1394
1312
  }
1395
1313
  }
1396
1314
  // eslint-disable-next-line @typescript-eslint/member-ordering
@@ -1424,9 +1342,14 @@ class FederationHost {
1424
1342
  * It accepts one argument, the name of the share scope.
1425
1343
  * If the share scope does not exist, it creates one.
1426
1344
  */ // eslint-disable-next-line @typescript-eslint/member-ordering
1427
- initializeSharing(shareScopeName = DEFAULT_SCOPE, strategy) {
1428
- const shareScope = this.shareScopeMap;
1345
+ initializeSharing(shareScopeName = DEFAULT_SCOPE) {
1346
+ const shareScopeLoading = Global.__FEDERATION__.__SHARE_SCOPE_LOADING__;
1347
+ const shareScope = Global.__FEDERATION__.__SHARE__;
1429
1348
  const hostName = this.options.name;
1349
+ // Executes only once
1350
+ if (shareScopeLoading[shareScopeName]) {
1351
+ return shareScopeLoading[shareScopeName];
1352
+ }
1430
1353
  // Creates a new share scope if necessary
1431
1354
  if (!shareScope[shareScopeName]) {
1432
1355
  shareScope[shareScopeName] = {};
@@ -1434,27 +1357,21 @@ class FederationHost {
1434
1357
  // Executes all initialization snippets from all accessible modules
1435
1358
  const scope = shareScope[shareScopeName];
1436
1359
  const register = (name, shared)=>{
1437
- var _activeVersion_shareConfig;
1438
1360
  const { version, eager } = shared;
1439
1361
  scope[name] = scope[name] || {};
1440
1362
  const versions = scope[name];
1441
1363
  const activeVersion = versions[version];
1442
- const activeVersionEager = Boolean(activeVersion && (activeVersion.eager || ((_activeVersion_shareConfig = activeVersion.shareConfig) == null ? void 0 : _activeVersion_shareConfig.eager)));
1364
+ const activeVersionEager = Boolean(activeVersion && (activeVersion.eager || activeVersion.shareConfig.eager));
1443
1365
  if (!activeVersion || !activeVersion.loaded && (Boolean(!eager) !== !activeVersionEager ? eager : hostName > activeVersion.from)) {
1444
1366
  versions[version] = shared;
1445
1367
  }
1446
1368
  };
1447
1369
  const promises = [];
1448
- const initFn = (mod)=>mod && mod.init && mod.init(shareScope[shareScopeName]);
1449
1370
  const initRemoteModule = async (key)=>{
1450
1371
  const { module } = await this._getRemoteModuleAndOptions(key);
1451
- if (module.getEntry) {
1452
- const entry = await module.getEntry();
1453
- if (!module.inited) {
1454
- initFn(entry);
1455
- module.inited = true;
1456
- }
1457
- }
1372
+ const initFn = (mod)=>mod && mod.init && mod.init(shareScope[shareScopeName]);
1373
+ const entry = await module.getEntry();
1374
+ initFn(entry);
1458
1375
  };
1459
1376
  Object.keys(this.options.shared).forEach((shareName)=>{
1460
1377
  const shared = this.options.shared[shareName];
@@ -1462,17 +1379,15 @@ class FederationHost {
1462
1379
  register(shareName, shared);
1463
1380
  }
1464
1381
  });
1465
- if (strategy === 'version-first') {
1466
- this.options.remotes.forEach((remote)=>{
1467
- if (remote.shareScope === shareScopeName) {
1468
- promises.push(initRemoteModule(remote.name));
1469
- }
1470
- });
1382
+ this.options.remotes.forEach((remote)=>{
1383
+ if (remote.shareScope === shareScopeName) {
1384
+ promises.push(initRemoteModule(remote.name));
1385
+ }
1386
+ });
1387
+ if (!promises.length) {
1388
+ return shareScopeLoading[shareScopeName] = true;
1471
1389
  }
1472
- return promises;
1473
- }
1474
- initShareScopeMap(scopeName, shareScope) {
1475
- this.shareScopeMap[scopeName] = shareScope;
1390
+ return shareScopeLoading[shareScopeName] = Promise.all(promises).then(()=>shareScopeLoading[shareScopeName] = true);
1476
1391
  }
1477
1392
  formatOptions(globalOptions, userOptions) {
1478
1393
  const formatShareOptions = formatShareConfigs(userOptions.shared || {}, userOptions.name);
@@ -1512,17 +1427,16 @@ class FederationHost {
1512
1427
  }
1513
1428
  return res;
1514
1429
  }, globalOptionsRes.remotes);
1515
- // register shared in shareScopeMap
1430
+ // register shared include lib
1516
1431
  const sharedKeys = Object.keys(formatShareOptions);
1517
1432
  sharedKeys.forEach((sharedKey)=>{
1518
1433
  const sharedVal = formatShareOptions[sharedKey];
1519
- const registeredShared = getRegisteredShare(this.shareScopeMap, sharedKey, sharedVal, this.hooks.lifecycle.resolveShare);
1520
- if (!registeredShared && sharedVal && sharedVal.lib) {
1434
+ const globalShare = getGlobalShare(sharedKey, sharedVal);
1435
+ if (!globalShare && sharedVal && sharedVal.lib) {
1521
1436
  this.setShared({
1522
1437
  pkgName: sharedKey,
1523
1438
  lib: sharedVal.lib,
1524
1439
  get: sharedVal.get,
1525
- loaded: true,
1526
1440
  shared: sharedVal,
1527
1441
  from: userOptions.name
1528
1442
  });
@@ -1557,6 +1471,7 @@ class FederationHost {
1557
1471
  ]);
1558
1472
  }
1559
1473
  setShared({ pkgName, shared, from, lib, loading, loaded, get }) {
1474
+ const target = getGlobalShareScope();
1560
1475
  const { version, scope = 'default' } = shared, shareInfo = _object_without_properties_loose(shared, [
1561
1476
  "version",
1562
1477
  "scope"
@@ -1565,23 +1480,23 @@ class FederationHost {
1565
1480
  scope
1566
1481
  ];
1567
1482
  scopes.forEach((sc)=>{
1568
- if (!this.shareScopeMap[sc]) {
1569
- this.shareScopeMap[sc] = {};
1483
+ if (!target[sc]) {
1484
+ target[sc] = {};
1570
1485
  }
1571
- if (!this.shareScopeMap[sc][pkgName]) {
1572
- this.shareScopeMap[sc][pkgName] = {};
1486
+ if (!target[sc][pkgName]) {
1487
+ target[sc][pkgName] = {};
1573
1488
  }
1574
- if (this.shareScopeMap[sc][pkgName][version]) {
1489
+ if (target[sc][pkgName][version]) {
1575
1490
  warn(// eslint-disable-next-line max-len
1576
1491
  `The share \n ${safeToString({
1577
1492
  scope: sc,
1578
1493
  pkgName,
1579
1494
  version,
1580
- from: this.shareScopeMap[sc][pkgName][version].from
1495
+ from: target[sc][pkgName][version].from
1581
1496
  })} has been registered`);
1582
1497
  return;
1583
1498
  }
1584
- this.shareScopeMap[sc][pkgName][version] = _extends({
1499
+ target[sc][pkgName][version] = _extends({
1585
1500
  version,
1586
1501
  scope: [
1587
1502
  'default'
@@ -1592,7 +1507,7 @@ class FederationHost {
1592
1507
  loading
1593
1508
  });
1594
1509
  if (get) {
1595
- this.shareScopeMap[sc][pkgName][version].get = get;
1510
+ target[sc][pkgName][version].get = get;
1596
1511
  }
1597
1512
  });
1598
1513
  }
@@ -1602,18 +1517,18 @@ class FederationHost {
1602
1517
  init: new SyncHook(),
1603
1518
  beforeRequest: new AsyncWaterfallHook('beforeRequest'),
1604
1519
  afterResolve: new AsyncWaterfallHook('afterResolve'),
1520
+ beforeInitContainer: new AsyncWaterfallHook('beforeInitContainer'),
1521
+ initContainer: new AsyncWaterfallHook('initContainer'),
1605
1522
  onLoad: new AsyncHook('onLoad'),
1606
1523
  handlePreloadModule: new SyncHook('handlePreloadModule'),
1607
1524
  errorLoadRemote: new AsyncHook('errorLoadRemote'),
1608
1525
  beforeLoadShare: new AsyncWaterfallHook('beforeLoadShare'),
1609
1526
  loadShare: new AsyncHook(),
1610
- resolveShare: new SyncWaterfallHook('resolveShare'),
1611
1527
  beforePreloadRemote: new AsyncHook(),
1612
1528
  generatePreloadAssets: new AsyncHook('generatePreloadAssets'),
1613
1529
  afterPreloadRemote: new AsyncHook()
1614
1530
  });
1615
- this.releaseNumber = `5`;
1616
- this.version = `0.0.5`;
1531
+ this.version = '0.0.5';
1617
1532
  this.moduleCache = new Map();
1618
1533
  this.loaderHook = new PluginSystem({
1619
1534
  // FIXME: may not be suitable
@@ -1621,6 +1536,7 @@ class FederationHost {
1621
1536
  createScript: new SyncHook(),
1622
1537
  fetch: new AsyncHook('fetch')
1623
1538
  });
1539
+ this.loadingShare = {};
1624
1540
  // TODO: Validate the details of the options
1625
1541
  // Initialize options with default values
1626
1542
  const defaultOptions = {
@@ -1636,8 +1552,6 @@ class FederationHost {
1636
1552
  };
1637
1553
  this.name = userOptions.name;
1638
1554
  this.options = defaultOptions;
1639
- this.shareScopeMap = {};
1640
- this._setGlobalShareScopeMap();
1641
1555
  this.snapshotHandler = new SnapshotHandler(this);
1642
1556
  this.registerPlugins([
1643
1557
  ...defaultOptions.plugins,
package/dist/package.json CHANGED
@@ -39,8 +39,8 @@
39
39
  "helpers": [
40
40
  "./dist/helpers.cjs.d.ts"
41
41
  ],
42
- "types": [
43
- "./dist/types.cjs.d.ts"
42
+ "type": [
43
+ "./dist/type.cjs.d.ts"
44
44
  ]
45
45
  }
46
46
  },