@module-federation/runtime 0.6.3 → 0.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -276,7 +276,7 @@ let Module = class Module {
276
276
  return this.remoteEntryExports;
277
277
  }
278
278
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
279
- async get(id, expose, options) {
279
+ async get(id, expose, options, remoteSnapshot) {
280
280
  const { loadFactory = true } = options || {
281
281
  loadFactory: true
282
282
  };
@@ -312,6 +312,8 @@ let Module = class Module {
312
312
  }
313
313
  await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
314
314
  await this.host.hooks.lifecycle.initContainer.emit(polyfills._extends({}, initContainerOptions, {
315
+ id,
316
+ remoteSnapshot,
315
317
  remoteEntryExports
316
318
  }));
317
319
  }
@@ -1568,8 +1570,8 @@ class RemoteHandler {
1568
1570
  const { module, moduleOptions, remoteMatchInfo } = await this.getRemoteModuleAndOptions({
1569
1571
  id
1570
1572
  });
1571
- const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
1572
- const moduleOrFactory = await module.get(idRes, expose, options);
1573
+ const { pkgNameOrAlias, remote, expose, id: idRes, remoteSnapshot } = remoteMatchInfo;
1574
+ const moduleOrFactory = await module.get(idRes, expose, options, remoteSnapshot);
1573
1575
  const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
1574
1576
  id: idRes,
1575
1577
  pkgNameOrAlias,
@@ -1978,7 +1980,7 @@ class FederationHost {
1978
1980
  // maybe will change, temporarily for internal use only
1979
1981
  initContainer: new AsyncWaterfallHook('initContainer')
1980
1982
  });
1981
- this.version = "0.6.3";
1983
+ this.version = "0.6.5";
1982
1984
  this.moduleCache = new Map();
1983
1985
  this.loaderHook = new PluginSystem({
1984
1986
  // FIXME: may not be suitable , not open to the public yet
@@ -2083,6 +2085,7 @@ Object.defineProperty(exports, 'loadScriptNode', {
2083
2085
  });
2084
2086
  exports.registerGlobalPlugins = share.registerGlobalPlugins;
2085
2087
  exports.FederationHost = FederationHost;
2088
+ exports.Module = Module;
2086
2089
  exports.getInstance = getInstance;
2087
2090
  exports.getRemoteEntry = getRemoteEntry;
2088
2091
  exports.getRemoteInfo = getRemoteInfo;
package/dist/index.esm.js CHANGED
@@ -274,7 +274,7 @@ let Module = class Module {
274
274
  return this.remoteEntryExports;
275
275
  }
276
276
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
277
- async get(id, expose, options) {
277
+ async get(id, expose, options, remoteSnapshot) {
278
278
  const { loadFactory = true } = options || {
279
279
  loadFactory: true
280
280
  };
@@ -310,6 +310,8 @@ let Module = class Module {
310
310
  }
311
311
  await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
312
312
  await this.host.hooks.lifecycle.initContainer.emit(_extends({}, initContainerOptions, {
313
+ id,
314
+ remoteSnapshot,
313
315
  remoteEntryExports
314
316
  }));
315
317
  }
@@ -1566,8 +1568,8 @@ class RemoteHandler {
1566
1568
  const { module, moduleOptions, remoteMatchInfo } = await this.getRemoteModuleAndOptions({
1567
1569
  id
1568
1570
  });
1569
- const { pkgNameOrAlias, remote, expose, id: idRes } = remoteMatchInfo;
1570
- const moduleOrFactory = await module.get(idRes, expose, options);
1571
+ const { pkgNameOrAlias, remote, expose, id: idRes, remoteSnapshot } = remoteMatchInfo;
1572
+ const moduleOrFactory = await module.get(idRes, expose, options, remoteSnapshot);
1571
1573
  const moduleWrapper = await this.hooks.lifecycle.onLoad.emit({
1572
1574
  id: idRes,
1573
1575
  pkgNameOrAlias,
@@ -1976,7 +1978,7 @@ class FederationHost {
1976
1978
  // maybe will change, temporarily for internal use only
1977
1979
  initContainer: new AsyncWaterfallHook('initContainer')
1978
1980
  });
1979
- this.version = "0.6.3";
1981
+ this.version = "0.6.5";
1980
1982
  this.moduleCache = new Map();
1981
1983
  this.loaderHook = new PluginSystem({
1982
1984
  // FIXME: may not be suitable , not open to the public yet
@@ -2071,4 +2073,4 @@ function getInstance() {
2071
2073
  // Inject for debug
2072
2074
  setGlobalFederationConstructor(FederationHost);
2073
2075
 
2074
- export { FederationHost, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
2076
+ export { FederationHost, Module, getInstance, getRemoteEntry, getRemoteInfo, init, loadRemote, loadShare, loadShareSync, preloadRemote, registerPlugins, registerRemotes };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
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
@@ -175,7 +175,7 @@ function getGlobalFederationConstructor() {
175
175
  function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
176
176
  if (isDebug) {
177
177
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
178
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.3";
178
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.5";
179
179
  }
180
180
  }
181
181
  // eslint-disable-next-line @typescript-eslint/ban-types
package/dist/share.esm.js CHANGED
@@ -173,7 +173,7 @@ function getGlobalFederationConstructor() {
173
173
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
174
174
  if (isDebug) {
175
175
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
176
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.3";
176
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.5";
177
177
  }
178
178
  }
179
179
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -1,4 +1,4 @@
1
- import type { CreateScriptHookReturn } from '@module-federation/sdk';
1
+ import type { CreateScriptHookReturn, ModuleInfo } from '@module-federation/sdk';
2
2
  import { Options, PreloadRemoteArgs, RemoteEntryExports, Remote, Shared, ShareInfos, UserOptions, RemoteInfo, ShareScopeMap, InitScope, RemoteEntryInitOptions, CallFrom } from './type';
3
3
  import { Module } from './module';
4
4
  import { AsyncHook, AsyncWaterfallHook, PluginSystem, SyncHook, SyncWaterfallHook } from './utils/hooks';
@@ -32,6 +32,8 @@ export declare class FederationHost {
32
32
  remoteInfo: RemoteInfo;
33
33
  remoteEntryExports: RemoteEntryExports;
34
34
  origin: FederationHost;
35
+ id: string;
36
+ remoteSnapshot?: ModuleInfo;
35
37
  }>;
36
38
  }>;
37
39
  version: string;
@@ -4,6 +4,7 @@ export { FederationHost } from './core';
4
4
  export { registerGlobalPlugins } from './global';
5
5
  export { getRemoteEntry, getRemoteInfo } from './utils';
6
6
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
7
+ export { Module } from './module';
7
8
  export type { Federation } from './global';
8
9
  export type { FederationRuntimePlugin };
9
10
  export declare function init(options: UserOptions): FederationHost;
@@ -1,3 +1,4 @@
1
+ import { ModuleInfo } from '@module-federation/sdk';
1
2
  import { FederationHost } from '../core';
2
3
  import { RemoteEntryExports, RemoteInfo } from '../type';
3
4
  export type ModuleOptions = ConstructorParameters<typeof Module>[0];
@@ -14,7 +15,7 @@ declare class Module {
14
15
  getEntry(): Promise<RemoteEntryExports>;
15
16
  get(id: string, expose: string, options?: {
16
17
  loadFactory?: boolean;
17
- }): Promise<any>;
18
+ }, remoteSnapshot?: ModuleInfo): Promise<any>;
18
19
  private wraperFactory;
19
20
  }
20
21
  export { Module };
@@ -44,14 +44,14 @@ export declare class RemoteHandler {
44
44
  exposeModuleFactory: any;
45
45
  moduleInstance: Module;
46
46
  }], void>;
47
- handlePreloadModule: SyncHook<{
47
+ handlePreloadModule: SyncHook<[{
48
48
  id: string;
49
49
  name: string;
50
50
  remote: Remote;
51
51
  remoteSnapshot: ModuleInfo;
52
52
  preloadConfig: PreloadRemoteArgs;
53
53
  origin: FederationHost;
54
- }, void>;
54
+ }], void>;
55
55
  errorLoadRemote: AsyncHook<[{
56
56
  id: string;
57
57
  error: unknown;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -50,6 +50,6 @@
50
50
  }
51
51
  },
52
52
  "dependencies": {
53
- "@module-federation/sdk": "0.6.3"
53
+ "@module-federation/sdk": "0.6.5"
54
54
  }
55
55
  }