@module-federation/runtime 0.0.0-next-20240318072254 → 0.0.0-next-20240318085858

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/README.md CHANGED
@@ -212,15 +212,15 @@ init({
212
212
  remotes: [
213
213
  {
214
214
  name: '@demo/sub1',
215
- entry: 'http://localhost:2001/mf-manifest.json',
215
+ entry: 'http://localhost:2001/vmok-manifest.json',
216
216
  },
217
217
  {
218
218
  name: '@demo/sub2',
219
- entry: 'http://localhost:2001/mf-manifest.json',
219
+ entry: 'http://localhost:2001/vmok-manifest.json',
220
220
  },
221
221
  {
222
222
  name: '@demo/sub3',
223
- entry: 'http://localhost:2001/mf-manifest.json',
223
+ entry: 'http://localhost:2001/vmok-manifest.json',
224
224
  },
225
225
  ],
226
226
  });
@@ -258,73 +258,6 @@ preloadRemote([
258
258
  ]);
259
259
  ```
260
260
 
261
- ### registerRemotes
262
-
263
- - Type: `registerRemotes(remotes: Remote[], options?: { force?: boolean }): void`
264
- - Used to register remotes after init .
265
-
266
- - Type
267
-
268
- ```typescript
269
- function registerRemotes(remotes: Remote[], options?: { force?: boolean }) {}
270
-
271
- type Remote = (RemoteWithEntry | RemoteWithVersion) & RemoteInfoCommon;
272
-
273
- interface RemoteInfoCommon {
274
- alias?: string;
275
- shareScope?: string;
276
- type?: RemoteEntryType;
277
- entryGlobalName?: string;
278
- }
279
-
280
- interface RemoteWithEntry {
281
- name: string;
282
- entry: string;
283
- }
284
-
285
- interface RemoteWithVersion {
286
- name: string;
287
- version: string;
288
- }
289
- ```
290
-
291
- - Details
292
- **info**: Please be careful when setting `force:true` !
293
-
294
- If set `force: true`, it will merge remote(include loaded remote), and remove loaded remote cache , as well as console.warn to tell this action may have risks.
295
-
296
- * Example
297
-
298
- ```ts
299
- import { init, registerRemotes } from '@module-federation/runtime';
300
-
301
- init({
302
- name: '@demo/register-new-remotes',
303
- remotes: [
304
- {
305
- name: '@demo/sub1',
306
- entry: 'http://localhost:2001/mf-manifest.json',
307
- }
308
- ],
309
- });
310
-
311
- // add new remote @demo/sub2
312
- registerRemotes([
313
- {
314
- name: '@demo/sub2',
315
- entry: 'http://localhost:2002/mf-manifest.json',
316
- }
317
- ]);
318
-
319
- // override previous remote @demo/sub1
320
- registerRemotes([
321
- {
322
- name: '@demo/sub1',
323
- entry: 'http://localhost:2003/mf-manifest.json',
324
- }
325
- ]);
326
- ```
327
-
328
261
  ## hooks
329
262
 
330
263
  Lifecycle hooks for FederationHost interaction.
package/dist/index.cjs.js CHANGED
@@ -160,13 +160,9 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
160
160
  return e;
161
161
  });
162
162
  }
163
- function getRemoteEntryUniqueKey(remoteInfo) {
164
- const { entry, name } = remoteInfo;
165
- return sdk.composeKeyWithSeparator(name, entry);
166
- }
167
163
  async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook }) {
168
164
  const { entry, name, type, entryGlobalName } = remoteInfo;
169
- const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
165
+ const uniqueKey = sdk.composeKeyWithSeparator(name, entry);
170
166
  if (remoteEntryExports) {
171
167
  return remoteEntryExports;
172
168
  }
@@ -790,7 +786,9 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
790
786
  id: assetsInfo.moduleName === '.' ? remoteInfo.name : exposeFullPath,
791
787
  name: remoteInfo.name,
792
788
  remoteSnapshot: moduleInfoSnapshot,
793
- preloadConfig
789
+ preloadConfig,
790
+ remote: remoteInfo,
791
+ origin
794
792
  });
795
793
  const preloaded = share.getPreloaded(exposeFullPath);
796
794
  if (preloaded) {
@@ -1024,14 +1022,9 @@ class SnapshotHandler {
1024
1022
  return manifestJson;
1025
1023
  }
1026
1024
  try {
1027
- const headers = sdk.getHeaders();
1028
- let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {
1029
- headers
1030
- });
1025
+ let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {});
1031
1026
  if (!res || !(res instanceof Response)) {
1032
- res = await fetch(manifestUrl, {
1033
- headers
1034
- });
1027
+ res = await fetch(manifestUrl, {});
1035
1028
  }
1036
1029
  manifestJson = await res.json();
1037
1030
  share.assert(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, `${manifestUrl} is not a federation manifest`);
@@ -1487,9 +1480,30 @@ class FederationHost {
1487
1480
  });
1488
1481
  const userRemotes = userOptionsRes.remotes || [];
1489
1482
  const remotes = userRemotes.reduce((res, remote)=>{
1490
- this.registerRemote(remote, res, {
1491
- force: false
1492
- });
1483
+ if (!res.find((item)=>item.name === remote.name)) {
1484
+ if (remote.alias) {
1485
+ // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error
1486
+ // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported
1487
+ const findEqual = res.find((item)=>{
1488
+ var _item_alias;
1489
+ return remote.alias && (item.name.startsWith(remote.alias) || ((_item_alias = item.alias) == null ? void 0 : _item_alias.startsWith(remote.alias)));
1490
+ });
1491
+ share.assert(!findEqual, `The alias ${remote.alias} of remote ${remote.name} is not allowed to be the prefix of ${findEqual && findEqual.name} name or alias`);
1492
+ }
1493
+ // Set the remote entry to a complete path
1494
+ if ('entry' in remote) {
1495
+ if (share.isBrowserEnv() && !remote.entry.startsWith('http')) {
1496
+ remote.entry = new URL(remote.entry, window.location.origin).href;
1497
+ }
1498
+ }
1499
+ if (!remote.shareScope) {
1500
+ remote.shareScope = share.DEFAULT_SCOPE;
1501
+ }
1502
+ if (!remote.type) {
1503
+ remote.type = share.DEFAULT_REMOTE_TYPE;
1504
+ }
1505
+ res.push(remote);
1506
+ }
1493
1507
  return res;
1494
1508
  }, globalOptionsRes.remotes);
1495
1509
  // register shared in shareScopeMap
@@ -1569,74 +1583,6 @@ class FederationHost {
1569
1583
  }
1570
1584
  });
1571
1585
  }
1572
- removeRemote(remote) {
1573
- const { name } = remote;
1574
- const remoteIndex = this.options.remotes.findIndex((item)=>item.name === name);
1575
- if (remoteIndex !== -1) {
1576
- this.options.remotes.splice(remoteIndex, 1);
1577
- }
1578
- const loadedModule = this.moduleCache.get(remote.name);
1579
- if (loadedModule) {
1580
- const key = loadedModule.remoteInfo.entryGlobalName;
1581
- if (globalThis[key]) {
1582
- delete globalThis[key];
1583
- }
1584
- const remoteEntryUniqueKey = getRemoteEntryUniqueKey(loadedModule.remoteInfo);
1585
- if (share.globalLoading[remoteEntryUniqueKey]) {
1586
- delete share.globalLoading[remoteEntryUniqueKey];
1587
- }
1588
- this.moduleCache.delete(remote.name);
1589
- }
1590
- }
1591
- registerRemote(remote, targetRemotes, options) {
1592
- const normalizeRemote = ()=>{
1593
- if (remote.alias) {
1594
- // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error
1595
- // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported
1596
- const findEqual = targetRemotes.find((item)=>{
1597
- var _item_alias;
1598
- return remote.alias && (item.name.startsWith(remote.alias) || ((_item_alias = item.alias) == null ? void 0 : _item_alias.startsWith(remote.alias)));
1599
- });
1600
- share.assert(!findEqual, `The alias ${remote.alias} of remote ${remote.name} is not allowed to be the prefix of ${findEqual && findEqual.name} name or alias`);
1601
- }
1602
- // Set the remote entry to a complete path
1603
- if ('entry' in remote) {
1604
- if (share.isBrowserEnv() && !remote.entry.startsWith('http')) {
1605
- remote.entry = new URL(remote.entry, window.location.origin).href;
1606
- }
1607
- }
1608
- if (!remote.shareScope) {
1609
- remote.shareScope = share.DEFAULT_SCOPE;
1610
- }
1611
- if (!remote.type) {
1612
- remote.type = share.DEFAULT_REMOTE_TYPE;
1613
- }
1614
- };
1615
- const registeredRemote = targetRemotes.find((item)=>item.name === remote.name);
1616
- if (!registeredRemote) {
1617
- normalizeRemote();
1618
- targetRemotes.push(remote);
1619
- } else {
1620
- const messages = [
1621
- `The remote "${remote.name}" is already registered.`,
1622
- (options == null ? void 0 : options.force) ? 'Hope you have known that OVERRIDE it may have some unexpected errors' : 'If you want to merge the remote, you can set "force: true".'
1623
- ];
1624
- if (options == null ? void 0 : options.force) {
1625
- // remove registered remote
1626
- this.removeRemote(registeredRemote);
1627
- normalizeRemote();
1628
- targetRemotes.push(remote);
1629
- }
1630
- share.warn(messages.join(' '));
1631
- }
1632
- }
1633
- registerRemotes(remotes, options) {
1634
- remotes.forEach((remote)=>{
1635
- this.registerRemote(remote, this.options.remotes, {
1636
- force: options == null ? void 0 : options.force
1637
- });
1638
- });
1639
- }
1640
1586
  constructor(userOptions){
1641
1587
  this.hooks = new PluginSystem({
1642
1588
  beforeInit: new SyncWaterfallHook('beforeInit'),
@@ -1661,7 +1607,7 @@ class FederationHost {
1661
1607
  // not used yet
1662
1608
  afterPreloadRemote: new AsyncHook()
1663
1609
  });
1664
- this.version = "0.0.17";
1610
+ this.version = "0.0.15";
1665
1611
  this.moduleCache = new Map();
1666
1612
  this.loaderHook = new PluginSystem({
1667
1613
  // FIXME: may not be suitable , not open to the public yet
@@ -1736,11 +1682,6 @@ function preloadRemote(...args) {
1736
1682
  // eslint-disable-next-line prefer-spread
1737
1683
  return FederationInstance.preloadRemote.apply(FederationInstance, args);
1738
1684
  }
1739
- function registerRemotes(...args) {
1740
- share.assert(FederationInstance, 'Please call init first');
1741
- // eslint-disable-next-line prefer-spread
1742
- return FederationInstance.registerRemotes.apply(FederationInstance, args);
1743
- }
1744
1685
  // Inject for debug
1745
1686
  share.setGlobalFederationConstructor(FederationHost);
1746
1687
 
@@ -1754,9 +1695,10 @@ Object.defineProperty(exports, 'loadScriptNode', {
1754
1695
  get: function () { return sdk.loadScriptNode; }
1755
1696
  });
1756
1697
  exports.FederationHost = FederationHost;
1698
+ exports.getRemoteEntry = getRemoteEntry;
1699
+ exports.getRemoteInfo = getRemoteInfo;
1757
1700
  exports.init = init;
1758
1701
  exports.loadRemote = loadRemote;
1759
1702
  exports.loadShare = loadShare;
1760
1703
  exports.loadShareSync = loadShareSync;
1761
1704
  exports.preloadRemote = preloadRemote;
1762
- exports.registerRemotes = registerRemotes;
package/dist/index.esm.js CHANGED
@@ -1,6 +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, 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 addGlobalSnapshot, r as setGlobalSnapshotInfoByModuleInfo, t as getGlobalSnapshot, G as Global, u as getGlobalShareScope, v as formatShareConfigs, x as getBuilderId, y as isBrowserEnv, z as addUniqueItem, A as setGlobalFederationConstructor, B as getGlobalFederationInstance, C as getGlobalFederationConstructor, E as setGlobalFederationInstance } from './share.esm.js';
1
+ import { g as getGlobalHostPlugins, a as globalLoading, D as DEFAULT_REMOTE_TYPE, b as DEFAULT_SCOPE, c as getRemoteEntryExports, d as assert, s as safeToString, 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 addGlobalSnapshot, r as setGlobalSnapshotInfoByModuleInfo, t as getGlobalSnapshot, G as Global, u as getGlobalShareScope, v as formatShareConfigs, x as isBrowserEnv, y as getBuilderId, z as addUniqueItem, A as setGlobalFederationConstructor, B as getGlobalFederationInstance, C as getGlobalFederationConstructor, E as setGlobalFederationInstance } from './share.esm.js';
2
2
  export { F as registerGlobalPlugins } from './share.esm.js';
3
- import { composeKeyWithSeparator, loadScriptNode, loadScript, createLink, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, getHeaders } from '@module-federation/sdk';
3
+ import { composeKeyWithSeparator, loadScriptNode, loadScript, createLink, getResourceUrl, isManifestProvider, generateSnapshotFromManifest } from '@module-federation/sdk';
4
4
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
5
5
 
6
6
  // Function to match a remote with its name and expose
@@ -158,13 +158,9 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
158
158
  return e;
159
159
  });
160
160
  }
161
- function getRemoteEntryUniqueKey(remoteInfo) {
162
- const { entry, name } = remoteInfo;
163
- return composeKeyWithSeparator(name, entry);
164
- }
165
161
  async function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook }) {
166
162
  const { entry, name, type, entryGlobalName } = remoteInfo;
167
- const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
163
+ const uniqueKey = composeKeyWithSeparator(name, entry);
168
164
  if (remoteEntryExports) {
169
165
  return remoteEntryExports;
170
166
  }
@@ -788,7 +784,9 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
788
784
  id: assetsInfo.moduleName === '.' ? remoteInfo.name : exposeFullPath,
789
785
  name: remoteInfo.name,
790
786
  remoteSnapshot: moduleInfoSnapshot,
791
- preloadConfig
787
+ preloadConfig,
788
+ remote: remoteInfo,
789
+ origin
792
790
  });
793
791
  const preloaded = getPreloaded(exposeFullPath);
794
792
  if (preloaded) {
@@ -1022,14 +1020,9 @@ class SnapshotHandler {
1022
1020
  return manifestJson;
1023
1021
  }
1024
1022
  try {
1025
- const headers = getHeaders();
1026
- let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {
1027
- headers
1028
- });
1023
+ let res = await this.loaderHook.lifecycle.fetch.emit(manifestUrl, {});
1029
1024
  if (!res || !(res instanceof Response)) {
1030
- res = await fetch(manifestUrl, {
1031
- headers
1032
- });
1025
+ res = await fetch(manifestUrl, {});
1033
1026
  }
1034
1027
  manifestJson = await res.json();
1035
1028
  assert(manifestJson.metaData && manifestJson.exposes && manifestJson.shared, `${manifestUrl} is not a federation manifest`);
@@ -1485,9 +1478,30 @@ class FederationHost {
1485
1478
  });
1486
1479
  const userRemotes = userOptionsRes.remotes || [];
1487
1480
  const remotes = userRemotes.reduce((res, remote)=>{
1488
- this.registerRemote(remote, res, {
1489
- force: false
1490
- });
1481
+ if (!res.find((item)=>item.name === remote.name)) {
1482
+ if (remote.alias) {
1483
+ // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error
1484
+ // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported
1485
+ const findEqual = res.find((item)=>{
1486
+ var _item_alias;
1487
+ return remote.alias && (item.name.startsWith(remote.alias) || ((_item_alias = item.alias) == null ? void 0 : _item_alias.startsWith(remote.alias)));
1488
+ });
1489
+ assert(!findEqual, `The alias ${remote.alias} of remote ${remote.name} is not allowed to be the prefix of ${findEqual && findEqual.name} name or alias`);
1490
+ }
1491
+ // Set the remote entry to a complete path
1492
+ if ('entry' in remote) {
1493
+ if (isBrowserEnv() && !remote.entry.startsWith('http')) {
1494
+ remote.entry = new URL(remote.entry, window.location.origin).href;
1495
+ }
1496
+ }
1497
+ if (!remote.shareScope) {
1498
+ remote.shareScope = DEFAULT_SCOPE;
1499
+ }
1500
+ if (!remote.type) {
1501
+ remote.type = DEFAULT_REMOTE_TYPE;
1502
+ }
1503
+ res.push(remote);
1504
+ }
1491
1505
  return res;
1492
1506
  }, globalOptionsRes.remotes);
1493
1507
  // register shared in shareScopeMap
@@ -1567,74 +1581,6 @@ class FederationHost {
1567
1581
  }
1568
1582
  });
1569
1583
  }
1570
- removeRemote(remote) {
1571
- const { name } = remote;
1572
- const remoteIndex = this.options.remotes.findIndex((item)=>item.name === name);
1573
- if (remoteIndex !== -1) {
1574
- this.options.remotes.splice(remoteIndex, 1);
1575
- }
1576
- const loadedModule = this.moduleCache.get(remote.name);
1577
- if (loadedModule) {
1578
- const key = loadedModule.remoteInfo.entryGlobalName;
1579
- if (globalThis[key]) {
1580
- delete globalThis[key];
1581
- }
1582
- const remoteEntryUniqueKey = getRemoteEntryUniqueKey(loadedModule.remoteInfo);
1583
- if (globalLoading[remoteEntryUniqueKey]) {
1584
- delete globalLoading[remoteEntryUniqueKey];
1585
- }
1586
- this.moduleCache.delete(remote.name);
1587
- }
1588
- }
1589
- registerRemote(remote, targetRemotes, options) {
1590
- const normalizeRemote = ()=>{
1591
- if (remote.alias) {
1592
- // Validate if alias equals the prefix of remote.name and remote.alias, if so, throw an error
1593
- // As multi-level path references cannot guarantee unique names, alias being a prefix of remote.name is not supported
1594
- const findEqual = targetRemotes.find((item)=>{
1595
- var _item_alias;
1596
- return remote.alias && (item.name.startsWith(remote.alias) || ((_item_alias = item.alias) == null ? void 0 : _item_alias.startsWith(remote.alias)));
1597
- });
1598
- assert(!findEqual, `The alias ${remote.alias} of remote ${remote.name} is not allowed to be the prefix of ${findEqual && findEqual.name} name or alias`);
1599
- }
1600
- // Set the remote entry to a complete path
1601
- if ('entry' in remote) {
1602
- if (isBrowserEnv() && !remote.entry.startsWith('http')) {
1603
- remote.entry = new URL(remote.entry, window.location.origin).href;
1604
- }
1605
- }
1606
- if (!remote.shareScope) {
1607
- remote.shareScope = DEFAULT_SCOPE;
1608
- }
1609
- if (!remote.type) {
1610
- remote.type = DEFAULT_REMOTE_TYPE;
1611
- }
1612
- };
1613
- const registeredRemote = targetRemotes.find((item)=>item.name === remote.name);
1614
- if (!registeredRemote) {
1615
- normalizeRemote();
1616
- targetRemotes.push(remote);
1617
- } else {
1618
- const messages = [
1619
- `The remote "${remote.name}" is already registered.`,
1620
- (options == null ? void 0 : options.force) ? 'Hope you have known that OVERRIDE it may have some unexpected errors' : 'If you want to merge the remote, you can set "force: true".'
1621
- ];
1622
- if (options == null ? void 0 : options.force) {
1623
- // remove registered remote
1624
- this.removeRemote(registeredRemote);
1625
- normalizeRemote();
1626
- targetRemotes.push(remote);
1627
- }
1628
- warn(messages.join(' '));
1629
- }
1630
- }
1631
- registerRemotes(remotes, options) {
1632
- remotes.forEach((remote)=>{
1633
- this.registerRemote(remote, this.options.remotes, {
1634
- force: options == null ? void 0 : options.force
1635
- });
1636
- });
1637
- }
1638
1584
  constructor(userOptions){
1639
1585
  this.hooks = new PluginSystem({
1640
1586
  beforeInit: new SyncWaterfallHook('beforeInit'),
@@ -1659,7 +1605,7 @@ class FederationHost {
1659
1605
  // not used yet
1660
1606
  afterPreloadRemote: new AsyncHook()
1661
1607
  });
1662
- this.version = "0.0.17";
1608
+ this.version = "0.0.15";
1663
1609
  this.moduleCache = new Map();
1664
1610
  this.loaderHook = new PluginSystem({
1665
1611
  // FIXME: may not be suitable , not open to the public yet
@@ -1734,12 +1680,7 @@ function preloadRemote(...args) {
1734
1680
  // eslint-disable-next-line prefer-spread
1735
1681
  return FederationInstance.preloadRemote.apply(FederationInstance, args);
1736
1682
  }
1737
- function registerRemotes(...args) {
1738
- assert(FederationInstance, 'Please call init first');
1739
- // eslint-disable-next-line prefer-spread
1740
- return FederationInstance.registerRemotes.apply(FederationInstance, args);
1741
- }
1742
1683
  // Inject for debug
1743
1684
  setGlobalFederationConstructor(FederationHost);
1744
1685
 
1745
- export { FederationHost, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerRemotes };
1686
+ export { FederationHost, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.0.17",
3
+ "version": "0.0.15",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
package/dist/share.cjs.js CHANGED
@@ -185,7 +185,7 @@ function getGlobalFederationConstructor() {
185
185
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
186
186
  if (isDebug) {
187
187
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
188
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.17";
188
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.15";
189
189
  }
190
190
  }
191
191
  // eslint-disable-next-line @typescript-eslint/ban-types
package/dist/share.esm.js CHANGED
@@ -183,7 +183,7 @@ function getGlobalFederationConstructor() {
183
183
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
184
184
  if (isDebug) {
185
185
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
186
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.17";
186
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.15";
187
187
  }
188
188
  }
189
189
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -803,4 +803,4 @@ function getGlobalShareScope() {
803
803
  return Global.__FEDERATION__.__SHARE__;
804
804
  }
805
805
 
806
- export { setGlobalFederationConstructor as A, getGlobalFederationInstance as B, getGlobalFederationConstructor as C, DEFAULT_REMOTE_TYPE as D, setGlobalFederationInstance as E, registerGlobalPlugins as F, Global as G, nativeGlobal as H, resetFederationGlobalInfo as I, getTargetSnapshotInfoByModuleInfo as J, DEFAULT_SCOPE as a, globalLoading as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k, getRegisteredShare as l, getInfoWithoutType as m, getPreloaded as n, setPreloaded as o, getGlobalSnapshotInfoByModuleInfo as p, addGlobalSnapshot as q, setGlobalSnapshotInfoByModuleInfo as r, safeToString as s, getGlobalSnapshot as t, getGlobalShareScope as u, formatShareConfigs as v, warn as w, getBuilderId as x, isBrowserEnv as y, addUniqueItem as z };
806
+ export { setGlobalFederationConstructor as A, getGlobalFederationInstance as B, getGlobalFederationConstructor as C, DEFAULT_REMOTE_TYPE as D, setGlobalFederationInstance as E, registerGlobalPlugins as F, Global as G, nativeGlobal as H, resetFederationGlobalInfo as I, getTargetSnapshotInfoByModuleInfo as J, globalLoading as a, DEFAULT_SCOPE as b, getRemoteEntryExports as c, assert as d, getFMId as e, error as f, getGlobalHostPlugins as g, isPlainObject as h, isObject as i, isRemoteInfoWithEntry as j, isPureRemoteEntry as k, getRegisteredShare as l, getInfoWithoutType as m, getPreloaded as n, setPreloaded as o, getGlobalSnapshotInfoByModuleInfo as p, addGlobalSnapshot as q, setGlobalSnapshotInfoByModuleInfo as r, safeToString as s, getGlobalSnapshot as t, getGlobalShareScope as u, formatShareConfigs as v, warn as w, isBrowserEnv as x, getBuilderId as y, addUniqueItem as z };
@@ -67,8 +67,10 @@ export declare class FederationHost {
67
67
  handlePreloadModule: SyncHook<{
68
68
  id: string;
69
69
  name: string;
70
+ remote: Remote;
70
71
  remoteSnapshot: ModuleInfo;
71
72
  preloadConfig: PreloadRemoteArgs;
73
+ origin: FederationHost;
72
74
  }, void>;
73
75
  errorLoadRemote: AsyncHook<[{
74
76
  id: string;
@@ -153,10 +155,5 @@ export declare class FederationHost {
153
155
  private formatOptions;
154
156
  private registerPlugins;
155
157
  private setShared;
156
- private removeRemote;
157
- private registerRemote;
158
- registerRemotes(remotes: Remote[], options?: {
159
- force?: boolean;
160
- }): void;
161
158
  }
162
159
  export {};
@@ -2,6 +2,7 @@ import { FederationHost } from './core';
2
2
  import { UserOptions, FederationRuntimePlugin } from './type';
3
3
  export { FederationHost } from './core';
4
4
  export { registerGlobalPlugins } from './global';
5
+ export { getRemoteEntry, getRemoteInfo } from './utils';
5
6
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
6
7
  export type { Federation } from './global';
7
8
  export type { FederationRuntimePlugin };
@@ -10,4 +11,3 @@ export declare function loadRemote(...args: Parameters<FederationHost['loadRemot
10
11
  export declare function loadShare(...args: Parameters<FederationHost['loadShare']>): ReturnType<FederationHost['loadShare']>;
11
12
  export declare function loadShareSync(...args: Parameters<FederationHost['loadShareSync']>): ReturnType<FederationHost['loadShareSync']>;
12
13
  export declare function preloadRemote(...args: Parameters<FederationHost['preloadRemote']>): ReturnType<FederationHost['preloadRemote']>;
13
- export declare function registerRemotes(...args: Parameters<FederationHost['registerRemotes']>): ReturnType<FederationHost['registerRemotes']>;
@@ -3,3 +3,4 @@ export * from './tool';
3
3
  export * from './manifest';
4
4
  export * from './logger';
5
5
  export * from './plugin';
6
+ export * from './load';
@@ -9,7 +9,6 @@ export declare function loadEntryScript({ name, globalName, entry, createScriptH
9
9
  entry: string;
10
10
  createScriptHook?: (url: string) => HTMLScriptElement | void;
11
11
  }): Promise<RemoteEntryExports>;
12
- export declare function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string;
13
12
  export declare function getRemoteEntry({ remoteEntryExports, remoteInfo, createScriptHook, }: {
14
13
  remoteInfo: RemoteInfo;
15
14
  remoteEntryExports?: RemoteEntryExports | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.0.0-next-20240318072254",
3
+ "version": "0.0.0-next-20240318085858",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.esm.js",
@@ -45,6 +45,6 @@
45
45
  }
46
46
  },
47
47
  "dependencies": {
48
- "@module-federation/sdk": "0.0.0-next-20240318072254"
48
+ "@module-federation/sdk": "0.0.0-next-20240318085858"
49
49
  }
50
50
  }