@module-federation/runtime 0.0.0-next-20240115064607 → 0.0.0-next-20240117093010

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.
@@ -14,10 +14,7 @@ const GlobalUtils = {
14
14
  setGlobalFederationInstance: share.setGlobalFederationInstance,
15
15
  getGlobalFederationConstructor: share.getGlobalFederationConstructor,
16
16
  setGlobalFederationConstructor: share.setGlobalFederationConstructor,
17
- getInfoWithoutType: share.getInfoWithoutType,
18
17
  getGlobalSnapshot: share.getGlobalSnapshot,
19
- getTargetSnapshotInfoByModuleInfo: share.getTargetSnapshotInfoByModuleInfo,
20
- getGlobalSnapshotInfoByModuleInfo: share.getGlobalSnapshotInfoByModuleInfo,
21
18
  setGlobalSnapshotInfoByModuleInfo: share.setGlobalSnapshotInfoByModuleInfo,
22
19
  addGlobalSnapshot: share.addGlobalSnapshot,
23
20
  getRemoteEntryExports: share.getRemoteEntryExports,
@@ -1,4 +1,4 @@
1
- import { l as getRegisteredShare, t as getGlobalShareScope, G as Global, F as nativeGlobal, H as resetFederationGlobalInfo, A as getGlobalFederationInstance, C as setGlobalFederationInstance, B as getGlobalFederationConstructor, z as setGlobalFederationConstructor, m as getInfoWithoutType, r as getGlobalSnapshot, I as getTargetSnapshotInfoByModuleInfo, p as getGlobalSnapshotInfoByModuleInfo, q as setGlobalSnapshotInfoByModuleInfo, J as addGlobalSnapshot, c as getRemoteEntryExports, E as registerGlobalPlugins, g as getGlobalHostPlugins, n as getPreloaded, o as setPreloaded } from './share.esm.js';
1
+ import { n as getRegisteredShare, t as getGlobalShareScope, G as Global, F as nativeGlobal, H as resetFederationGlobalInfo, A as getGlobalFederationInstance, C as setGlobalFederationInstance, B as getGlobalFederationConstructor, z as setGlobalFederationConstructor, q as getGlobalSnapshot, p as setGlobalSnapshotInfoByModuleInfo, o as addGlobalSnapshot, c as getRemoteEntryExports, E as registerGlobalPlugins, g as getGlobalHostPlugins, l as getPreloaded, m as setPreloaded } from './share.esm.js';
2
2
 
3
3
  const ShareUtils = {
4
4
  getRegisteredShare,
@@ -12,10 +12,7 @@ const GlobalUtils = {
12
12
  setGlobalFederationInstance,
13
13
  getGlobalFederationConstructor,
14
14
  setGlobalFederationConstructor,
15
- getInfoWithoutType,
16
15
  getGlobalSnapshot,
17
- getTargetSnapshotInfoByModuleInfo,
18
- getGlobalSnapshotInfoByModuleInfo,
19
16
  setGlobalSnapshotInfoByModuleInfo,
20
17
  addGlobalSnapshot,
21
18
  getRemoteEntryExports,
package/dist/index.cjs.js CHANGED
@@ -214,6 +214,7 @@ let Module = class Module {
214
214
  remoteInfo: this.remoteInfo,
215
215
  remoteEntryExports: this.remoteEntryExports,
216
216
  createScriptHook: (url)=>{
217
+ console.log('xxxxxxx', this.host.loaderHook);
217
218
  const res = this.host.loaderHook.lifecycle.createScript.emit({
218
219
  url
219
220
  });
@@ -674,9 +675,9 @@ function splitId(id) {
674
675
  }
675
676
  }
676
677
  // Traverse all nodes in moduleInfo and traverse the entire snapshot
677
- function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo = {}, remoteSnapshot, getModuleInfoHook) {
678
+ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo = {}, getSnapshotInfoWithHook, remoteSnapshot) {
678
679
  const id = share.getFMId(remoteInfo);
679
- const { value: snapshotValue } = share.getInfoWithoutType(globalSnapshot, id, getModuleInfoHook);
680
+ const { value: snapshotValue } = getSnapshotInfoWithHook.getInfoWithoutTypeWithHook(globalSnapshot, id);
680
681
  const effectiveRemoteSnapshot = remoteSnapshot || snapshotValue;
681
682
  if (effectiveRemoteSnapshot && !sdk.isManifestProvider(effectiveRemoteSnapshot)) {
682
683
  traverse(effectiveRemoteSnapshot, remoteInfo, isRoot);
@@ -692,7 +693,7 @@ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo =
692
693
  traverseModuleInfo(globalSnapshot, {
693
694
  name: subRemoteInfo.name,
694
695
  version: remoteValue.matchedVersion
695
- }, traverse, false, memo, undefined, getModuleInfoHook);
696
+ }, traverse, false, memo, getSnapshotInfoWithHook, undefined);
696
697
  }
697
698
  }
698
699
  }
@@ -792,16 +793,7 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
792
793
  share.setPreloaded(exposeFullPath);
793
794
  }
794
795
  }
795
- }, true, memo, remoteSnapshot, (target, key)=>{
796
- const res = origin.loaderHook.lifecycle.getModuleInfo.emit({
797
- target,
798
- key
799
- });
800
- if (res && !(res instanceof Promise)) {
801
- return res;
802
- }
803
- return;
804
- });
796
+ }, true, memo, origin.snapshotHandler.getSnapshotInfoHandler, remoteSnapshot);
805
797
  if (remoteSnapshot.shared) {
806
798
  remoteSnapshot.shared.forEach((shared)=>{
807
799
  var _options_shared;
@@ -894,37 +886,27 @@ class SnapshotHandler {
894
886
  // eslint-disable-next-line max-lines-per-function
895
887
  async loadRemoteSnapshotInfo(moduleInfo) {
896
888
  const { options } = this.HostInstance;
897
- const hostSnapshot = share.getGlobalSnapshotInfoByModuleInfo({
898
- name: this.HostInstance.options.name,
899
- version: this.HostInstance.options.version
900
- }, {
901
- getModuleInfoHook: (target, key)=>{
902
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
903
- target,
904
- key
905
- });
906
- if (res && !(res instanceof Promise)) {
907
- return res;
908
- }
909
- return;
910
- }
911
- });
912
889
  await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
913
890
  options,
914
891
  moduleInfo
915
892
  });
893
+ let hostSnapshot = this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
894
+ name: this.HostInstance.options.name,
895
+ version: this.HostInstance.options.version
896
+ });
897
+ if (!hostSnapshot) {
898
+ hostSnapshot = {
899
+ version: this.HostInstance.options.version || '',
900
+ remoteEntry: '',
901
+ remotesInfo: {}
902
+ };
903
+ share.addGlobalSnapshot({
904
+ [this.HostInstance.options.name]: hostSnapshot
905
+ });
906
+ }
916
907
  // In dynamic loadRemote scenarios, incomplete remotesInfo delivery may occur. In such cases, the remotesInfo in the host needs to be completed in the snapshot at runtime.
917
908
  // This ensures the snapshot's integrity and helps the chrome plugin correctly identify all producer modules, ensuring that proxyable producer modules will not be missing.
918
- if (hostSnapshot && 'remotesInfo' in hostSnapshot && !share.getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name, (target, key)=>{
919
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
920
- target,
921
- key
922
- });
923
- if (res && !(res instanceof Promise)) {
924
- return res;
925
- }
926
- return;
927
- }).value) {
909
+ if (hostSnapshot && 'remotesInfo' in hostSnapshot && !this.getSnapshotInfoHandler.getInfoWithoutTypeWithHook(hostSnapshot.remotesInfo, moduleInfo.name).value) {
928
910
  if ('version' in moduleInfo || 'entry' in moduleInfo) {
929
911
  hostSnapshot.remotesInfo = _extends$1({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
930
912
  [moduleInfo.name]: {
@@ -990,70 +972,28 @@ class SnapshotHandler {
990
972
  }
991
973
  }
992
974
  getGlobalRemoteInfo(moduleInfo) {
993
- const hostGlobalSnapshot = share.getGlobalSnapshotInfoByModuleInfo({
975
+ const hostGlobalSnapshot = this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
994
976
  name: this.HostInstance.options.name,
995
977
  version: this.HostInstance.options.version
996
- }, {
997
- getModuleInfoHook: (target, key)=>{
998
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
999
- target,
1000
- key
1001
- });
1002
- if (res && !(res instanceof Promise)) {
1003
- return res;
1004
- }
1005
- return;
1006
- }
1007
978
  });
1008
979
  // get remote detail info from global
1009
- const globalRemoteInfo = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && share.getInfoWithoutType(hostGlobalSnapshot.remotesInfo, moduleInfo.name, (target, key)=>{
1010
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
1011
- target,
1012
- key
1013
- });
1014
- if (res && !(res instanceof Promise)) {
1015
- return res;
1016
- }
1017
- return;
1018
- }).value;
980
+ const globalRemoteInfo = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && this.getSnapshotInfoHandler.getInfoWithoutTypeWithHook(hostGlobalSnapshot.remotesInfo, moduleInfo.name).value;
1019
981
  if (globalRemoteInfo && globalRemoteInfo.matchedVersion) {
1020
982
  return {
1021
983
  hostGlobalSnapshot,
1022
984
  globalSnapshot: share.getGlobalSnapshot(),
1023
- remoteSnapshot: share.getGlobalSnapshotInfoByModuleInfo({
985
+ remoteSnapshot: this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
1024
986
  name: moduleInfo.name,
1025
987
  version: globalRemoteInfo.matchedVersion
1026
- }, {
1027
- getModuleInfoHook: (target, key)=>{
1028
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
1029
- target,
1030
- key
1031
- });
1032
- if (res && !(res instanceof Promise)) {
1033
- return res;
1034
- }
1035
- return;
1036
- }
1037
988
  })
1038
989
  };
1039
990
  }
1040
991
  return {
1041
992
  hostGlobalSnapshot: undefined,
1042
993
  globalSnapshot: share.getGlobalSnapshot(),
1043
- remoteSnapshot: share.getGlobalSnapshotInfoByModuleInfo({
994
+ remoteSnapshot: this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
1044
995
  name: moduleInfo.name,
1045
996
  version: 'version' in moduleInfo ? moduleInfo.version : undefined
1046
- }, {
1047
- getModuleInfoHook: (target, key)=>{
1048
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
1049
- target,
1050
- key
1051
- });
1052
- if (res && !(res instanceof Promise)) {
1053
- return res;
1054
- }
1055
- return;
1056
- }
1057
997
  })
1058
998
  };
1059
999
  }
@@ -1109,6 +1049,7 @@ class SnapshotHandler {
1109
1049
  this.manifestLoading = share.Global.__FEDERATION__.__MANIFEST_LOADING__;
1110
1050
  this.HostInstance = HostInstance;
1111
1051
  this.loaderHook = HostInstance.loaderHook;
1052
+ this.getSnapshotInfoHandler = new share.GetSnapshotInfoWithHook(this.loaderHook);
1112
1053
  }
1113
1054
  }
1114
1055
 
@@ -1518,7 +1459,7 @@ class FederationHost {
1518
1459
  }
1519
1460
  // Set the remote entry to a complete path
1520
1461
  if ('entry' in remote) {
1521
- if (share.isBrowserEnv() && !remote.entry.startsWith('http')) {
1462
+ if (share.isBrowserEnv()) {
1522
1463
  remote.entry = new URL(remote.entry, window.location.origin).href;
1523
1464
  }
1524
1465
  }
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
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 setGlobalSnapshotInfoByModuleInfo, r as getGlobalSnapshot, G as Global, t as getGlobalShareScope, u as formatShareConfigs, v as isBrowserEnv, x as getBuilderId, y as addUniqueItem, z as setGlobalFederationConstructor, A as getGlobalFederationInstance, B as getGlobalFederationConstructor, C as setGlobalFederationInstance } from './share.esm.js';
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 getPreloaded, m as setPreloaded, n as getRegisteredShare, o as addGlobalSnapshot, p as setGlobalSnapshotInfoByModuleInfo, q as getGlobalSnapshot, G as Global, r as GetSnapshotInfoWithHook, t as getGlobalShareScope, u as formatShareConfigs, v as isBrowserEnv, x as getBuilderId, y as addUniqueItem, z as setGlobalFederationConstructor, A as getGlobalFederationInstance, B as getGlobalFederationConstructor, C as setGlobalFederationInstance } from './share.esm.js';
2
2
  export { E as registerGlobalPlugins } from './share.esm.js';
3
3
  import { composeKeyWithSeparator, loadScriptNode, loadScript, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest } from '@module-federation/sdk';
4
4
  export { loadScript } from '@module-federation/sdk';
@@ -212,6 +212,7 @@ let Module = class Module {
212
212
  remoteInfo: this.remoteInfo,
213
213
  remoteEntryExports: this.remoteEntryExports,
214
214
  createScriptHook: (url)=>{
215
+ console.log('xxxxxxx', this.host.loaderHook);
215
216
  const res = this.host.loaderHook.lifecycle.createScript.emit({
216
217
  url
217
218
  });
@@ -672,9 +673,9 @@ function splitId(id) {
672
673
  }
673
674
  }
674
675
  // Traverse all nodes in moduleInfo and traverse the entire snapshot
675
- function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo = {}, remoteSnapshot, getModuleInfoHook) {
676
+ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo = {}, getSnapshotInfoWithHook, remoteSnapshot) {
676
677
  const id = getFMId(remoteInfo);
677
- const { value: snapshotValue } = getInfoWithoutType(globalSnapshot, id, getModuleInfoHook);
678
+ const { value: snapshotValue } = getSnapshotInfoWithHook.getInfoWithoutTypeWithHook(globalSnapshot, id);
678
679
  const effectiveRemoteSnapshot = remoteSnapshot || snapshotValue;
679
680
  if (effectiveRemoteSnapshot && !isManifestProvider(effectiveRemoteSnapshot)) {
680
681
  traverse(effectiveRemoteSnapshot, remoteInfo, isRoot);
@@ -690,7 +691,7 @@ function traverseModuleInfo(globalSnapshot, remoteInfo, traverse, isRoot, memo =
690
691
  traverseModuleInfo(globalSnapshot, {
691
692
  name: subRemoteInfo.name,
692
693
  version: remoteValue.matchedVersion
693
- }, traverse, false, memo, undefined, getModuleInfoHook);
694
+ }, traverse, false, memo, getSnapshotInfoWithHook, undefined);
694
695
  }
695
696
  }
696
697
  }
@@ -790,16 +791,7 @@ function generatePreloadAssets(origin, preloadOptions, remote, globalSnapshot, r
790
791
  setPreloaded(exposeFullPath);
791
792
  }
792
793
  }
793
- }, true, memo, remoteSnapshot, (target, key)=>{
794
- const res = origin.loaderHook.lifecycle.getModuleInfo.emit({
795
- target,
796
- key
797
- });
798
- if (res && !(res instanceof Promise)) {
799
- return res;
800
- }
801
- return;
802
- });
794
+ }, true, memo, origin.snapshotHandler.getSnapshotInfoHandler, remoteSnapshot);
803
795
  if (remoteSnapshot.shared) {
804
796
  remoteSnapshot.shared.forEach((shared)=>{
805
797
  var _options_shared;
@@ -892,37 +884,27 @@ class SnapshotHandler {
892
884
  // eslint-disable-next-line max-lines-per-function
893
885
  async loadRemoteSnapshotInfo(moduleInfo) {
894
886
  const { options } = this.HostInstance;
895
- const hostSnapshot = getGlobalSnapshotInfoByModuleInfo({
896
- name: this.HostInstance.options.name,
897
- version: this.HostInstance.options.version
898
- }, {
899
- getModuleInfoHook: (target, key)=>{
900
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
901
- target,
902
- key
903
- });
904
- if (res && !(res instanceof Promise)) {
905
- return res;
906
- }
907
- return;
908
- }
909
- });
910
887
  await this.hooks.lifecycle.beforeLoadRemoteSnapshot.emit({
911
888
  options,
912
889
  moduleInfo
913
890
  });
891
+ let hostSnapshot = this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
892
+ name: this.HostInstance.options.name,
893
+ version: this.HostInstance.options.version
894
+ });
895
+ if (!hostSnapshot) {
896
+ hostSnapshot = {
897
+ version: this.HostInstance.options.version || '',
898
+ remoteEntry: '',
899
+ remotesInfo: {}
900
+ };
901
+ addGlobalSnapshot({
902
+ [this.HostInstance.options.name]: hostSnapshot
903
+ });
904
+ }
914
905
  // In dynamic loadRemote scenarios, incomplete remotesInfo delivery may occur. In such cases, the remotesInfo in the host needs to be completed in the snapshot at runtime.
915
906
  // This ensures the snapshot's integrity and helps the chrome plugin correctly identify all producer modules, ensuring that proxyable producer modules will not be missing.
916
- if (hostSnapshot && 'remotesInfo' in hostSnapshot && !getInfoWithoutType(hostSnapshot.remotesInfo, moduleInfo.name, (target, key)=>{
917
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
918
- target,
919
- key
920
- });
921
- if (res && !(res instanceof Promise)) {
922
- return res;
923
- }
924
- return;
925
- }).value) {
907
+ if (hostSnapshot && 'remotesInfo' in hostSnapshot && !this.getSnapshotInfoHandler.getInfoWithoutTypeWithHook(hostSnapshot.remotesInfo, moduleInfo.name).value) {
926
908
  if ('version' in moduleInfo || 'entry' in moduleInfo) {
927
909
  hostSnapshot.remotesInfo = _extends$1({}, hostSnapshot == null ? void 0 : hostSnapshot.remotesInfo, {
928
910
  [moduleInfo.name]: {
@@ -988,70 +970,28 @@ class SnapshotHandler {
988
970
  }
989
971
  }
990
972
  getGlobalRemoteInfo(moduleInfo) {
991
- const hostGlobalSnapshot = getGlobalSnapshotInfoByModuleInfo({
973
+ const hostGlobalSnapshot = this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
992
974
  name: this.HostInstance.options.name,
993
975
  version: this.HostInstance.options.version
994
- }, {
995
- getModuleInfoHook: (target, key)=>{
996
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
997
- target,
998
- key
999
- });
1000
- if (res && !(res instanceof Promise)) {
1001
- return res;
1002
- }
1003
- return;
1004
- }
1005
976
  });
1006
977
  // get remote detail info from global
1007
- const globalRemoteInfo = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && getInfoWithoutType(hostGlobalSnapshot.remotesInfo, moduleInfo.name, (target, key)=>{
1008
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
1009
- target,
1010
- key
1011
- });
1012
- if (res && !(res instanceof Promise)) {
1013
- return res;
1014
- }
1015
- return;
1016
- }).value;
978
+ const globalRemoteInfo = hostGlobalSnapshot && 'remotesInfo' in hostGlobalSnapshot && hostGlobalSnapshot.remotesInfo && this.getSnapshotInfoHandler.getInfoWithoutTypeWithHook(hostGlobalSnapshot.remotesInfo, moduleInfo.name).value;
1017
979
  if (globalRemoteInfo && globalRemoteInfo.matchedVersion) {
1018
980
  return {
1019
981
  hostGlobalSnapshot,
1020
982
  globalSnapshot: getGlobalSnapshot(),
1021
- remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
983
+ remoteSnapshot: this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
1022
984
  name: moduleInfo.name,
1023
985
  version: globalRemoteInfo.matchedVersion
1024
- }, {
1025
- getModuleInfoHook: (target, key)=>{
1026
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
1027
- target,
1028
- key
1029
- });
1030
- if (res && !(res instanceof Promise)) {
1031
- return res;
1032
- }
1033
- return;
1034
- }
1035
986
  })
1036
987
  };
1037
988
  }
1038
989
  return {
1039
990
  hostGlobalSnapshot: undefined,
1040
991
  globalSnapshot: getGlobalSnapshot(),
1041
- remoteSnapshot: getGlobalSnapshotInfoByModuleInfo({
992
+ remoteSnapshot: this.getSnapshotInfoHandler.getGlobalSnapshotInfoByModuleInfo({
1042
993
  name: moduleInfo.name,
1043
994
  version: 'version' in moduleInfo ? moduleInfo.version : undefined
1044
- }, {
1045
- getModuleInfoHook: (target, key)=>{
1046
- const res = this.HostInstance.loaderHook.lifecycle.getModuleInfo.emit({
1047
- target,
1048
- key
1049
- });
1050
- if (res && !(res instanceof Promise)) {
1051
- return res;
1052
- }
1053
- return;
1054
- }
1055
995
  })
1056
996
  };
1057
997
  }
@@ -1107,6 +1047,7 @@ class SnapshotHandler {
1107
1047
  this.manifestLoading = Global.__FEDERATION__.__MANIFEST_LOADING__;
1108
1048
  this.HostInstance = HostInstance;
1109
1049
  this.loaderHook = HostInstance.loaderHook;
1050
+ this.getSnapshotInfoHandler = new GetSnapshotInfoWithHook(this.loaderHook);
1110
1051
  }
1111
1052
  }
1112
1053
 
@@ -1516,7 +1457,7 @@ class FederationHost {
1516
1457
  }
1517
1458
  // Set the remote entry to a complete path
1518
1459
  if ('entry' in remote) {
1519
- if (isBrowserEnv() && !remote.entry.startsWith('http')) {
1460
+ if (isBrowserEnv()) {
1520
1461
  remote.entry = new URL(remote.entry, window.location.origin).href;
1521
1462
  }
1522
1463
  }
package/dist/share.cjs.js CHANGED
@@ -168,50 +168,63 @@ function setGlobalFederationInstance(FederationInstance) {
168
168
  function getGlobalFederationConstructor() {
169
169
  return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
170
170
  }
171
- function setGlobalFederationConstructor(FederationConstructor) {
172
- if (isDebugMode()) {
171
+ function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
172
+ if (isDebug) {
173
173
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
174
174
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8";
175
175
  }
176
176
  }
177
177
  // eslint-disable-next-line @typescript-eslint/ban-types
178
- function getInfoWithoutType(target, key, getModuleInfoHook) {
179
- let res = {
178
+ function getInfoWithoutType(target, key) {
179
+ return {
180
180
  value: target[key],
181
181
  key: key
182
182
  };
183
- if (getModuleInfoHook) {
184
- const hookRes = getModuleInfoHook(target, key);
185
- res = hookRes || res;
186
- }
187
- return res;
188
183
  }
189
- const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
190
- const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot, getModuleInfoHook)=>{
191
- // Check if the remote is included in the hostSnapshot
192
- const moduleKey = getFMId(moduleInfo);
193
- const getModuleInfo = getInfoWithoutType(snapshot, moduleKey, getModuleInfoHook).value;
194
- // The remoteSnapshot might not include a version
195
- if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
196
- getModuleInfo.version = moduleInfo['version'];
197
- }
198
- if (getModuleInfo) {
199
- return getModuleInfo;
184
+ class GetSnapshotInfoWithHook {
185
+ getInfoWithoutTypeWithHook(target, key) {
186
+ let res = getInfoWithoutType(target, key);
187
+ const hookRes = this.loaderHook.lifecycle.getModuleInfo.emit({
188
+ target,
189
+ key
190
+ });
191
+ if (hookRes && !(hookRes instanceof Promise)) {
192
+ res = hookRes || res;
193
+ }
194
+ return res;
200
195
  }
201
- // If the remote is not included in the hostSnapshot, deploy a micro app snapshot
202
- if ('version' in moduleInfo && moduleInfo['version']) {
203
- const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
204
- "version"
205
- ]);
206
- const moduleKeyWithoutVersion = getFMId(resModuleInfo);
207
- const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion, getModuleInfoHook).value;
208
- if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
209
- return getModuleInfoWithoutVersion;
196
+ getTargetSnapshotInfoByModuleInfo(moduleInfo, snapshot) {
197
+ // Check if the remote is included in the hostSnapshot
198
+ const moduleKey = getFMId(moduleInfo);
199
+ const getModuleInfo = this.getInfoWithoutTypeWithHook(snapshot, moduleKey).value;
200
+ // The remoteSnapshot might not include a version
201
+ if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
202
+ getModuleInfo.version = moduleInfo['version'];
210
203
  }
204
+ if (getModuleInfo) {
205
+ return getModuleInfo;
206
+ }
207
+ // If the remote is not included in the hostSnapshot, deploy a micro app snapshot
208
+ if ('version' in moduleInfo && moduleInfo['version']) {
209
+ const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
210
+ "version"
211
+ ]);
212
+ const moduleKeyWithoutVersion = getFMId(resModuleInfo);
213
+ const getModuleInfoWithoutVersion = this.getInfoWithoutTypeWithHook(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
214
+ if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
215
+ return getModuleInfoWithoutVersion;
216
+ }
217
+ }
218
+ return;
211
219
  }
212
- return;
213
- };
214
- const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo, extraOptions == null ? void 0 : extraOptions.getModuleInfoHook);
220
+ getGlobalSnapshotInfoByModuleInfo(moduleInfo) {
221
+ return this.getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
222
+ }
223
+ constructor(loaderHook){
224
+ this.loaderHook = loaderHook;
225
+ }
226
+ }
227
+ const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
215
228
  const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
216
229
  const moduleKey = getFMId(remoteInfo);
217
230
  nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
@@ -683,27 +696,24 @@ const findVersion = (shareScopeMap, scope, pkgName, cb)=>{
683
696
  return prev;
684
697
  }, 0);
685
698
  };
686
- const isLoaded = (shared)=>{
687
- return Boolean(shared.loaded) || typeof shared.lib === 'function';
688
- };
689
699
  function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
690
700
  const versions = shareScopeMap[scope][pkgName];
691
701
  const callback = function(prev, cur) {
692
- return !isLoaded(versions[prev]) && versionLt(prev, cur);
702
+ return !versions[prev].loaded && versionLt(prev, cur);
693
703
  };
694
704
  return findVersion(shareScopeMap, scope, pkgName, callback);
695
705
  }
696
706
  function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
697
707
  const versions = shareScopeMap[scope][pkgName];
698
708
  const callback = function(prev, cur) {
699
- if (isLoaded(versions[cur])) {
700
- if (isLoaded(versions[prev])) {
709
+ if (versions[cur].loaded) {
710
+ if (versions[prev].loaded) {
701
711
  return Boolean(versionLt(prev, cur));
702
712
  } else {
703
713
  return true;
704
714
  }
705
715
  }
706
- if (isLoaded(versions[prev])) {
716
+ if (versions[prev].loaded) {
707
717
  return false;
708
718
  }
709
719
  return versionLt(prev, cur);
@@ -774,6 +784,7 @@ function getGlobalShareScope() {
774
784
 
775
785
  exports.DEFAULT_REMOTE_TYPE = DEFAULT_REMOTE_TYPE;
776
786
  exports.DEFAULT_SCOPE = DEFAULT_SCOPE;
787
+ exports.GetSnapshotInfoWithHook = GetSnapshotInfoWithHook;
777
788
  exports.Global = Global;
778
789
  exports.addGlobalSnapshot = addGlobalSnapshot;
779
790
  exports.addUniqueItem = addUniqueItem;
@@ -787,12 +798,9 @@ exports.getGlobalFederationInstance = getGlobalFederationInstance;
787
798
  exports.getGlobalHostPlugins = getGlobalHostPlugins;
788
799
  exports.getGlobalShareScope = getGlobalShareScope;
789
800
  exports.getGlobalSnapshot = getGlobalSnapshot;
790
- exports.getGlobalSnapshotInfoByModuleInfo = getGlobalSnapshotInfoByModuleInfo;
791
- exports.getInfoWithoutType = getInfoWithoutType;
792
801
  exports.getPreloaded = getPreloaded;
793
802
  exports.getRegisteredShare = getRegisteredShare;
794
803
  exports.getRemoteEntryExports = getRemoteEntryExports;
795
- exports.getTargetSnapshotInfoByModuleInfo = getTargetSnapshotInfoByModuleInfo;
796
804
  exports.globalLoading = globalLoading;
797
805
  exports.isBrowserEnv = isBrowserEnv;
798
806
  exports.isObject = isObject;
package/dist/share.esm.js CHANGED
@@ -166,50 +166,63 @@ function setGlobalFederationInstance(FederationInstance) {
166
166
  function getGlobalFederationConstructor() {
167
167
  return globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__;
168
168
  }
169
- function setGlobalFederationConstructor(FederationConstructor) {
170
- if (isDebugMode()) {
169
+ function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
170
+ if (isDebug) {
171
171
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
172
172
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.8";
173
173
  }
174
174
  }
175
175
  // eslint-disable-next-line @typescript-eslint/ban-types
176
- function getInfoWithoutType(target, key, getModuleInfoHook) {
177
- let res = {
176
+ function getInfoWithoutType(target, key) {
177
+ return {
178
178
  value: target[key],
179
179
  key: key
180
180
  };
181
- if (getModuleInfoHook) {
182
- const hookRes = getModuleInfoHook(target, key);
183
- res = hookRes || res;
184
- }
185
- return res;
186
181
  }
187
- const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
188
- const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot, getModuleInfoHook)=>{
189
- // Check if the remote is included in the hostSnapshot
190
- const moduleKey = getFMId(moduleInfo);
191
- const getModuleInfo = getInfoWithoutType(snapshot, moduleKey, getModuleInfoHook).value;
192
- // The remoteSnapshot might not include a version
193
- if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
194
- getModuleInfo.version = moduleInfo['version'];
195
- }
196
- if (getModuleInfo) {
197
- return getModuleInfo;
182
+ class GetSnapshotInfoWithHook {
183
+ getInfoWithoutTypeWithHook(target, key) {
184
+ let res = getInfoWithoutType(target, key);
185
+ const hookRes = this.loaderHook.lifecycle.getModuleInfo.emit({
186
+ target,
187
+ key
188
+ });
189
+ if (hookRes && !(hookRes instanceof Promise)) {
190
+ res = hookRes || res;
191
+ }
192
+ return res;
198
193
  }
199
- // If the remote is not included in the hostSnapshot, deploy a micro app snapshot
200
- if ('version' in moduleInfo && moduleInfo['version']) {
201
- const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
202
- "version"
203
- ]);
204
- const moduleKeyWithoutVersion = getFMId(resModuleInfo);
205
- const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion, getModuleInfoHook).value;
206
- if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
207
- return getModuleInfoWithoutVersion;
194
+ getTargetSnapshotInfoByModuleInfo(moduleInfo, snapshot) {
195
+ // Check if the remote is included in the hostSnapshot
196
+ const moduleKey = getFMId(moduleInfo);
197
+ const getModuleInfo = this.getInfoWithoutTypeWithHook(snapshot, moduleKey).value;
198
+ // The remoteSnapshot might not include a version
199
+ if (getModuleInfo && !getModuleInfo.version && 'version' in moduleInfo && moduleInfo['version']) {
200
+ getModuleInfo.version = moduleInfo['version'];
208
201
  }
202
+ if (getModuleInfo) {
203
+ return getModuleInfo;
204
+ }
205
+ // If the remote is not included in the hostSnapshot, deploy a micro app snapshot
206
+ if ('version' in moduleInfo && moduleInfo['version']) {
207
+ const { version } = moduleInfo, resModuleInfo = _object_without_properties_loose(moduleInfo, [
208
+ "version"
209
+ ]);
210
+ const moduleKeyWithoutVersion = getFMId(resModuleInfo);
211
+ const getModuleInfoWithoutVersion = this.getInfoWithoutTypeWithHook(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
212
+ if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
213
+ return getModuleInfoWithoutVersion;
214
+ }
215
+ }
216
+ return;
209
217
  }
210
- return;
211
- };
212
- const getGlobalSnapshotInfoByModuleInfo = (moduleInfo, extraOptions)=>getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo, extraOptions == null ? void 0 : extraOptions.getModuleInfoHook);
218
+ getGlobalSnapshotInfoByModuleInfo(moduleInfo) {
219
+ return this.getTargetSnapshotInfoByModuleInfo(moduleInfo, nativeGlobal.__FEDERATION__.moduleInfo);
220
+ }
221
+ constructor(loaderHook){
222
+ this.loaderHook = loaderHook;
223
+ }
224
+ }
225
+ const getGlobalSnapshot = ()=>nativeGlobal.__FEDERATION__.moduleInfo;
213
226
  const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo)=>{
214
227
  const moduleKey = getFMId(remoteInfo);
215
228
  nativeGlobal.__FEDERATION__.moduleInfo[moduleKey] = moduleDetailInfo;
@@ -681,27 +694,24 @@ const findVersion = (shareScopeMap, scope, pkgName, cb)=>{
681
694
  return prev;
682
695
  }, 0);
683
696
  };
684
- const isLoaded = (shared)=>{
685
- return Boolean(shared.loaded) || typeof shared.lib === 'function';
686
- };
687
697
  function findSingletonVersionOrderByVersion(shareScopeMap, scope, pkgName) {
688
698
  const versions = shareScopeMap[scope][pkgName];
689
699
  const callback = function(prev, cur) {
690
- return !isLoaded(versions[prev]) && versionLt(prev, cur);
700
+ return !versions[prev].loaded && versionLt(prev, cur);
691
701
  };
692
702
  return findVersion(shareScopeMap, scope, pkgName, callback);
693
703
  }
694
704
  function findSingletonVersionOrderByLoaded(shareScopeMap, scope, pkgName) {
695
705
  const versions = shareScopeMap[scope][pkgName];
696
706
  const callback = function(prev, cur) {
697
- if (isLoaded(versions[cur])) {
698
- if (isLoaded(versions[prev])) {
707
+ if (versions[cur].loaded) {
708
+ if (versions[prev].loaded) {
699
709
  return Boolean(versionLt(prev, cur));
700
710
  } else {
701
711
  return true;
702
712
  }
703
713
  }
704
- if (isLoaded(versions[prev])) {
714
+ if (versions[prev].loaded) {
705
715
  return false;
706
716
  }
707
717
  return versionLt(prev, cur);
@@ -770,4 +780,4 @@ function getGlobalShareScope() {
770
780
  return Global.__FEDERATION__.__SHARE__;
771
781
  }
772
782
 
773
- export { getGlobalFederationInstance as A, getGlobalFederationConstructor as B, setGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, registerGlobalPlugins as E, nativeGlobal as F, Global as G, resetFederationGlobalInfo as H, getTargetSnapshotInfoByModuleInfo as I, addGlobalSnapshot 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, setGlobalSnapshotInfoByModuleInfo as q, getGlobalSnapshot as r, safeToString as s, getGlobalShareScope as t, formatShareConfigs as u, isBrowserEnv as v, warn as w, getBuilderId as x, addUniqueItem as y, setGlobalFederationConstructor as z };
783
+ export { getGlobalFederationInstance as A, getGlobalFederationConstructor as B, setGlobalFederationInstance as C, DEFAULT_REMOTE_TYPE as D, registerGlobalPlugins as E, nativeGlobal as F, Global as G, resetFederationGlobalInfo as H, 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, getPreloaded as l, setPreloaded as m, getRegisteredShare as n, addGlobalSnapshot as o, setGlobalSnapshotInfoByModuleInfo as p, getGlobalSnapshot as q, GetSnapshotInfoWithHook as r, safeToString as s, getGlobalShareScope as t, formatShareConfigs as u, isBrowserEnv as v, warn as w, getBuilderId as x, addUniqueItem as y, setGlobalFederationConstructor as z };
@@ -23,25 +23,18 @@ export declare function resetFederationGlobalInfo(): void;
23
23
  export declare function getGlobalFederationInstance(name: string, version: string | undefined): FederationHost | undefined;
24
24
  export declare function setGlobalFederationInstance(FederationInstance: FederationHost): void;
25
25
  export declare function getGlobalFederationConstructor(): typeof FederationHost | undefined;
26
- export declare function setGlobalFederationConstructor(FederationConstructor: typeof FederationHost): void;
27
- export declare function getInfoWithoutType<T extends object>(target: T, key: keyof T, getModuleInfoHook?: (target: any, key: string | number | symbol) => {
28
- value: any | undefined;
29
- key: string;
30
- } | void): {
31
- value: T[keyof T] | undefined;
32
- key: string;
33
- };
34
- export declare const getGlobalSnapshot: () => GlobalModuleInfo;
35
- export declare const getTargetSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, 'alias'>, snapshot: GlobalModuleInfo, getModuleInfoHook?: ((target: any, key: string | number | symbol) => void | {
36
- value: any | undefined;
37
- key: string;
38
- }) | undefined) => GlobalModuleInfo[string] | undefined;
39
- export declare const getGlobalSnapshotInfoByModuleInfo: (moduleInfo: Optional<Remote, 'alias'>, extraOptions?: {
40
- getModuleInfoHook?: ((target: any, key: string | number | symbol) => void | {
41
- value: any | undefined;
26
+ export declare function setGlobalFederationConstructor(FederationConstructor: typeof FederationHost | undefined, isDebug?: boolean): void;
27
+ export declare class GetSnapshotInfoWithHook {
28
+ loaderHook: FederationHost['loaderHook'];
29
+ constructor(loaderHook: FederationHost['loaderHook']);
30
+ getInfoWithoutTypeWithHook<T extends object>(target: T, key: keyof T): {
31
+ value: T[keyof T] | undefined;
42
32
  key: string;
43
- }) | undefined;
44
- } | undefined) => GlobalModuleInfo[string] | undefined;
33
+ };
34
+ getTargetSnapshotInfoByModuleInfo(moduleInfo: Optional<Remote, 'alias'>, snapshot: GlobalModuleInfo): import("@module-federation/sdk").PureConsumerModuleInfo | import("@module-federation/sdk").ManifestProvider | undefined;
35
+ getGlobalSnapshotInfoByModuleInfo(moduleInfo: Optional<Remote, 'alias'>): import("@module-federation/sdk").PureConsumerModuleInfo | import("@module-federation/sdk").ManifestProvider | undefined;
36
+ }
37
+ export declare const getGlobalSnapshot: () => GlobalModuleInfo;
45
38
  export declare const setGlobalSnapshotInfoByModuleInfo: (remoteInfo: Remote, moduleDetailInfo: GlobalModuleInfo[string]) => GlobalModuleInfo;
46
39
  export declare const addGlobalSnapshot: (moduleInfos: GlobalModuleInfo) => (() => void);
47
40
  export declare const getRemoteEntryExports: (name: string, globalName: string | undefined) => {
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getInfoWithoutType, getGlobalSnapshot, getTargetSnapshotInfoByModuleInfo, getGlobalSnapshotInfoByModuleInfo, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
2
+ import { resetFederationGlobalInfo, getGlobalFederationInstance, setGlobalFederationInstance, getGlobalFederationConstructor, setGlobalFederationConstructor, getGlobalSnapshot, setGlobalSnapshotInfoByModuleInfo, addGlobalSnapshot, getRemoteEntryExports, registerGlobalPlugins, getGlobalHostPlugins, getPreloaded, setPreloaded, Global } from './global';
3
3
  import { getRegisteredShare, getGlobalShareScope } from './utils/share';
4
4
  interface IShareUtils {
5
5
  getRegisteredShare: typeof getRegisteredShare;
@@ -13,10 +13,7 @@ interface IGlobalUtils {
13
13
  setGlobalFederationInstance: typeof setGlobalFederationInstance;
14
14
  getGlobalFederationConstructor: typeof getGlobalFederationConstructor;
15
15
  setGlobalFederationConstructor: typeof setGlobalFederationConstructor;
16
- getInfoWithoutType: typeof getInfoWithoutType;
17
16
  getGlobalSnapshot: typeof getGlobalSnapshot;
18
- getTargetSnapshotInfoByModuleInfo: typeof getTargetSnapshotInfoByModuleInfo;
19
- getGlobalSnapshotInfoByModuleInfo: typeof getGlobalSnapshotInfoByModuleInfo;
20
17
  setGlobalSnapshotInfoByModuleInfo: typeof setGlobalSnapshotInfoByModuleInfo;
21
18
  addGlobalSnapshot: typeof addGlobalSnapshot;
22
19
  getRemoteEntryExports: typeof getRemoteEntryExports;
@@ -1,6 +1,6 @@
1
1
  import { GlobalModuleInfo, Manifest, ModuleInfo } from '@module-federation/sdk';
2
2
  import { Options, Remote } from '../../type';
3
- import { getGlobalSnapshot } from '../../global';
3
+ import { getGlobalSnapshot, GetSnapshotInfoWithHook } from '../../global';
4
4
  import { PluginSystem, AsyncHook, AsyncWaterfallHook } from '../../utils/hooks';
5
5
  import { FederationHost } from '../../core';
6
6
  export declare class SnapshotHandler {
@@ -30,6 +30,7 @@ export declare class SnapshotHandler {
30
30
  }>;
31
31
  loaderHook: FederationHost['loaderHook'];
32
32
  manifestLoading: Record<string, Promise<ModuleInfo>>;
33
+ getSnapshotInfoHandler: GetSnapshotInfoWithHook;
33
34
  constructor(HostInstance: FederationHost);
34
35
  loadSnapshot(moduleInfo: Remote): Promise<{
35
36
  remoteSnapshot: GlobalModuleInfo[string] | undefined;
@@ -38,12 +38,12 @@ type SharedBaseArgs = {
38
38
  deps?: Array<string>;
39
39
  strategy?: 'version-first' | 'loaded-first';
40
40
  };
41
+ export type SharedGetter = (() => () => Module) | (() => Promise<() => Module>);
41
42
  export type ShareArgs = (SharedBaseArgs & {
42
- get: () => () => Module | Promise<() => Module>;
43
+ get: SharedGetter;
43
44
  }) | (SharedBaseArgs & {
44
45
  lib: () => Module;
45
46
  });
46
- export type SharedGetter = () => () => Promise<() => Module> | Module;
47
47
  export type Shared = {
48
48
  version: string;
49
49
  get: SharedGetter;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.0.0-next-20240115064607",
3
+ "version": "0.0.0-next-20240117093010",
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-20240115064607"
48
+ "@module-federation/sdk": "0.0.0-next-20240117093010"
49
49
  }
50
50
  }