@module-federation/runtime-core 0.0.0-next-20250526074234 → 0.0.0-next-20250527065931

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.
@@ -1691,12 +1691,9 @@ function snapshotPlugin() {
1691
1691
  return {
1692
1692
  name: 'snapshot-plugin',
1693
1693
  async afterResolve (args) {
1694
- const { remote, pkgNameOrAlias, expose, origin, remoteInfo, id } = args;
1694
+ const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
1695
1695
  if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
1696
- const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
1697
- moduleInfo: remote,
1698
- id
1699
- });
1696
+ const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(remote);
1700
1697
  assignRemoteInfo(remoteInfo, remoteSnapshot);
1701
1698
  // preloading assets
1702
1699
  const preloadOptions = {
@@ -1955,7 +1952,7 @@ const generatePreloadAssetsPlugin = function() {
1955
1952
 
1956
1953
  function getGlobalRemoteInfo(moduleInfo, origin) {
1957
1954
  const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
1958
- name: origin.name,
1955
+ name: origin.options.name,
1959
1956
  version: origin.options.version
1960
1957
  });
1961
1958
  // get remote detail info from global
@@ -1980,8 +1977,23 @@ function getGlobalRemoteInfo(moduleInfo, origin) {
1980
1977
  };
1981
1978
  }
1982
1979
  class SnapshotHandler {
1980
+ async loadSnapshot(moduleInfo) {
1981
+ const { options } = this.HostInstance;
1982
+ const { hostGlobalSnapshot, remoteSnapshot, globalSnapshot } = this.getGlobalRemoteInfo(moduleInfo);
1983
+ const { remoteSnapshot: globalRemoteSnapshot, globalSnapshot: globalSnapshotRes } = await this.hooks.lifecycle.loadSnapshot.emit({
1984
+ options,
1985
+ moduleInfo,
1986
+ hostGlobalSnapshot,
1987
+ remoteSnapshot,
1988
+ globalSnapshot
1989
+ });
1990
+ return {
1991
+ remoteSnapshot: globalRemoteSnapshot,
1992
+ globalSnapshot: globalSnapshotRes
1993
+ };
1994
+ }
1983
1995
  // eslint-disable-next-line max-lines-per-function
1984
- async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
1996
+ async loadRemoteSnapshotInfo(moduleInfo) {
1985
1997
  const { options } = this.HostInstance;
1986
1998
  await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
1987
1999
  options,
@@ -2068,8 +2080,6 @@ class SnapshotHandler {
2068
2080
  }
2069
2081
  }
2070
2082
  await this.hooks.lifecycle.afterLoadSnapshot.emit({
2071
- id,
2072
- host: this.HostInstance,
2073
2083
  options,
2074
2084
  moduleInfo,
2075
2085
  remoteSnapshot: mSnapshot
@@ -2607,9 +2617,7 @@ class RemoteHandler {
2607
2617
  await Promise.all(preloadOps.map(async (ops)=>{
2608
2618
  const { remote } = ops;
2609
2619
  const remoteInfo = getRemoteInfo(remote);
2610
- const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
2611
- moduleInfo: remote
2612
- });
2620
+ const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo(remote);
2613
2621
  const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
2614
2622
  origin: host,
2615
2623
  preloadOptions: ops,
package/dist/index.esm.js CHANGED
@@ -1690,12 +1690,9 @@ function snapshotPlugin() {
1690
1690
  return {
1691
1691
  name: 'snapshot-plugin',
1692
1692
  async afterResolve (args) {
1693
- const { remote, pkgNameOrAlias, expose, origin, remoteInfo, id } = args;
1693
+ const { remote, pkgNameOrAlias, expose, origin, remoteInfo } = args;
1694
1694
  if (!isRemoteInfoWithEntry(remote) || !isPureRemoteEntry(remote)) {
1695
- const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo({
1696
- moduleInfo: remote,
1697
- id
1698
- });
1695
+ const { remoteSnapshot, globalSnapshot } = await origin.snapshotHandler.loadRemoteSnapshotInfo(remote);
1699
1696
  assignRemoteInfo(remoteInfo, remoteSnapshot);
1700
1697
  // preloading assets
1701
1698
  const preloadOptions = {
@@ -1954,7 +1951,7 @@ const generatePreloadAssetsPlugin = function() {
1954
1951
 
1955
1952
  function getGlobalRemoteInfo(moduleInfo, origin) {
1956
1953
  const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
1957
- name: origin.name,
1954
+ name: origin.options.name,
1958
1955
  version: origin.options.version
1959
1956
  });
1960
1957
  // get remote detail info from global
@@ -1979,8 +1976,23 @@ function getGlobalRemoteInfo(moduleInfo, origin) {
1979
1976
  };
1980
1977
  }
1981
1978
  class SnapshotHandler {
1979
+ async loadSnapshot(moduleInfo) {
1980
+ const { options } = this.HostInstance;
1981
+ const { hostGlobalSnapshot, remoteSnapshot, globalSnapshot } = this.getGlobalRemoteInfo(moduleInfo);
1982
+ const { remoteSnapshot: globalRemoteSnapshot, globalSnapshot: globalSnapshotRes } = await this.hooks.lifecycle.loadSnapshot.emit({
1983
+ options,
1984
+ moduleInfo,
1985
+ hostGlobalSnapshot,
1986
+ remoteSnapshot,
1987
+ globalSnapshot
1988
+ });
1989
+ return {
1990
+ remoteSnapshot: globalRemoteSnapshot,
1991
+ globalSnapshot: globalSnapshotRes
1992
+ };
1993
+ }
1982
1994
  // eslint-disable-next-line max-lines-per-function
1983
- async loadRemoteSnapshotInfo({ moduleInfo, id, expose }) {
1995
+ async loadRemoteSnapshotInfo(moduleInfo) {
1984
1996
  const { options } = this.HostInstance;
1985
1997
  await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
1986
1998
  options,
@@ -2067,8 +2079,6 @@ class SnapshotHandler {
2067
2079
  }
2068
2080
  }
2069
2081
  await this.hooks.lifecycle.afterLoadSnapshot.emit({
2070
- id,
2071
- host: this.HostInstance,
2072
2082
  options,
2073
2083
  moduleInfo,
2074
2084
  remoteSnapshot: mSnapshot
@@ -2606,9 +2616,7 @@ class RemoteHandler {
2606
2616
  await Promise.all(preloadOps.map(async (ops)=>{
2607
2617
  const { remote } = ops;
2608
2618
  const remoteInfo = getRemoteInfo(remote);
2609
- const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo({
2610
- moduleInfo: remote
2611
- });
2619
+ const { globalSnapshot, remoteSnapshot } = await host.snapshotHandler.loadRemoteSnapshotInfo(remote);
2612
2620
  const assets = await this.hooks.lifecycle.generatePreloadAssets.emit({
2613
2621
  origin: host,
2614
2622
  preloadOptions: ops,
@@ -33,8 +33,6 @@ export declare class SnapshotHandler {
33
33
  from: "global" | "manifest";
34
34
  }>;
35
35
  afterLoadSnapshot: AsyncWaterfallHook<{
36
- id?: string;
37
- host: FederationHost;
38
36
  options: Options;
39
37
  moduleInfo: Remote;
40
38
  remoteSnapshot: ModuleInfo;
@@ -43,11 +41,11 @@ export declare class SnapshotHandler {
43
41
  loaderHook: FederationHost['loaderHook'];
44
42
  manifestLoading: Record<string, Promise<ModuleInfo>>;
45
43
  constructor(HostInstance: FederationHost);
46
- loadRemoteSnapshotInfo({ moduleInfo, id, expose, }: {
47
- moduleInfo: Remote;
48
- id?: string;
49
- expose?: string;
50
- }): Promise<{
44
+ loadSnapshot(moduleInfo: Remote): Promise<{
45
+ remoteSnapshot: GlobalModuleInfo[string] | undefined;
46
+ globalSnapshot: ReturnType<typeof getGlobalSnapshot>;
47
+ }>;
48
+ loadRemoteSnapshotInfo(moduleInfo: Remote): Promise<{
51
49
  remoteSnapshot: ModuleInfo;
52
50
  globalSnapshot: GlobalModuleInfo;
53
51
  }> | never;
@@ -20,7 +20,6 @@ export type LoadShareExtraOptions = {
20
20
  resolver?: (sharedOptions: ShareInfos[string]) => Shared;
21
21
  };
22
22
  export interface RemoteInfo {
23
- alias?: string;
24
23
  name: string;
25
24
  version?: string;
26
25
  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-20250526074234",
3
+ "version": "0.0.0-next-20250527065931",
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-20250526074234",
56
- "@module-federation/error-codes": "0.0.0-next-20250526074234"
55
+ "@module-federation/sdk": "0.0.0-next-20250527065931",
56
+ "@module-federation/error-codes": "0.0.0-next-20250527065931"
57
57
  }
58
58
  }