@module-federation/runtime-core 0.0.0-next-20250616233826 → 0.0.0-next-20250617063153

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.
@@ -196,7 +196,7 @@ function getGlobalFederationConstructor() {
196
196
  function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
197
197
  if (isDebug) {
198
198
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
199
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.14.3";
199
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.15.0";
200
200
  }
201
201
  }
202
202
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -1310,7 +1310,8 @@ let Module = class Module {
1310
1310
  });
1311
1311
  if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
1312
1312
  error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_002, errorCodes.runtimeDescMap, {
1313
- remoteName: name,
1313
+ hostName: this.host.name,
1314
+ remoteName: this.remoteInfo.name,
1314
1315
  remoteEntryUrl: this.remoteInfo.entry,
1315
1316
  remoteEntryKey: this.remoteInfo.entryGlobalName
1316
1317
  }));
@@ -1744,9 +1745,12 @@ function snapshotPlugin() {
1744
1745
  return {
1745
1746
  name: 'snapshot-plugin',
1746
1747
  async afterResolve (args) {
1747
- const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
1748
+ const { remote, pkgNameOrAlias, expose, origin, remoteInfo, id } = args;
1748
1749
  if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
1749
- const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(remote);
1750
+ const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
1751
+ moduleInfo: remote,
1752
+ id
1753
+ });
1750
1754
  assignRemoteInfo(remoteInfo, remoteSnapshot);
1751
1755
  // preloading assets
1752
1756
  const preloadOptions = {
@@ -2005,7 +2009,7 @@ const generatePreloadAssetsPlugin = function() {
2005
2009
 
2006
2010
  function getGlobalRemoteInfo(moduleInfo, origin) {
2007
2011
  const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
2008
- name: origin.options.name,
2012
+ name: origin.name,
2009
2013
  version: origin.options.version
2010
2014
  });
2011
2015
  // get remote detail info from global
@@ -2030,23 +2034,8 @@ function getGlobalRemoteInfo(moduleInfo, origin) {
2030
2034
  };
2031
2035
  }
2032
2036
  class SnapshotHandler {
2033
- async loadSnapshot(moduleInfo) {
2034
- const { options } = this.HostInstance;
2035
- const { hostGlobalSnapshot, remoteSnapshot, globalSnapshot } = this.getGlobalRemoteInfo(moduleInfo);
2036
- const { remoteSnapshot: globalRemoteSnapshot, globalSnapshot: globalSnapshotRes } = await this.hooks.lifecycle.loadSnapshot.emit({
2037
- options,
2038
- moduleInfo,
2039
- hostGlobalSnapshot,
2040
- remoteSnapshot,
2041
- globalSnapshot
2042
- });
2043
- return {
2044
- remoteSnapshot: globalRemoteSnapshot,
2045
- globalSnapshot: globalSnapshotRes
2046
- };
2047
- }
2048
2037
  // eslint-disable-next-line max-lines-per-function
2049
- async loadRemoteSnapshotInfo(moduleInfo) {
2038
+ async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
2050
2039
  const { options } = this.HostInstance;
2051
2040
  await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
2052
2041
  options,
@@ -2133,6 +2122,8 @@ class SnapshotHandler {
2133
2122
  }
2134
2123
  }
2135
2124
  await this.hooks.lifecycle.afterLoadSnapshot.emit({
2125
+ id,
2126
+ host: this.HostInstance,
2136
2127
  options,
2137
2128
  moduleInfo,
2138
2129
  remoteSnapshot: mSnapshot
@@ -2670,7 +2661,9 @@ class RemoteHandler {
2670
2661
  await Promise.all(preloadOps.map(async (ops)=>{
2671
2662
  const { remote } = ops;
2672
2663
  const remoteInfo = getRemoteInfo(remote);
2673
- const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo(remote);
2664
+ const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
2665
+ moduleInfo: remote
2666
+ });
2674
2667
  const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
2675
2668
  origin: host,
2676
2669
  preloadOptions: ops,
@@ -3031,7 +3024,7 @@ class FederationHost {
3031
3024
  // maybe will change, temporarily for internal use only
3032
3025
  initContainer: new AsyncWaterfallHook('initContainer')
3033
3026
  });
3034
- this.version = "0.14.3";
3027
+ this.version = "0.15.0";
3035
3028
  this.moduleCache = new Map();
3036
3029
  this.loaderHook = new PluginSystem({
3037
3030
  // FIXME: may not be suitable , not open to the public yet
package/dist/index.esm.js CHANGED
@@ -195,7 +195,7 @@ function getGlobalFederationConstructor() {
195
195
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
196
196
  if (isDebug) {
197
197
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
198
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.14.3";
198
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.15.0";
199
199
  }
200
200
  }
201
201
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -1309,7 +1309,8 @@ let Module = class Module {
1309
1309
  });
1310
1310
  if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
1311
1311
  error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
1312
- remoteName: name,
1312
+ hostName: this.host.name,
1313
+ remoteName: this.remoteInfo.name,
1313
1314
  remoteEntryUrl: this.remoteInfo.entry,
1314
1315
  remoteEntryKey: this.remoteInfo.entryGlobalName
1315
1316
  }));
@@ -1743,9 +1744,12 @@ function snapshotPlugin() {
1743
1744
  return {
1744
1745
  name: 'snapshot-plugin',
1745
1746
  async afterResolve (args) {
1746
- const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
1747
+ const { remote, pkgNameOrAlias, expose, origin, remoteInfo, id } = args;
1747
1748
  if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
1748
- const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(remote);
1749
+ const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
1750
+ moduleInfo: remote,
1751
+ id
1752
+ });
1749
1753
  assignRemoteInfo(remoteInfo, remoteSnapshot);
1750
1754
  // preloading assets
1751
1755
  const preloadOptions = {
@@ -2004,7 +2008,7 @@ const generatePreloadAssetsPlugin = function() {
2004
2008
 
2005
2009
  function getGlobalRemoteInfo(moduleInfo, origin) {
2006
2010
  const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
2007
- name: origin.options.name,
2011
+ name: origin.name,
2008
2012
  version: origin.options.version
2009
2013
  });
2010
2014
  // get remote detail info from global
@@ -2029,23 +2033,8 @@ function getGlobalRemoteInfo(moduleInfo, origin) {
2029
2033
  };
2030
2034
  }
2031
2035
  class SnapshotHandler {
2032
- async loadSnapshot(moduleInfo) {
2033
- const { options } = this.HostInstance;
2034
- const { hostGlobalSnapshot, remoteSnapshot, globalSnapshot } = this.getGlobalRemoteInfo(moduleInfo);
2035
- const { remoteSnapshot: globalRemoteSnapshot, globalSnapshot: globalSnapshotRes } = await this.hooks.lifecycle.loadSnapshot.emit({
2036
- options,
2037
- moduleInfo,
2038
- hostGlobalSnapshot,
2039
- remoteSnapshot,
2040
- globalSnapshot
2041
- });
2042
- return {
2043
- remoteSnapshot: globalRemoteSnapshot,
2044
- globalSnapshot: globalSnapshotRes
2045
- };
2046
- }
2047
2036
  // eslint-disable-next-line max-lines-per-function
2048
- async loadRemoteSnapshotInfo(moduleInfo) {
2037
+ async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
2049
2038
  const { options } = this.HostInstance;
2050
2039
  await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
2051
2040
  options,
@@ -2132,6 +2121,8 @@ class SnapshotHandler {
2132
2121
  }
2133
2122
  }
2134
2123
  await this.hooks.lifecycle.afterLoadSnapshot.emit({
2124
+ id,
2125
+ host: this.HostInstance,
2135
2126
  options,
2136
2127
  moduleInfo,
2137
2128
  remoteSnapshot: mSnapshot
@@ -2669,7 +2660,9 @@ class RemoteHandler {
2669
2660
  await Promise.all(preloadOps.map(async (ops)=>{
2670
2661
  const { remote } = ops;
2671
2662
  const remoteInfo = getRemoteInfo(remote);
2672
- const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo(remote);
2663
+ const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
2664
+ moduleInfo: remote
2665
+ });
2673
2666
  const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
2674
2667
  origin: host,
2675
2668
  preloadOptions: ops,
@@ -3030,7 +3023,7 @@ class FederationHost {
3030
3023
  // maybe will change, temporarily for internal use only
3031
3024
  initContainer: new AsyncWaterfallHook('initContainer')
3032
3025
  });
3033
- this.version = "0.14.3";
3026
+ this.version = "0.15.0";
3034
3027
  this.moduleCache = new Map();
3035
3028
  this.loaderHook = new PluginSystem({
3036
3029
  // FIXME: may not be suitable , not open to the public yet
@@ -33,6 +33,8 @@ export declare class SnapshotHandler {
33
33
  from: "global" | "manifest";
34
34
  }>;
35
35
  afterLoadSnapshot: AsyncWaterfallHook<{
36
+ id?: string;
37
+ host: FederationHost;
36
38
  options: Options;
37
39
  moduleInfo: Remote;
38
40
  remoteSnapshot: ModuleInfo;
@@ -41,11 +43,11 @@ export declare class SnapshotHandler {
41
43
  loaderHook: FederationHost['loaderHook'];
42
44
  manifestLoading: Record<string, Promise<ModuleInfo>>;
43
45
  constructor(HostInstance: FederationHost);
44
- loadSnapshot(moduleInfo: Remote): Promise<{
45
- remoteSnapshot: GlobalModuleInfo[string] | undefined;
46
- globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
47
- }>;
48
- loadRemoteSnapshotInfo(moduleInfo: Remote): Promise<{
46
+ loadRemoteSnapshotInfo({ moduleInfo, id, expose, }: {
47
+ moduleInfo: Remote;
48
+ id?: string;
49
+ expose?: string;
50
+ }): Promise<{
49
51
  remoteSnapshot: ModuleInfo;
50
52
  globalSnapshot: GlobalModuleInfo;
51
53
  }> | never;
@@ -20,6 +20,7 @@ export type LoadShareExtraOptions = {
20
20
  resolver?: (sharedOptions: ShareInfos[string]) => Shared;
21
21
  };
22
22
  export interface RemoteInfo {
23
+ alias?: string;
23
24
  name: string;
24
25
  version?: string;
25
26
  buildVersion?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime-core",
3
- "version": "0.0.0-next-20250616233826",
3
+ "version": "0.0.0-next-20250617063153",
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-20250616233826",
56
- "@module-federation/error-codes": "0.0.0-next-20250616233826"
55
+ "@module-federation/sdk": "0.0.0-next-20250617063153",
56
+ "@module-federation/error-codes": "0.0.0-next-20250617063153"
57
57
  }
58
58
  }