@module-federation/runtime-core 0.0.0-next-20250707074728 → 0.0.0-next-20250708033956

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.
@@ -943,34 +943,6 @@ function getTargetSharedOptions(options) {
943
943
  return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
944
944
  }
945
945
 
946
- const ShareUtils = {
947
- getRegisteredShare,
948
- getGlobalShareScope
949
- };
950
- const GlobalUtils = {
951
- Global,
952
- nativeGlobal,
953
- resetFederationGlobalInfo,
954
- setGlobalFederationInstance,
955
- getGlobalFederationConstructor,
956
- setGlobalFederationConstructor,
957
- getInfoWithoutType,
958
- getGlobalSnapshot,
959
- getTargetSnapshotInfoByModuleInfo,
960
- getGlobalSnapshotInfoByModuleInfo,
961
- setGlobalSnapshotInfoByModuleInfo,
962
- addGlobalSnapshot,
963
- getRemoteEntryExports,
964
- registerGlobalPlugins,
965
- getGlobalHostPlugins,
966
- getPreloaded,
967
- setPreloaded
968
- };
969
- var helpers = {
970
- global: GlobalUtils,
971
- share: ShareUtils
972
- };
973
-
974
946
  function getBuilderId() {
975
947
  //@ts-ignore
976
948
  return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
@@ -1240,6 +1212,202 @@ function getRemoteInfo(remote) {
1240
1212
  });
1241
1213
  }
1242
1214
 
1215
+ function defaultPreloadArgs(preloadConfig) {
1216
+ return polyfills._extends({
1217
+ resourceCategory: 'sync',
1218
+ share: true,
1219
+ depsRemote: true,
1220
+ prefetchInterface: false
1221
+ }, preloadConfig);
1222
+ }
1223
+ function formatPreloadArgs(remotes, preloadArgs) {
1224
+ return preloadArgs.map((args)=>{
1225
+ const remoteInfo = matchRemote(remotes, args.nameOrAlias);
1226
+ assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && sdk.safeToString({
1227
+ remoteInfo,
1228
+ remotes
1229
+ })}`);
1230
+ return {
1231
+ remote: remoteInfo,
1232
+ preloadConfig: defaultPreloadArgs(args)
1233
+ };
1234
+ });
1235
+ }
1236
+ function normalizePreloadExposes(exposes) {
1237
+ if (!exposes) {
1238
+ return [];
1239
+ }
1240
+ return exposes.map((expose)=>{
1241
+ if (expose === '.') {
1242
+ return expose;
1243
+ }
1244
+ if (expose.startsWith('./')) {
1245
+ return expose.replace('./', '');
1246
+ }
1247
+ return expose;
1248
+ });
1249
+ }
1250
+ function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
1251
+ useLinkPreload = true) {
1252
+ const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
1253
+ if (host.options.inBrowser) {
1254
+ entryAssets.forEach((asset)=>{
1255
+ const { moduleInfo } = asset;
1256
+ const module = host.moduleCache.get(remoteInfo.name);
1257
+ if (module) {
1258
+ getRemoteEntry({
1259
+ origin: host,
1260
+ remoteInfo: moduleInfo,
1261
+ remoteEntryExports: module.remoteEntryExports
1262
+ });
1263
+ } else {
1264
+ getRemoteEntry({
1265
+ origin: host,
1266
+ remoteInfo: moduleInfo,
1267
+ remoteEntryExports: undefined
1268
+ });
1269
+ }
1270
+ });
1271
+ if (useLinkPreload) {
1272
+ const defaultAttrs = {
1273
+ rel: 'preload',
1274
+ as: 'style'
1275
+ };
1276
+ cssAssets.forEach((cssUrl)=>{
1277
+ const { link: cssEl, needAttach } = sdk.createLink({
1278
+ url: cssUrl,
1279
+ cb: ()=>{
1280
+ // noop
1281
+ },
1282
+ attrs: defaultAttrs,
1283
+ createLinkHook: (url, attrs)=>{
1284
+ const res = host.loaderHook.lifecycle.createLink.emit({
1285
+ url,
1286
+ attrs
1287
+ });
1288
+ if (res instanceof HTMLLinkElement) {
1289
+ return res;
1290
+ }
1291
+ return;
1292
+ }
1293
+ });
1294
+ needAttach && document.head.appendChild(cssEl);
1295
+ });
1296
+ } else {
1297
+ const defaultAttrs = {
1298
+ rel: 'stylesheet',
1299
+ type: 'text/css'
1300
+ };
1301
+ cssAssets.forEach((cssUrl)=>{
1302
+ const { link: cssEl, needAttach } = sdk.createLink({
1303
+ url: cssUrl,
1304
+ cb: ()=>{
1305
+ // noop
1306
+ },
1307
+ attrs: defaultAttrs,
1308
+ createLinkHook: (url, attrs)=>{
1309
+ const res = host.loaderHook.lifecycle.createLink.emit({
1310
+ url,
1311
+ attrs
1312
+ });
1313
+ if (res instanceof HTMLLinkElement) {
1314
+ return res;
1315
+ }
1316
+ return;
1317
+ },
1318
+ needDeleteLink: false
1319
+ });
1320
+ needAttach && document.head.appendChild(cssEl);
1321
+ });
1322
+ }
1323
+ if (useLinkPreload) {
1324
+ const defaultAttrs = {
1325
+ rel: 'preload',
1326
+ as: 'script'
1327
+ };
1328
+ jsAssetsWithoutEntry.forEach((jsUrl)=>{
1329
+ const { link: linkEl, needAttach } = sdk.createLink({
1330
+ url: jsUrl,
1331
+ cb: ()=>{
1332
+ // noop
1333
+ },
1334
+ attrs: defaultAttrs,
1335
+ createLinkHook: (url, attrs)=>{
1336
+ const res = host.loaderHook.lifecycle.createLink.emit({
1337
+ url,
1338
+ attrs
1339
+ });
1340
+ if (res instanceof HTMLLinkElement) {
1341
+ return res;
1342
+ }
1343
+ return;
1344
+ }
1345
+ });
1346
+ needAttach && document.head.appendChild(linkEl);
1347
+ });
1348
+ } else {
1349
+ const defaultAttrs = {
1350
+ fetchpriority: 'high',
1351
+ type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
1352
+ };
1353
+ jsAssetsWithoutEntry.forEach((jsUrl)=>{
1354
+ const { script: scriptEl, needAttach } = sdk.createScript({
1355
+ url: jsUrl,
1356
+ cb: ()=>{
1357
+ // noop
1358
+ },
1359
+ attrs: defaultAttrs,
1360
+ createScriptHook: (url, attrs)=>{
1361
+ const res = host.loaderHook.lifecycle.createScript.emit({
1362
+ url,
1363
+ attrs
1364
+ });
1365
+ if (res instanceof HTMLScriptElement) {
1366
+ return res;
1367
+ }
1368
+ return;
1369
+ },
1370
+ needDeleteScript: true
1371
+ });
1372
+ needAttach && document.head.appendChild(scriptEl);
1373
+ });
1374
+ }
1375
+ }
1376
+ }
1377
+
1378
+ const ShareUtils = {
1379
+ getRegisteredShare,
1380
+ getGlobalShareScope
1381
+ };
1382
+ const GlobalUtils = {
1383
+ Global,
1384
+ nativeGlobal,
1385
+ resetFederationGlobalInfo,
1386
+ setGlobalFederationInstance,
1387
+ getGlobalFederationConstructor,
1388
+ setGlobalFederationConstructor,
1389
+ getInfoWithoutType,
1390
+ getGlobalSnapshot,
1391
+ getTargetSnapshotInfoByModuleInfo,
1392
+ getGlobalSnapshotInfoByModuleInfo,
1393
+ setGlobalSnapshotInfoByModuleInfo,
1394
+ addGlobalSnapshot,
1395
+ getRemoteEntryExports,
1396
+ registerGlobalPlugins,
1397
+ getGlobalHostPlugins,
1398
+ getPreloaded,
1399
+ setPreloaded
1400
+ };
1401
+ var helpers = {
1402
+ global: GlobalUtils,
1403
+ share: ShareUtils,
1404
+ utils: {
1405
+ matchRemoteWithNameAndExpose,
1406
+ preloadAssets,
1407
+ getRemoteInfo
1408
+ }
1409
+ };
1410
+
1243
1411
  let Module = class Module {
1244
1412
  async getEntry() {
1245
1413
  if (this.remoteEntryExports) {
@@ -1563,169 +1731,6 @@ class PluginSystem {
1563
1731
  }
1564
1732
  }
1565
1733
 
1566
- function defaultPreloadArgs(preloadConfig) {
1567
- return polyfills._extends({
1568
- resourceCategory: 'sync',
1569
- share: true,
1570
- depsRemote: true,
1571
- prefetchInterface: false
1572
- }, preloadConfig);
1573
- }
1574
- function formatPreloadArgs(remotes, preloadArgs) {
1575
- return preloadArgs.map((args)=>{
1576
- const remoteInfo = matchRemote(remotes, args.nameOrAlias);
1577
- assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && sdk.safeToString({
1578
- remoteInfo,
1579
- remotes
1580
- })}`);
1581
- return {
1582
- remote: remoteInfo,
1583
- preloadConfig: defaultPreloadArgs(args)
1584
- };
1585
- });
1586
- }
1587
- function normalizePreloadExposes(exposes) {
1588
- if (!exposes) {
1589
- return [];
1590
- }
1591
- return exposes.map((expose)=>{
1592
- if (expose === '.') {
1593
- return expose;
1594
- }
1595
- if (expose.startsWith('./')) {
1596
- return expose.replace('./', '');
1597
- }
1598
- return expose;
1599
- });
1600
- }
1601
- function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
1602
- useLinkPreload = true) {
1603
- const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
1604
- if (host.options.inBrowser) {
1605
- entryAssets.forEach((asset)=>{
1606
- const { moduleInfo } = asset;
1607
- const module = host.moduleCache.get(remoteInfo.name);
1608
- if (module) {
1609
- getRemoteEntry({
1610
- origin: host,
1611
- remoteInfo: moduleInfo,
1612
- remoteEntryExports: module.remoteEntryExports
1613
- });
1614
- } else {
1615
- getRemoteEntry({
1616
- origin: host,
1617
- remoteInfo: moduleInfo,
1618
- remoteEntryExports: undefined
1619
- });
1620
- }
1621
- });
1622
- if (useLinkPreload) {
1623
- const defaultAttrs = {
1624
- rel: 'preload',
1625
- as: 'style'
1626
- };
1627
- cssAssets.forEach((cssUrl)=>{
1628
- const { link: cssEl, needAttach } = sdk.createLink({
1629
- url: cssUrl,
1630
- cb: ()=>{
1631
- // noop
1632
- },
1633
- attrs: defaultAttrs,
1634
- createLinkHook: (url, attrs)=>{
1635
- const res = host.loaderHook.lifecycle.createLink.emit({
1636
- url,
1637
- attrs
1638
- });
1639
- if (res instanceof HTMLLinkElement) {
1640
- return res;
1641
- }
1642
- return;
1643
- }
1644
- });
1645
- needAttach && document.head.appendChild(cssEl);
1646
- });
1647
- } else {
1648
- const defaultAttrs = {
1649
- rel: 'stylesheet',
1650
- type: 'text/css'
1651
- };
1652
- cssAssets.forEach((cssUrl)=>{
1653
- const { link: cssEl, needAttach } = sdk.createLink({
1654
- url: cssUrl,
1655
- cb: ()=>{
1656
- // noop
1657
- },
1658
- attrs: defaultAttrs,
1659
- createLinkHook: (url, attrs)=>{
1660
- const res = host.loaderHook.lifecycle.createLink.emit({
1661
- url,
1662
- attrs
1663
- });
1664
- if (res instanceof HTMLLinkElement) {
1665
- return res;
1666
- }
1667
- return;
1668
- },
1669
- needDeleteLink: false
1670
- });
1671
- needAttach && document.head.appendChild(cssEl);
1672
- });
1673
- }
1674
- if (useLinkPreload) {
1675
- const defaultAttrs = {
1676
- rel: 'preload',
1677
- as: 'script'
1678
- };
1679
- jsAssetsWithoutEntry.forEach((jsUrl)=>{
1680
- const { link: linkEl, needAttach } = sdk.createLink({
1681
- url: jsUrl,
1682
- cb: ()=>{
1683
- // noop
1684
- },
1685
- attrs: defaultAttrs,
1686
- createLinkHook: (url, attrs)=>{
1687
- const res = host.loaderHook.lifecycle.createLink.emit({
1688
- url,
1689
- attrs
1690
- });
1691
- if (res instanceof HTMLLinkElement) {
1692
- return res;
1693
- }
1694
- return;
1695
- }
1696
- });
1697
- needAttach && document.head.appendChild(linkEl);
1698
- });
1699
- } else {
1700
- const defaultAttrs = {
1701
- fetchpriority: 'high',
1702
- type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
1703
- };
1704
- jsAssetsWithoutEntry.forEach((jsUrl)=>{
1705
- const { script: scriptEl, needAttach } = sdk.createScript({
1706
- url: jsUrl,
1707
- cb: ()=>{
1708
- // noop
1709
- },
1710
- attrs: defaultAttrs,
1711
- createScriptHook: (url, attrs)=>{
1712
- const res = host.loaderHook.lifecycle.createScript.emit({
1713
- url,
1714
- attrs
1715
- });
1716
- if (res instanceof HTMLScriptElement) {
1717
- return res;
1718
- }
1719
- return;
1720
- },
1721
- needDeleteScript: true
1722
- });
1723
- needAttach && document.head.appendChild(scriptEl);
1724
- });
1725
- }
1726
- }
1727
- }
1728
-
1729
1734
  function assignRemoteInfo(remoteInfo, remoteSnapshot) {
1730
1735
  const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
1731
1736
  if (!remoteEntryInfo.url) {
@@ -2918,7 +2923,7 @@ class RemoteHandler {
2918
2923
  }
2919
2924
 
2920
2925
  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
2921
- class ModuleFederation {
2926
+ class FederationHost {
2922
2927
  initOptions(userOptions) {
2923
2928
  this.registerPlugins(userOptions.plugins);
2924
2929
  const options = this.formatOptions(this.options, userOptions);
@@ -3015,11 +3020,6 @@ class ModuleFederation {
3015
3020
  registerRemotes(remotes, options) {
3016
3021
  return this.remoteHandler.registerRemotes(remotes, options);
3017
3022
  }
3018
- registerShared(shared) {
3019
- this.sharedHandler.registerShared(this.options, polyfills._extends({}, this.options, {
3020
- shared
3021
- }));
3022
- }
3023
3023
  constructor(userOptions){
3024
3024
  this.hooks = new PluginSystem({
3025
3025
  beforeInit: new SyncWaterfallHook('beforeInit'),
@@ -3081,9 +3081,9 @@ var index = /*#__PURE__*/Object.freeze({
3081
3081
  exports.loadScript = sdk.loadScript;
3082
3082
  exports.loadScriptNode = sdk.loadScriptNode;
3083
3083
  exports.CurrentGlobal = CurrentGlobal;
3084
+ exports.FederationHost = FederationHost;
3084
3085
  exports.Global = Global;
3085
3086
  exports.Module = Module;
3086
- exports.ModuleFederation = ModuleFederation;
3087
3087
  exports.addGlobalSnapshot = addGlobalSnapshot;
3088
3088
  exports.assert = assert;
3089
3089
  exports.getGlobalFederationConstructor = getGlobalFederationConstructor;
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
 
@@ -942,34 +942,6 @@ function getTargetSharedOptions(options) {
942
942
  return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
943
943
  }
944
944
 
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
945
  function getBuilderId() {
974
946
  //@ts-ignore
975
947
  return typeof FEDERATION_BUILD_IDENTIFIER !== 'undefined' ? FEDERATION_BUILD_IDENTIFIER : '';
@@ -1239,6 +1211,202 @@ function getRemoteInfo(remote) {
1239
1211
  });
1240
1212
  }
1241
1213
 
1214
+ function defaultPreloadArgs(preloadConfig) {
1215
+ return _extends({
1216
+ resourceCategory: 'sync',
1217
+ share: true,
1218
+ depsRemote: true,
1219
+ prefetchInterface: false
1220
+ }, preloadConfig);
1221
+ }
1222
+ function formatPreloadArgs(remotes, preloadArgs) {
1223
+ return preloadArgs.map((args)=>{
1224
+ const remoteInfo = matchRemote(remotes, args.nameOrAlias);
1225
+ assert(remoteInfo, `Unable to preload ${args.nameOrAlias} as it is not included in ${!remoteInfo && safeToString({
1226
+ remoteInfo,
1227
+ remotes
1228
+ })}`);
1229
+ return {
1230
+ remote: remoteInfo,
1231
+ preloadConfig: defaultPreloadArgs(args)
1232
+ };
1233
+ });
1234
+ }
1235
+ function normalizePreloadExposes(exposes) {
1236
+ if (!exposes) {
1237
+ return [];
1238
+ }
1239
+ return exposes.map((expose)=>{
1240
+ if (expose === '.') {
1241
+ return expose;
1242
+ }
1243
+ if (expose.startsWith('./')) {
1244
+ return expose.replace('./', '');
1245
+ }
1246
+ return expose;
1247
+ });
1248
+ }
1249
+ function preloadAssets(remoteInfo, host, assets, // It is used to distinguish preload from load remote parallel loading
1250
+ useLinkPreload = true) {
1251
+ const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
1252
+ if (host.options.inBrowser) {
1253
+ entryAssets.forEach((asset)=>{
1254
+ const { moduleInfo } = asset;
1255
+ const module = host.moduleCache.get(remoteInfo.name);
1256
+ if (module) {
1257
+ getRemoteEntry({
1258
+ origin: host,
1259
+ remoteInfo: moduleInfo,
1260
+ remoteEntryExports: module.remoteEntryExports
1261
+ });
1262
+ } else {
1263
+ getRemoteEntry({
1264
+ origin: host,
1265
+ remoteInfo: moduleInfo,
1266
+ remoteEntryExports: undefined
1267
+ });
1268
+ }
1269
+ });
1270
+ if (useLinkPreload) {
1271
+ const defaultAttrs = {
1272
+ rel: 'preload',
1273
+ as: 'style'
1274
+ };
1275
+ cssAssets.forEach((cssUrl)=>{
1276
+ const { link: cssEl, needAttach } = createLink({
1277
+ url: cssUrl,
1278
+ cb: ()=>{
1279
+ // noop
1280
+ },
1281
+ attrs: defaultAttrs,
1282
+ createLinkHook: (url, attrs)=>{
1283
+ const res = host.loaderHook.lifecycle.createLink.emit({
1284
+ url,
1285
+ attrs
1286
+ });
1287
+ if (res instanceof HTMLLinkElement) {
1288
+ return res;
1289
+ }
1290
+ return;
1291
+ }
1292
+ });
1293
+ needAttach && document.head.appendChild(cssEl);
1294
+ });
1295
+ } else {
1296
+ const defaultAttrs = {
1297
+ rel: 'stylesheet',
1298
+ type: 'text/css'
1299
+ };
1300
+ cssAssets.forEach((cssUrl)=>{
1301
+ const { link: cssEl, needAttach } = createLink({
1302
+ url: cssUrl,
1303
+ cb: ()=>{
1304
+ // noop
1305
+ },
1306
+ attrs: defaultAttrs,
1307
+ createLinkHook: (url, attrs)=>{
1308
+ const res = host.loaderHook.lifecycle.createLink.emit({
1309
+ url,
1310
+ attrs
1311
+ });
1312
+ if (res instanceof HTMLLinkElement) {
1313
+ return res;
1314
+ }
1315
+ return;
1316
+ },
1317
+ needDeleteLink: false
1318
+ });
1319
+ needAttach && document.head.appendChild(cssEl);
1320
+ });
1321
+ }
1322
+ if (useLinkPreload) {
1323
+ const defaultAttrs = {
1324
+ rel: 'preload',
1325
+ as: 'script'
1326
+ };
1327
+ jsAssetsWithoutEntry.forEach((jsUrl)=>{
1328
+ const { link: linkEl, needAttach } = createLink({
1329
+ url: jsUrl,
1330
+ cb: ()=>{
1331
+ // noop
1332
+ },
1333
+ attrs: defaultAttrs,
1334
+ createLinkHook: (url, attrs)=>{
1335
+ const res = host.loaderHook.lifecycle.createLink.emit({
1336
+ url,
1337
+ attrs
1338
+ });
1339
+ if (res instanceof HTMLLinkElement) {
1340
+ return res;
1341
+ }
1342
+ return;
1343
+ }
1344
+ });
1345
+ needAttach && document.head.appendChild(linkEl);
1346
+ });
1347
+ } else {
1348
+ const defaultAttrs = {
1349
+ fetchpriority: 'high',
1350
+ type: (remoteInfo == null ? void 0 : remoteInfo.type) === 'module' ? 'module' : 'text/javascript'
1351
+ };
1352
+ jsAssetsWithoutEntry.forEach((jsUrl)=>{
1353
+ const { script: scriptEl, needAttach } = createScript({
1354
+ url: jsUrl,
1355
+ cb: ()=>{
1356
+ // noop
1357
+ },
1358
+ attrs: defaultAttrs,
1359
+ createScriptHook: (url, attrs)=>{
1360
+ const res = host.loaderHook.lifecycle.createScript.emit({
1361
+ url,
1362
+ attrs
1363
+ });
1364
+ if (res instanceof HTMLScriptElement) {
1365
+ return res;
1366
+ }
1367
+ return;
1368
+ },
1369
+ needDeleteScript: true
1370
+ });
1371
+ needAttach && document.head.appendChild(scriptEl);
1372
+ });
1373
+ }
1374
+ }
1375
+ }
1376
+
1377
+ const ShareUtils = {
1378
+ getRegisteredShare,
1379
+ getGlobalShareScope
1380
+ };
1381
+ const GlobalUtils = {
1382
+ Global,
1383
+ nativeGlobal,
1384
+ resetFederationGlobalInfo,
1385
+ setGlobalFederationInstance,
1386
+ getGlobalFederationConstructor,
1387
+ setGlobalFederationConstructor,
1388
+ getInfoWithoutType,
1389
+ getGlobalSnapshot,
1390
+ getTargetSnapshotInfoByModuleInfo,
1391
+ getGlobalSnapshotInfoByModuleInfo,
1392
+ setGlobalSnapshotInfoByModuleInfo,
1393
+ addGlobalSnapshot,
1394
+ getRemoteEntryExports,
1395
+ registerGlobalPlugins,
1396
+ getGlobalHostPlugins,
1397
+ getPreloaded,
1398
+ setPreloaded
1399
+ };
1400
+ var helpers = {
1401
+ global: GlobalUtils,
1402
+ share: ShareUtils,
1403
+ utils: {
1404
+ matchRemoteWithNameAndExpose,
1405
+ preloadAssets,
1406
+ getRemoteInfo
1407
+ }
1408
+ };
1409
+
1242
1410
  let Module = class Module {
1243
1411
  async getEntry() {
1244
1412
  if (this.remoteEntryExports) {
@@ -1562,169 +1730,6 @@ class PluginSystem {
1562
1730
  }
1563
1731
  }
1564
1732
 
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
1733
  function assignRemoteInfo(remoteInfo, remoteSnapshot) {
1729
1734
  const remoteEntryInfo = getRemoteEntryInfoFromSnapshot(remoteSnapshot);
1730
1735
  if (!remoteEntryInfo.url) {
@@ -2917,7 +2922,7 @@ class RemoteHandler {
2917
2922
  }
2918
2923
 
2919
2924
  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 ModuleFederation {
2925
+ class FederationHost {
2921
2926
  initOptions(userOptions) {
2922
2927
  this.registerPlugins(userOptions.plugins);
2923
2928
  const options = this.formatOptions(this.options, userOptions);
@@ -3014,11 +3019,6 @@ class ModuleFederation {
3014
3019
  registerRemotes(remotes, options) {
3015
3020
  return this.remoteHandler.registerRemotes(remotes, options);
3016
3021
  }
3017
- registerShared(shared) {
3018
- this.sharedHandler.registerShared(this.options, _extends({}, this.options, {
3019
- shared
3020
- }));
3021
- }
3022
3022
  constructor(userOptions){
3023
3023
  this.hooks = new PluginSystem({
3024
3024
  beforeInit: new SyncWaterfallHook('beforeInit'),
@@ -3077,4 +3077,4 @@ var index = /*#__PURE__*/Object.freeze({
3077
3077
  __proto__: null
3078
3078
  });
3079
3079
 
3080
- 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 };
3080
+ 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 };
@@ -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 ModuleFederation {
9
+ export declare class FederationHost {
10
10
  options: Options;
11
11
  hooks: PluginSystem<{
12
12
  beforeInit: SyncWaterfallHook<{
13
13
  userOptions: UserOptions;
14
14
  options: Options;
15
- origin: ModuleFederation;
15
+ origin: FederationHost;
16
16
  shareInfo: ShareInfos;
17
17
  }>;
18
18
  init: SyncHook<[{
19
19
  options: Options;
20
- origin: ModuleFederation;
20
+ origin: FederationHost;
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: ModuleFederation;
27
+ origin: FederationHost;
28
28
  }>;
29
29
  initContainer: AsyncWaterfallHook<{
30
30
  shareScope: ShareScopeMap[string];
@@ -32,7 +32,7 @@ export declare class ModuleFederation {
32
32
  remoteEntryInitOptions: RemoteEntryInitOptions;
33
33
  remoteInfo: RemoteInfo;
34
34
  remoteEntryExports: RemoteEntryExports;
35
- origin: ModuleFederation;
35
+ origin: FederationHost;
36
36
  id: string;
37
37
  remoteSnapshot?: ModuleInfo;
38
38
  }>;
@@ -63,7 +63,7 @@ export declare class ModuleFederation {
63
63
  fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
64
64
  loadEntryError: AsyncHook<[{
65
65
  getRemoteEntry: typeof getRemoteEntry;
66
- origin: ModuleFederation;
66
+ origin: FederationHost;
67
67
  remoteInfo: RemoteInfo;
68
68
  remoteEntryExports?: RemoteEntryExports | undefined;
69
69
  globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
@@ -111,5 +111,4 @@ export declare class ModuleFederation {
111
111
  registerRemotes(remotes: Remote[], options?: {
112
112
  force?: boolean;
113
113
  }): void;
114
- registerShared(shared: UserOptions['shared']): void;
115
114
  }
@@ -1,13 +1,13 @@
1
- import { ModuleFederation } from './core';
1
+ import { FederationHost } from './core';
2
2
  import { RemoteEntryExports, GlobalShareScopeMap, Remote, Optional } from './type';
3
3
  import { GlobalModuleInfo, ModuleInfo } from '@module-federation/sdk';
4
- import { ModuleFederationRuntimePlugin } from './type/plugin';
4
+ import { FederationRuntimePlugin } from './type/plugin';
5
5
  export interface Federation {
6
- __GLOBAL_PLUGIN__: Array<ModuleFederationRuntimePlugin>;
6
+ __GLOBAL_PLUGIN__: Array<FederationRuntimePlugin>;
7
7
  __DEBUG_CONSTRUCTOR_VERSION__?: string;
8
8
  moduleInfo: GlobalModuleInfo;
9
- __DEBUG_CONSTRUCTOR__?: typeof ModuleFederation;
10
- __INSTANCES__: Array<ModuleFederation>;
9
+ __DEBUG_CONSTRUCTOR__?: typeof FederationHost;
10
+ __INSTANCES__: Array<FederationHost>;
11
11
  __SHARE__: GlobalShareScopeMap;
12
12
  __MANIFEST_LOADING__: Record<string, Promise<ModuleInfo>>;
13
13
  __PRELOADED_MAP__: Map<string, boolean>;
@@ -20,9 +20,9 @@ declare global {
20
20
  }
21
21
  export declare const globalLoading: Record<string, Promise<void | RemoteEntryExports> | undefined>;
22
22
  export declare function resetFederationGlobalInfo(): void;
23
- export declare function setGlobalFederationInstance(FederationInstance: ModuleFederation): void;
24
- export declare function getGlobalFederationConstructor(): typeof ModuleFederation | undefined;
25
- export declare function setGlobalFederationConstructor(FederationConstructor: typeof ModuleFederation | undefined, isDebug?: boolean): void;
23
+ export declare function setGlobalFederationInstance(FederationInstance: FederationHost): void;
24
+ export declare function getGlobalFederationConstructor(): typeof FederationHost | undefined;
25
+ export declare function setGlobalFederationConstructor(FederationConstructor: typeof FederationHost | undefined, isDebug?: boolean): void;
26
26
  export declare function getInfoWithoutType<T extends object>(target: T, key: keyof T): {
27
27
  value: T[keyof T] | undefined;
28
28
  key: string;
@@ -36,7 +36,7 @@ export declare const getRemoteEntryExports: (name: string, globalName: string |
36
36
  remoteEntryKey: string;
37
37
  entryExports: RemoteEntryExports | undefined;
38
38
  };
39
- export declare const registerGlobalPlugins: (plugins: Array<ModuleFederationRuntimePlugin>) => void;
40
- export declare const getGlobalHostPlugins: () => Array<ModuleFederationRuntimePlugin>;
39
+ export declare const registerGlobalPlugins: (plugins: Array<FederationRuntimePlugin>) => void;
40
+ export declare const getGlobalHostPlugins: () => Array<FederationRuntimePlugin>;
41
41
  export declare const getPreloaded: (id: string) => boolean | undefined;
42
42
  export declare const setPreloaded: (id: string) => Map<string, boolean>;
@@ -1,5 +1,7 @@
1
1
  import { resetFederationGlobalInfo, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
2
2
  import { getRegisteredShare, getGlobalShareScope } from './utils/share';
3
+ import { getRemoteInfo, matchRemoteWithNameAndExpose } from './utils';
4
+ import { preloadAssets } from './utils/preload';
3
5
  interface IShareUtils {
4
6
  getRegisteredShare: typeof getRegisteredShare;
5
7
  getGlobalShareScope: typeof getGlobalShareScope;
@@ -26,6 +28,11 @@ interface IGlobalUtils {
26
28
  declare const _default: {
27
29
  global: IGlobalUtils;
28
30
  share: IShareUtils;
31
+ utils: {
32
+ matchRemoteWithNameAndExpose: typeof matchRemoteWithNameAndExpose;
33
+ preloadAssets: typeof preloadAssets;
34
+ getRemoteInfo: typeof getRemoteInfo;
35
+ };
29
36
  };
30
37
  export default _default;
31
38
  export type { IGlobalUtils, IShareUtils };
@@ -1,7 +1,7 @@
1
1
  import helpers, { type IGlobalUtils, type IShareUtils } from './helpers';
2
- export { ModuleFederation } from './core';
2
+ export { FederationHost } from './core';
3
3
  export { type Federation, CurrentGlobal, Global, getGlobalFederationConstructor, setGlobalFederationInstance, setGlobalFederationConstructor, resetFederationGlobalInfo, addGlobalSnapshot, getGlobalSnapshot, getInfoWithoutType, } from './global';
4
- export type { UserOptions, ModuleFederationRuntimePlugin } from './type';
4
+ export type { UserOptions, FederationRuntimePlugin } from './type';
5
5
  export { assert } from './utils/logger';
6
6
  export { registerGlobalPlugins } from './global';
7
7
  export { getRemoteEntry, getRemoteInfo, isStaticResourcesEqual, matchRemoteWithNameAndExpose, safeWrapper, } from './utils';
@@ -1,5 +1,5 @@
1
1
  import { ModuleInfo } from '@module-federation/sdk';
2
- import { ModuleFederation } from '../core';
2
+ import { FederationHost } from '../core';
3
3
  import { RemoteEntryExports, RemoteInfo } from '../type';
4
4
  export type ModuleOptions = ConstructorParameters<typeof Module>[0];
5
5
  declare class Module {
@@ -7,10 +7,10 @@ declare class Module {
7
7
  inited: boolean;
8
8
  remoteEntryExports?: RemoteEntryExports;
9
9
  lib: RemoteEntryExports | undefined;
10
- host: ModuleFederation;
10
+ host: FederationHost;
11
11
  constructor({ remoteInfo, host, }: {
12
12
  remoteInfo: RemoteInfo;
13
- host: ModuleFederation;
13
+ host: FederationHost;
14
14
  });
15
15
  getEntry(): Promise<RemoteEntryExports>;
16
16
  get(id: string, expose: string, options?: {
@@ -1,8 +1,8 @@
1
1
  import { GlobalModuleInfo, ModuleInfo } from '@module-federation/sdk';
2
- import { ModuleFederationRuntimePlugin, PreloadAssets, PreloadOptions, RemoteInfoOptionalVersion } from '../type';
3
- import { ModuleFederation } from '../core';
2
+ import { FederationRuntimePlugin, PreloadAssets, PreloadOptions, RemoteInfoOptionalVersion } from '../type';
3
+ import { FederationHost } from '../core';
4
4
  declare global {
5
5
  var __INIT_VMOK_DEPLOY_GLOBAL_DATA__: boolean | undefined;
6
6
  }
7
- export declare function generatePreloadAssets(origin: ModuleFederation, preloadOptions: PreloadOptions[number], remote: RemoteInfoOptionalVersion, globalSnapshot: GlobalModuleInfo, remoteSnapshot: ModuleInfo): PreloadAssets;
8
- export declare const generatePreloadAssetsPlugin: () => ModuleFederationRuntimePlugin;
7
+ export declare function generatePreloadAssets(origin: FederationHost, preloadOptions: PreloadOptions[number], remote: RemoteInfoOptionalVersion, globalSnapshot: GlobalModuleInfo, remoteSnapshot: ModuleInfo): PreloadAssets;
8
+ export declare const generatePreloadAssetsPlugin: () => FederationRuntimePlugin;
@@ -2,15 +2,15 @@ import { GlobalModuleInfo, Manifest, ModuleInfo } from '@module-federation/sdk';
2
2
  import { Options, Remote } from '../../type';
3
3
  import { getGlobalSnapshot } from '../../global';
4
4
  import { PluginSystem, AsyncHook, AsyncWaterfallHook } from '../../utils/hooks';
5
- import { ModuleFederation } from '../../core';
6
- export declare function getGlobalRemoteInfo(moduleInfo: Remote, origin: ModuleFederation): {
5
+ import { FederationHost } from '../../core';
6
+ export declare function getGlobalRemoteInfo(moduleInfo: Remote, origin: FederationHost): {
7
7
  hostGlobalSnapshot: ModuleInfo | undefined;
8
8
  globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
9
9
  remoteSnapshot: GlobalModuleInfo[string] | undefined;
10
10
  };
11
11
  export declare class SnapshotHandler {
12
12
  loadingHostSnapshot: Promise<GlobalModuleInfo | void> | null;
13
- HostInstance: ModuleFederation;
13
+ HostInstance: FederationHost;
14
14
  manifestCache: Map<string, Manifest>;
15
15
  hooks: PluginSystem<{
16
16
  beforeLoadRemoteSnapshot: AsyncHook<[{
@@ -34,15 +34,15 @@ export declare class SnapshotHandler {
34
34
  }>;
35
35
  afterLoadSnapshot: AsyncWaterfallHook<{
36
36
  id?: string;
37
- host: ModuleFederation;
37
+ host: FederationHost;
38
38
  options: Options;
39
39
  moduleInfo: Remote;
40
40
  remoteSnapshot: ModuleInfo;
41
41
  }>;
42
42
  }>;
43
- loaderHook: ModuleFederation['loaderHook'];
43
+ loaderHook: FederationHost['loaderHook'];
44
44
  manifestLoading: Record<string, Promise<ModuleInfo>>;
45
- constructor(HostInstance: ModuleFederation);
45
+ constructor(HostInstance: FederationHost);
46
46
  loadRemoteSnapshotInfo({ moduleInfo, id, expose, }: {
47
47
  moduleInfo: Remote;
48
48
  id?: string;
@@ -1,5 +1,5 @@
1
1
  import { ModuleInfo } from '@module-federation/sdk';
2
- import { ModuleFederationRuntimePlugin } from '../../type/plugin';
2
+ import { FederationRuntimePlugin } from '../../type/plugin';
3
3
  import { RemoteInfo } from '../../type';
4
4
  export declare function assignRemoteInfo(remoteInfo: RemoteInfo, remoteSnapshot: ModuleInfo): void;
5
- export declare function snapshotPlugin(): ModuleFederationRuntimePlugin;
5
+ export declare function snapshotPlugin(): FederationRuntimePlugin;
@@ -1,6 +1,6 @@
1
1
  import { ModuleInfo, GlobalModuleInfo } from '@module-federation/sdk';
2
2
  import { Options, UserOptions, PreloadAssets, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, RemoteEntryExports, CallFrom } from '../type';
3
- import { ModuleFederation } from '../core';
3
+ import { FederationHost } from '../core';
4
4
  import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncHook, SyncWaterfallHook } from '../utils/hooks';
5
5
  import { Module, ModuleOptions } from '../module';
6
6
  export interface LoadRemoteMatch {
@@ -9,12 +9,12 @@ export interface LoadRemoteMatch {
9
9
  expose: string;
10
10
  remote: Remote;
11
11
  options: Options;
12
- origin: ModuleFederation;
12
+ origin: FederationHost;
13
13
  remoteInfo: RemoteInfo;
14
14
  remoteSnapshot?: ModuleInfo;
15
15
  }
16
16
  export declare class RemoteHandler {
17
- host: ModuleFederation;
17
+ host: FederationHost;
18
18
  idToRemoteMap: Record<string, {
19
19
  name: string;
20
20
  expose: string;
@@ -22,16 +22,16 @@ export declare class RemoteHandler {
22
22
  hooks: PluginSystem<{
23
23
  beforeRegisterRemote: SyncWaterfallHook<{
24
24
  remote: Remote;
25
- origin: ModuleFederation;
25
+ origin: FederationHost;
26
26
  }>;
27
27
  registerRemote: SyncWaterfallHook<{
28
28
  remote: Remote;
29
- origin: ModuleFederation;
29
+ origin: FederationHost;
30
30
  }>;
31
31
  beforeRequest: AsyncWaterfallHook<{
32
32
  id: string;
33
33
  options: Options;
34
- origin: ModuleFederation;
34
+ origin: FederationHost;
35
35
  }>;
36
36
  onLoad: AsyncHook<[{
37
37
  id: string;
@@ -39,7 +39,7 @@ export declare class RemoteHandler {
39
39
  pkgNameOrAlias: string;
40
40
  remote: Remote;
41
41
  options: ModuleOptions;
42
- origin: ModuleFederation;
42
+ origin: FederationHost;
43
43
  exposeModule: any;
44
44
  exposeModuleFactory: any;
45
45
  moduleInstance: Module;
@@ -50,7 +50,7 @@ export declare class RemoteHandler {
50
50
  remote: Remote;
51
51
  remoteSnapshot: ModuleInfo;
52
52
  preloadConfig: PreloadRemoteArgs;
53
- origin: ModuleFederation;
53
+ origin: FederationHost;
54
54
  }], void>;
55
55
  errorLoadRemote: AsyncHook<[{
56
56
  id: string;
@@ -58,15 +58,15 @@ export declare class RemoteHandler {
58
58
  options?: any;
59
59
  from: CallFrom;
60
60
  lifecycle: "beforeRequest" | "beforeLoadShare" | "afterResolve" | "onLoad";
61
- origin: ModuleFederation;
61
+ origin: FederationHost;
62
62
  }], unknown>;
63
63
  beforePreloadRemote: AsyncHook<[{
64
64
  preloadOps: Array<PreloadRemoteArgs>;
65
65
  options: Options;
66
- origin: ModuleFederation;
66
+ origin: FederationHost;
67
67
  }], false | void | Promise<false | void>>;
68
68
  generatePreloadAssets: AsyncHook<[{
69
- origin: ModuleFederation;
69
+ origin: FederationHost;
70
70
  preloadOptions: PreloadOptions[number];
71
71
  remote: Remote;
72
72
  remoteInfo: RemoteInfo;
@@ -76,15 +76,15 @@ export declare class RemoteHandler {
76
76
  afterPreloadRemote: AsyncHook<{
77
77
  preloadOps: Array<PreloadRemoteArgs>;
78
78
  options: Options;
79
- origin: ModuleFederation;
79
+ origin: FederationHost;
80
80
  }, false | void | Promise<false | void>>;
81
81
  loadEntry: AsyncHook<[{
82
- loaderHook: ModuleFederation["loaderHook"];
82
+ loaderHook: FederationHost["loaderHook"];
83
83
  remoteInfo: RemoteInfo;
84
84
  remoteEntryExports?: RemoteEntryExports;
85
85
  }], Promise<RemoteEntryExports>>;
86
86
  }>;
87
- constructor(host: ModuleFederation);
87
+ constructor(host: FederationHost);
88
88
  formatAndRegisterRemote(globalOptions: Options, userOptions: UserOptions): Remote[];
89
89
  setIdToRemoteMap(id: string, remoteMatchInfo: LoadRemoteMatch): void;
90
90
  loadRemote<T>(id: string, options?: {
@@ -1,10 +1,10 @@
1
1
  import { Federation } from '../global';
2
2
  import { Options, ShareScopeMap, ShareInfos, Shared, UserOptions, ShareStrategy, InitScope, InitTokens, CallFrom } from '../type';
3
- import { ModuleFederation } from '../core';
3
+ import { FederationHost } from '../core';
4
4
  import { PluginSystem, AsyncHook, AsyncWaterfallHook, SyncWaterfallHook } from '../utils/hooks';
5
5
  import { LoadRemoteMatch } from '../remote';
6
6
  export declare class SharedHandler {
7
- host: ModuleFederation;
7
+ host: FederationHost;
8
8
  shareScopeMap: ShareScopeMap;
9
9
  hooks: PluginSystem<{
10
10
  afterResolve: AsyncWaterfallHook<LoadRemoteMatch>;
@@ -12,9 +12,9 @@ export declare class SharedHandler {
12
12
  pkgName: string;
13
13
  shareInfo?: Shared;
14
14
  shared: Options["shared"];
15
- origin: ModuleFederation;
15
+ origin: FederationHost;
16
16
  }>;
17
- loadShare: AsyncHook<[ModuleFederation, string, ShareInfos], false | void | Promise<false | void>>;
17
+ loadShare: AsyncHook<[FederationHost, string, ShareInfos], false | void | Promise<false | void>>;
18
18
  resolveShare: SyncWaterfallHook<{
19
19
  shareScopeMap: ShareScopeMap;
20
20
  scope: string;
@@ -26,13 +26,13 @@ export declare class SharedHandler {
26
26
  initContainerShareScopeMap: SyncWaterfallHook<{
27
27
  shareScope: ShareScopeMap[string];
28
28
  options: Options;
29
- origin: ModuleFederation;
29
+ origin: FederationHost;
30
30
  scopeName: string;
31
31
  hostShareScopeMap?: ShareScopeMap;
32
32
  }>;
33
33
  }>;
34
34
  initTokens: InitTokens;
35
- constructor(host: ModuleFederation);
35
+ constructor(host: FederationHost);
36
36
  registerShared(globalOptions: Options, userOptions: UserOptions): {
37
37
  shareInfos: ShareInfos;
38
38
  shared: {
@@ -1,5 +1,5 @@
1
1
  import type { RemoteWithEntry, RemoteWithVersion, Module, RemoteEntryType } from '@module-federation/sdk';
2
- import { ModuleFederationRuntimePlugin } from './plugin';
2
+ import { FederationRuntimePlugin } from './plugin';
3
3
  export type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
4
4
  export type PartialOptional<T, K extends keyof T> = Omit<T, K> & {
5
5
  [P in K]-?: T[P];
@@ -88,7 +88,7 @@ export interface Options {
88
88
  version?: string;
89
89
  remotes: Array<Remote>;
90
90
  shared: ShareInfos;
91
- plugins: Array<ModuleFederationRuntimePlugin>;
91
+ plugins: Array<FederationRuntimePlugin>;
92
92
  inBrowser: boolean;
93
93
  shareStrategy?: ShareStrategy;
94
94
  }
@@ -1,9 +1,9 @@
1
- import { ModuleFederation } from '../core';
1
+ import { FederationHost } from '../core';
2
2
  import { Module } from '../module';
3
3
  import { SnapshotHandler } from '../plugins/snapshot/SnapshotHandler';
4
4
  import { SharedHandler } from '../shared';
5
5
  import { RemoteHandler } from '../remote';
6
- type CoreLifeCycle = ModuleFederation['hooks']['lifecycle'];
6
+ type CoreLifeCycle = FederationHost['hooks']['lifecycle'];
7
7
  type CoreLifeCyclePartial = Partial<{
8
8
  [k in keyof CoreLifeCycle]: Parameters<CoreLifeCycle[k]['on']>[0];
9
9
  }>;
@@ -27,7 +27,7 @@ type RemoteLifeCycle = RemoteHandler['hooks']['lifecycle'];
27
27
  type RemoteLifeCycleCyclePartial = Partial<{
28
28
  [k in keyof RemoteLifeCycle]: Parameters<RemoteLifeCycle[k]['on']>[0];
29
29
  }>;
30
- export type ModuleFederationRuntimePlugin = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & ModuleBridgeLifeCycleCyclePartial & {
30
+ export type FederationRuntimePlugin = CoreLifeCyclePartial & SnapshotLifeCycleCyclePartial & SharedLifeCycleCyclePartial & RemoteLifeCycleCyclePartial & ModuleLifeCycleCyclePartial & ModuleBridgeLifeCycleCyclePartial & {
31
31
  name: string;
32
32
  version?: string;
33
33
  };
@@ -1,8 +1,8 @@
1
- import { ModuleFederation } from '../core';
1
+ import { FederationHost } from '../core';
2
2
  import { Remote, RemoteEntryExports, RemoteInfo } from '../type';
3
3
  export declare function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string;
4
4
  export declare function getRemoteEntry({ origin, remoteEntryExports, remoteInfo, }: {
5
- origin: ModuleFederation;
5
+ origin: FederationHost;
6
6
  remoteInfo: RemoteInfo;
7
7
  remoteEntryExports?: RemoteEntryExports | undefined;
8
8
  }): Promise<RemoteEntryExports | false | void>;
@@ -1,4 +1,4 @@
1
- import { ModuleFederation } from '../core';
1
+ import { FederationHost } from '../core';
2
2
  import { UserOptions } from '../type';
3
3
  import { Module } from '../module';
4
- export declare function registerPlugins(plugins: UserOptions['plugins'], hookInstances: Array<ModuleFederation['hooks'] | ModuleFederation['snapshotHandler']['hooks'] | ModuleFederation['sharedHandler']['hooks'] | ModuleFederation['remoteHandler']['hooks'] | Module['host']['loaderHook'] | Module['host']['bridgeHook']>): import("../type").ModuleFederationRuntimePlugin[] | undefined;
4
+ export declare function registerPlugins(plugins: UserOptions['plugins'], hookInstances: Array<FederationHost['hooks'] | FederationHost['snapshotHandler']['hooks'] | FederationHost['sharedHandler']['hooks'] | FederationHost['remoteHandler']['hooks'] | Module['host']['loaderHook'] | Module['host']['bridgeHook']>): import("../type").FederationRuntimePlugin[] | undefined;
@@ -1,6 +1,6 @@
1
1
  import { PreloadAssets, PreloadConfig, PreloadOptions, PreloadRemoteArgs, Remote, RemoteInfo, depsPreloadArg } from '../type';
2
- import { ModuleFederation } from '../core';
2
+ import { FederationHost } from '../core';
3
3
  export declare function defaultPreloadArgs(preloadConfig: PreloadRemoteArgs | depsPreloadArg): PreloadConfig;
4
4
  export declare function formatPreloadArgs(remotes: Array<Remote>, preloadArgs: Array<PreloadRemoteArgs>): PreloadOptions;
5
5
  export declare function normalizePreloadExposes(exposes?: string[]): string[];
6
- export declare function preloadAssets(remoteInfo: RemoteInfo, host: ModuleFederation, assets: PreloadAssets, useLinkPreload?: boolean): void;
6
+ export declare function preloadAssets(remoteInfo: RemoteInfo, host: FederationHost, assets: PreloadAssets, useLinkPreload?: boolean): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime-core",
3
- "version": "0.0.0-next-20250707074728",
3
+ "version": "0.0.0-next-20250708033956",
4
4
  "type": "module",
5
5
  "author": "zhouxiao <codingzx@gmail.com>",
6
6
  "main": "./dist/index.cjs.cjs",
@@ -52,7 +52,7 @@
52
52
  }
53
53
  },
54
54
  "dependencies": {
55
- "@module-federation/sdk": "0.0.0-next-20250707074728",
56
- "@module-federation/error-codes": "0.0.0-next-20250707074728"
55
+ "@module-federation/sdk": "0.0.0-next-20250708033956",
56
+ "@module-federation/error-codes": "0.0.0-next-20250708033956"
57
57
  }
58
58
  }