@module-federation/runtime-core 0.16.0 → 0.17.1

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,5 +1,5 @@
1
1
  import { _ as _extends, a as _object_without_properties_loose } from './polyfills.esm.js';
2
- import { createLogger, isBrowserEnv, isReactNativeEnv, isDebugMode, composeKeyWithSeparator, loadScriptNode, loadScript, safeToString, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
2
+ import { createLogger, isBrowserEnv, isReactNativeEnv, isDebugMode, composeKeyWithSeparator, loadScriptNode, loadScript, createLink, createScript, safeToString, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
3
3
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
4
4
  import { getShortErrorMsg, RUNTIME_008, runtimeDescMap, RUNTIME_001, RUNTIME_002, RUNTIME_007, RUNTIME_003, RUNTIME_005, RUNTIME_006, RUNTIME_004 } from '@module-federation/error-codes';
5
5
 
@@ -14,14 +14,20 @@ function assert(condition, msg) {
14
14
  }
15
15
  function error(msg) {
16
16
  if (msg instanceof Error) {
17
- msg.message = `${LOG_CATEGORY}: ${msg.message}`;
17
+ // Check if the message already starts with the log category to avoid duplication
18
+ if (!msg.message.startsWith(LOG_CATEGORY)) {
19
+ msg.message = `${LOG_CATEGORY}: ${msg.message}`;
20
+ }
18
21
  throw msg;
19
22
  }
20
23
  throw new Error(`${LOG_CATEGORY}: ${msg}`);
21
24
  }
22
25
  function warn(msg) {
23
26
  if (msg instanceof Error) {
24
- msg.message = `${LOG_CATEGORY}: ${msg.message}`;
27
+ // Check if the message already starts with the log category to avoid duplication
28
+ if (!msg.message.startsWith(LOG_CATEGORY)) {
29
+ msg.message = `${LOG_CATEGORY}: ${msg.message}`;
30
+ }
25
31
  logger.warn(msg);
26
32
  } else {
27
33
  logger.warn(msg);
@@ -195,7 +201,7 @@ function getGlobalFederationConstructor() {
195
201
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
196
202
  if (isDebug) {
197
203
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
198
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.16.0";
204
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.17.1";
199
205
  }
200
206
  }
201
207
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -942,34 +948,6 @@ function getTargetSharedOptions(options) {
942
948
  return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
943
949
  }
944
950
 
945
- const ShareUtils = {
946
- getRegisteredShare,
947
- getGlobalShareScope
948
- };
949
- const GlobalUtils = {
950
- Global,
951
- nativeGlobal,
952
- resetFederationGlobalInfo,
953
- setGlobalFederationInstance,
954
- getGlobalFederationConstructor,
955
- setGlobalFederationConstructor,
956
- getInfoWithoutType,
957
- getGlobalSnapshot,
958
- getTargetSnapshotInfoByModuleInfo,
959
- getGlobalSnapshotInfoByModuleInfo,
960
- setGlobalSnapshotInfoByModuleInfo,
961
- addGlobalSnapshot,
962
- getRemoteEntryExports,
963
- registerGlobalPlugins,
964
- getGlobalHostPlugins,
965
- getPreloaded,
966
- setPreloaded
967
- };
968
- var helpers = {
969
- global: GlobalUtils,
970
- share: ShareUtils
971
- };
972
-
973
951
  function getBuilderId() {
974
952
  //@ts-ignore
975
953
  return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
@@ -1039,8 +1017,16 @@ function matchRemote(remotes, nameOrAlias) {
1039
1017
  return;
1040
1018
  }
1041
1019
 
1042
- function registerPlugins(plugins, hookInstances) {
1020
+ function registerPlugins(plugins, instance) {
1043
1021
  const globalPlugins = getGlobalHostPlugins();
1022
+ const hookInstances = [
1023
+ instance.hooks,
1024
+ instance.remoteHandler.hooks,
1025
+ instance.sharedHandler.hooks,
1026
+ instance.snapshotHandler.hooks,
1027
+ instance.loaderHook,
1028
+ instance.bridgeHook
1029
+ ];
1044
1030
  // Incorporate global plugins
1045
1031
  if (globalPlugins.length > 0) {
1046
1032
  globalPlugins.forEach((plugin)=>{
@@ -1052,7 +1038,7 @@ function registerPlugins(plugins, hookInstances) {
1052
1038
  if (plugins && plugins.length > 0) {
1053
1039
  plugins.forEach((plugin)=>{
1054
1040
  hookInstances.forEach((hookInstance)=>{
1055
- hookInstance.applyPlugin(plugin);
1041
+ hookInstance.applyPlugin(plugin, instance);
1056
1042
  });
1057
1043
  });
1058
1044
  }
@@ -1239,6 +1225,202 @@ function getRemoteInfo(remote) {
1239
1225
  });
1240
1226
  }
1241
1227
 
1228
+ function defaultPreloadArgs(preloadConfig) {
1229
+ return _extends({
1230
+ resourceCategory: 'sync',
1231
+ share: true,
1232
+ depsRemote: true,
1233
+ prefetchInterface: false
1234
+ }, preloadConfig);
1235
+ }
1236
+ function formatPreloadArgs(remotes, preloadArgs) {
1237
+ return preloadArgs.map((args)=>{
1238
+ const remoteInfo = matchRemote(remotes, args.nameOrAlias);
1239
+ assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && safeToString({
1240
+ remoteInfo,
1241
+ remotes
1242
+ })}`);
1243
+ return {
1244
+ remote: remoteInfo,
1245
+ preloadConfig: defaultPreloadArgs(args)
1246
+ };
1247
+ });
1248
+ }
1249
+ function normalizePreloadExposes(exposes) {
1250
+ if (!exposes) {
1251
+ return [];
1252
+ }
1253
+ return exposes.map((expose)=>{
1254
+ if (expose === '.') {
1255
+ return expose;
1256
+ }
1257
+ if (expose.startsWith('./')) {
1258
+ return expose.replace('./', '');
1259
+ }
1260
+ return expose;
1261
+ });
1262
+ }
1263
+ function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
1264
+ useLinkPreload = true) {
1265
+ const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
1266
+ if (host.options.inBrowser) {
1267
+ entryAssets.forEach((asset)=>{
1268
+ const { moduleInfo } = asset;
1269
+ const module = host.moduleCache.get(remoteInfo.name);
1270
+ if (module) {
1271
+ getRemoteEntry({
1272
+ origin: host,
1273
+ remoteInfo: moduleInfo,
1274
+ remoteEntryExports: module.remoteEntryExports
1275
+ });
1276
+ } else {
1277
+ getRemoteEntry({
1278
+ origin: host,
1279
+ remoteInfo: moduleInfo,
1280
+ remoteEntryExports: undefined
1281
+ });
1282
+ }
1283
+ });
1284
+ if (useLinkPreload) {
1285
+ const defaultAttrs = {
1286
+ rel: 'preload',
1287
+ as: 'style'
1288
+ };
1289
+ cssAssets.forEach((cssUrl)=>{
1290
+ const { link: cssEl, needAttach } = createLink({
1291
+ url: cssUrl,
1292
+ cb: ()=>{
1293
+ // noop
1294
+ },
1295
+ attrs: defaultAttrs,
1296
+ createLinkHook: (url, attrs)=>{
1297
+ const res = host.loaderHook.lifecycle.createLink.emit({
1298
+ url,
1299
+ attrs
1300
+ });
1301
+ if (res instanceof HTMLLinkElement) {
1302
+ return res;
1303
+ }
1304
+ return;
1305
+ }
1306
+ });
1307
+ needAttach && document.head.appendChild(cssEl);
1308
+ });
1309
+ } else {
1310
+ const defaultAttrs = {
1311
+ rel: 'stylesheet',
1312
+ type: 'text/css'
1313
+ };
1314
+ cssAssets.forEach((cssUrl)=>{
1315
+ const { link: cssEl, needAttach } = createLink({
1316
+ url: cssUrl,
1317
+ cb: ()=>{
1318
+ // noop
1319
+ },
1320
+ attrs: defaultAttrs,
1321
+ createLinkHook: (url, attrs)=>{
1322
+ const res = host.loaderHook.lifecycle.createLink.emit({
1323
+ url,
1324
+ attrs
1325
+ });
1326
+ if (res instanceof HTMLLinkElement) {
1327
+ return res;
1328
+ }
1329
+ return;
1330
+ },
1331
+ needDeleteLink: false
1332
+ });
1333
+ needAttach && document.head.appendChild(cssEl);
1334
+ });
1335
+ }
1336
+ if (useLinkPreload) {
1337
+ const defaultAttrs = {
1338
+ rel: 'preload',
1339
+ as: 'script'
1340
+ };
1341
+ jsAssetsWithoutEntry.forEach((jsUrl)=>{
1342
+ const { link: linkEl, needAttach } = createLink({
1343
+ url: jsUrl,
1344
+ cb: ()=>{
1345
+ // noop
1346
+ },
1347
+ attrs: defaultAttrs,
1348
+ createLinkHook: (url, attrs)=>{
1349
+ const res = host.loaderHook.lifecycle.createLink.emit({
1350
+ url,
1351
+ attrs
1352
+ });
1353
+ if (res instanceof HTMLLinkElement) {
1354
+ return res;
1355
+ }
1356
+ return;
1357
+ }
1358
+ });
1359
+ needAttach && document.head.appendChild(linkEl);
1360
+ });
1361
+ } else {
1362
+ const defaultAttrs = {
1363
+ fetchpriority: 'high',
1364
+ type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
1365
+ };
1366
+ jsAssetsWithoutEntry.forEach((jsUrl)=>{
1367
+ const { script: scriptEl, needAttach } = createScript({
1368
+ url: jsUrl,
1369
+ cb: ()=>{
1370
+ // noop
1371
+ },
1372
+ attrs: defaultAttrs,
1373
+ createScriptHook: (url, attrs)=>{
1374
+ const res = host.loaderHook.lifecycle.createScript.emit({
1375
+ url,
1376
+ attrs
1377
+ });
1378
+ if (res instanceof HTMLScriptElement) {
1379
+ return res;
1380
+ }
1381
+ return;
1382
+ },
1383
+ needDeleteScript: true
1384
+ });
1385
+ needAttach && document.head.appendChild(scriptEl);
1386
+ });
1387
+ }
1388
+ }
1389
+ }
1390
+
1391
+ const ShareUtils = {
1392
+ getRegisteredShare,
1393
+ getGlobalShareScope
1394
+ };
1395
+ const GlobalUtils = {
1396
+ Global,
1397
+ nativeGlobal,
1398
+ resetFederationGlobalInfo,
1399
+ setGlobalFederationInstance,
1400
+ getGlobalFederationConstructor,
1401
+ setGlobalFederationConstructor,
1402
+ getInfoWithoutType,
1403
+ getGlobalSnapshot,
1404
+ getTargetSnapshotInfoByModuleInfo,
1405
+ getGlobalSnapshotInfoByModuleInfo,
1406
+ setGlobalSnapshotInfoByModuleInfo,
1407
+ addGlobalSnapshot,
1408
+ getRemoteEntryExports,
1409
+ registerGlobalPlugins,
1410
+ getGlobalHostPlugins,
1411
+ getPreloaded,
1412
+ setPreloaded
1413
+ };
1414
+ var helpers = {
1415
+ global: GlobalUtils,
1416
+ share: ShareUtils,
1417
+ utils: {
1418
+ matchRemoteWithNameAndExpose,
1419
+ preloadAssets,
1420
+ getRemoteInfo
1421
+ }
1422
+ };
1423
+
1242
1424
  let Module = class Module {
1243
1425
  async getEntry() {
1244
1426
  if (this.remoteEntryExports) {
@@ -1475,7 +1657,8 @@ class SyncWaterfallHook extends SyncHook {
1475
1657
  return data;
1476
1658
  }
1477
1659
  constructor(type){
1478
- super(), this.onerror = error;
1660
+ super();
1661
+ this.onerror = error;
1479
1662
  this.type = type;
1480
1663
  }
1481
1664
  }
@@ -1513,19 +1696,21 @@ class AsyncWaterfallHook extends SyncHook {
1513
1696
  return Promise.resolve(data);
1514
1697
  }
1515
1698
  constructor(type){
1516
- super(), this.onerror = error;
1699
+ super();
1700
+ this.onerror = error;
1517
1701
  this.type = type;
1518
1702
  }
1519
1703
  }
1520
1704
 
1521
1705
  class PluginSystem {
1522
- applyPlugin(plugin) {
1706
+ applyPlugin(plugin, instance) {
1523
1707
  assert(isPlainObject(plugin), 'Plugin configuration is invalid.');
1524
1708
  // The plugin's name is mandatory and must be unique
1525
1709
  const pluginName = plugin.name;
1526
1710
  assert(pluginName, 'A name must be provided by the plugin.');
1527
1711
  if (!this.registerPlugins[pluginName]) {
1528
1712
  this.registerPlugins[pluginName] = plugin;
1713
+ plugin.apply == null ? void 0 : plugin.apply.call(plugin, instance);
1529
1714
  Object.keys(this.lifecycle).forEach((key)=>{
1530
1715
  const pluginLife = plugin[key];
1531
1716
  if (pluginLife) {
@@ -1544,17 +1729,6 @@ class PluginSystem {
1544
1729
  }
1545
1730
  });
1546
1731
  }
1547
- // eslint-disable-next-line @typescript-eslint/no-shadow
1548
- inherit({ lifecycle, registerPlugins }) {
1549
- Object.keys(lifecycle).forEach((hookName)=>{
1550
- assert(!this.lifecycle[hookName], `The hook "${hookName}" has a conflict and cannot be inherited.`);
1551
- this.lifecycle[hookName] = lifecycle[hookName];
1552
- });
1553
- Object.keys(registerPlugins).forEach((pluginName)=>{
1554
- assert(!this.registerPlugins[pluginName], `The plugin "${pluginName}" has a conflict and cannot be inherited.`);
1555
- this.applyPlugin(registerPlugins[pluginName]);
1556
- });
1557
- }
1558
1732
  constructor(lifecycle){
1559
1733
  this.registerPlugins = {};
1560
1734
  this.lifecycle = lifecycle;
@@ -1562,169 +1736,6 @@ class PluginSystem {
1562
1736
  }
1563
1737
  }
1564
1738
 
1565
- function defaultPreloadArgs(preloadConfig) {
1566
- return _extends({
1567
- resourceCategory: 'sync',
1568
- share: true,
1569
- depsRemote: true,
1570
- prefetchInterface: false
1571
- }, preloadConfig);
1572
- }
1573
- function formatPreloadArgs(remotes, preloadArgs) {
1574
- return preloadArgs.map((args)=>{
1575
- const remoteInfo = matchRemote(remotes, args.nameOrAlias);
1576
- assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && safeToString({
1577
- remoteInfo,
1578
- remotes
1579
- })}`);
1580
- return {
1581
- remote: remoteInfo,
1582
- preloadConfig: defaultPreloadArgs(args)
1583
- };
1584
- });
1585
- }
1586
- function normalizePreloadExposes(exposes) {
1587
- if (!exposes) {
1588
- return [];
1589
- }
1590
- return exposes.map((expose)=>{
1591
- if (expose === '.') {
1592
- return expose;
1593
- }
1594
- if (expose.startsWith('./')) {
1595
- return expose.replace('./', '');
1596
- }
1597
- return expose;
1598
- });
1599
- }
1600
- function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
1601
- useLinkPreload = true) {
1602
- const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
1603
- if (host.options.inBrowser) {
1604
- entryAssets.forEach((asset)=>{
1605
- const { moduleInfo } = asset;
1606
- const module = host.moduleCache.get(remoteInfo.name);
1607
- if (module) {
1608
- getRemoteEntry({
1609
- origin: host,
1610
- remoteInfo: moduleInfo,
1611
- remoteEntryExports: module.remoteEntryExports
1612
- });
1613
- } else {
1614
- getRemoteEntry({
1615
- origin: host,
1616
- remoteInfo: moduleInfo,
1617
- remoteEntryExports: undefined
1618
- });
1619
- }
1620
- });
1621
- if (useLinkPreload) {
1622
- const defaultAttrs = {
1623
- rel: 'preload',
1624
- as: 'style'
1625
- };
1626
- cssAssets.forEach((cssUrl)=>{
1627
- const { link: cssEl, needAttach } = createLink({
1628
- url: cssUrl,
1629
- cb: ()=>{
1630
- // noop
1631
- },
1632
- attrs: defaultAttrs,
1633
- createLinkHook: (url, attrs)=>{
1634
- const res = host.loaderHook.lifecycle.createLink.emit({
1635
- url,
1636
- attrs
1637
- });
1638
- if (res instanceof HTMLLinkElement) {
1639
- return res;
1640
- }
1641
- return;
1642
- }
1643
- });
1644
- needAttach && document.head.appendChild(cssEl);
1645
- });
1646
- } else {
1647
- const defaultAttrs = {
1648
- rel: 'stylesheet',
1649
- type: 'text/css'
1650
- };
1651
- cssAssets.forEach((cssUrl)=>{
1652
- const { link: cssEl, needAttach } = createLink({
1653
- url: cssUrl,
1654
- cb: ()=>{
1655
- // noop
1656
- },
1657
- attrs: defaultAttrs,
1658
- createLinkHook: (url, attrs)=>{
1659
- const res = host.loaderHook.lifecycle.createLink.emit({
1660
- url,
1661
- attrs
1662
- });
1663
- if (res instanceof HTMLLinkElement) {
1664
- return res;
1665
- }
1666
- return;
1667
- },
1668
- needDeleteLink: false
1669
- });
1670
- needAttach && document.head.appendChild(cssEl);
1671
- });
1672
- }
1673
- if (useLinkPreload) {
1674
- const defaultAttrs = {
1675
- rel: 'preload',
1676
- as: 'script'
1677
- };
1678
- jsAssetsWithoutEntry.forEach((jsUrl)=>{
1679
- const { link: linkEl, needAttach } = createLink({
1680
- url: jsUrl,
1681
- cb: ()=>{
1682
- // noop
1683
- },
1684
- attrs: defaultAttrs,
1685
- createLinkHook: (url, attrs)=>{
1686
- const res = host.loaderHook.lifecycle.createLink.emit({
1687
- url,
1688
- attrs
1689
- });
1690
- if (res instanceof HTMLLinkElement) {
1691
- return res;
1692
- }
1693
- return;
1694
- }
1695
- });
1696
- needAttach && document.head.appendChild(linkEl);
1697
- });
1698
- } else {
1699
- const defaultAttrs = {
1700
- fetchpriority: 'high',
1701
- type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
1702
- };
1703
- jsAssetsWithoutEntry.forEach((jsUrl)=>{
1704
- const { script: scriptEl, needAttach } = createScript({
1705
- url: jsUrl,
1706
- cb: ()=>{
1707
- // noop
1708
- },
1709
- attrs: defaultAttrs,
1710
- createScriptHook: (url, attrs)=>{
1711
- const res = host.loaderHook.lifecycle.createScript.emit({
1712
- url,
1713
- attrs
1714
- });
1715
- if (res instanceof HTMLScriptElement) {
1716
- return res;
1717
- }
1718
- return;
1719
- },
1720
- needDeleteScript: true
1721
- });
1722
- needAttach && document.head.appendChild(scriptEl);
1723
- });
1724
- }
1725
- }
1726
- }
1727
-
1728
1739
  function assignRemoteInfo(remoteInfo, remoteSnapshot) {
1729
1740
  const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
1730
1741
  if (!remoteEntryInfo.url) {
@@ -1930,7 +1941,7 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
1930
1941
  }
1931
1942
  }
1932
1943
  }, true, memo, remoteSnapshot);
1933
- if (remoteSnapshot.shared) {
1944
+ if (remoteSnapshot.shared && remoteSnapshot.shared.length > 0) {
1934
1945
  const collectSharedAssets = (shareInfo, snapshotShared)=>{
1935
1946
  const registeredShared = getRegisteredShare(origin.shareScopeMap, snapshotShared.sharedName, shareInfo, origin.sharedHandler.hooks.lifecycle.resolveShare);
1936
1947
  // 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.
@@ -2286,6 +2297,7 @@ class SharedHandler {
2286
2297
  if (gShared) {
2287
2298
  gShared.lib = factory;
2288
2299
  gShared.loaded = true;
2300
+ addUseIn(gShared);
2289
2301
  }
2290
2302
  return factory;
2291
2303
  };
@@ -2328,10 +2340,10 @@ class SharedHandler {
2328
2340
  }
2329
2341
  }
2330
2342
  /**
2331
- * This function initializes the sharing sequence (executed only once per share scope).
2332
- * It accepts one argument, the name of the share scope.
2333
- * If the share scope does not exist, it creates one.
2334
- */ // eslint-disable-next-line @typescript-eslint/member-ordering
2343
+ * This function initializes the sharing sequence (executed only once per share scope).
2344
+ * It accepts one argument, the name of the share scope.
2345
+ * If the share scope does not exist, it creates one.
2346
+ */ // eslint-disable-next-line @typescript-eslint/member-ordering
2335
2347
  initializeSharing(shareScopeName = DEFAULT_SCOPE, extraOptions) {
2336
2348
  const { host } = this;
2337
2349
  const from = extraOptions == null ? void 0 : extraOptions.from;
@@ -2917,7 +2929,7 @@ class RemoteHandler {
2917
2929
  }
2918
2930
 
2919
2931
  const USE_SNAPSHOT = typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === 'boolean' ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true; // Default to true (use snapshot) when not explicitly defined
2920
- class FederationHost {
2932
+ class ModuleFederation {
2921
2933
  initOptions(userOptions) {
2922
2934
  this.registerPlugins(userOptions.plugins);
2923
2935
  const options = this.formatOptions(this.options, userOptions);
@@ -2994,14 +3006,7 @@ class FederationHost {
2994
3006
  return optionsRes;
2995
3007
  }
2996
3008
  registerPlugins(plugins) {
2997
- const pluginRes = registerPlugins(plugins, [
2998
- this.hooks,
2999
- this.remoteHandler.hooks,
3000
- this.sharedHandler.hooks,
3001
- this.snapshotHandler.hooks,
3002
- this.loaderHook,
3003
- this.bridgeHook
3004
- ]);
3009
+ const pluginRes = registerPlugins(plugins, this);
3005
3010
  // Merge plugin
3006
3011
  this.options.plugins = this.options.plugins.reduce((res, plugin)=>{
3007
3012
  if (!plugin) return res;
@@ -3014,6 +3019,11 @@ class FederationHost {
3014
3019
  registerRemotes(remotes, options) {
3015
3020
  return this.remoteHandler.registerRemotes(remotes, options);
3016
3021
  }
3022
+ registerShared(shared) {
3023
+ this.sharedHandler.registerShared(this.options, _extends({}, this.options, {
3024
+ shared
3025
+ }));
3026
+ }
3017
3027
  constructor(userOptions){
3018
3028
  this.hooks = new PluginSystem({
3019
3029
  beforeInit: new SyncWaterfallHook('beforeInit'),
@@ -3023,7 +3033,7 @@ class FederationHost {
3023
3033
  // maybe will change, temporarily for internal use only
3024
3034
  initContainer: new AsyncWaterfallHook('initContainer')
3025
3035
  });
3026
- this.version = "0.16.0";
3036
+ this.version = "0.17.1";
3027
3037
  this.moduleCache = new Map();
3028
3038
  this.loaderHook = new PluginSystem({
3029
3039
  // FIXME: may not be suitable , not open to the public yet
@@ -3069,7 +3079,7 @@ class FederationHost {
3069
3079
  }
3070
3080
 
3071
3081
  var index = /*#__PURE__*/Object.freeze({
3072
- __proto__: null
3082
+ __proto__: null
3073
3083
  });
3074
3084
 
3075
- export { CurrentGlobal, FederationHost, Global, Module, addGlobalSnapshot, assert, getGlobalFederationConstructor, getGlobalSnapshot, getInfoWithoutType, getRegisteredShare, getRemoteEntry, getRemoteInfo, helpers, isStaticResourcesEqual, matchRemoteWithNameAndExpose, registerGlobalPlugins, resetFederationGlobalInfo, safeWrapper, satisfy, setGlobalFederationConstructor, setGlobalFederationInstance, index as types };
3085
+ export { CurrentGlobal, Global, Module, ModuleFederation, addGlobalSnapshot, assert, getGlobalFederationConstructor, getGlobalSnapshot, getInfoWithoutType, getRegisteredShare, getRemoteEntry, getRemoteInfo, helpers, isStaticResourcesEqual, matchRemoteWithNameAndExpose, registerGlobalPlugins, resetFederationGlobalInfo, safeWrapper, satisfy, setGlobalFederationConstructor, setGlobalFederationInstance, index as types };
@@ -6,25 +6,25 @@ import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHoo
6
6
  import { SnapshotHandler } from './plugins/snapshot/SnapshotHandler';
7
7
  import { SharedHandler } from './shared';
8
8
  import { RemoteHandler } from './remote';
9
- export declare class FederationHost {
9
+ export declare class ModuleFederation {
10
10
  options: Options;
11
11
  hooks: PluginSystem<{
12
12
  beforeInit: SyncWaterfallHook<{
13
13
  userOptions: UserOptions;
14
14
  options: Options;
15
- origin: FederationHost;
15
+ origin: ModuleFederation;
16
16
  shareInfo: ShareInfos;
17
17
  }>;
18
18
  init: SyncHook<[{
19
19
  options: Options;
20
- origin: FederationHost;
20
+ origin: ModuleFederation;
21
21
  }], void>;
22
22
  beforeInitContainer: AsyncWaterfallHook<{
23
23
  shareScope: ShareScopeMap[string];
24
24
  initScope: InitScope;
25
25
  remoteEntryInitOptions: RemoteEntryInitOptions;
26
26
  remoteInfo: RemoteInfo;
27
- origin: FederationHost;
27
+ origin: ModuleFederation;
28
28
  }>;
29
29
  initContainer: AsyncWaterfallHook<{
30
30
  shareScope: ShareScopeMap[string];
@@ -32,7 +32,7 @@ export declare class FederationHost {
32
32
  remoteEntryInitOptions: RemoteEntryInitOptions;
33
33
  remoteInfo: RemoteInfo;
34
34
  remoteEntryExports: RemoteEntryExports;
35
- origin: FederationHost;
35
+ origin: ModuleFederation;
36
36
  id: string;
37
37
  remoteSnapshot?: ModuleInfo;
38
38
  }>;
@@ -63,7 +63,7 @@ export declare class FederationHost {
63
63
  fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
64
64
  loadEntryError: AsyncHook<[{
65
65
  getRemoteEntry: typeof getRemoteEntry;
66
- origin: FederationHost;
66
+ origin: ModuleFederation;
67
67
  remoteInfo: RemoteInfo;
68
68
  remoteEntryExports?: RemoteEntryExports | undefined;
69
69
  globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
@@ -111,4 +111,5 @@ export declare class FederationHost {
111
111
  registerRemotes(remotes: Remote[], options?: {
112
112
  force?: boolean;
113
113
  }): void;
114
+ registerShared(shared: UserOptions['shared']): void;
114
115
  }