@module-federation/runtime 0.6.14 → 0.6.16

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.
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var share = require('./share.cjs.js');
4
- require('./polyfills.cjs.js');
5
- require('@module-federation/sdk');
6
4
 
7
5
  const ShareUtils = {
8
6
  getRegisteredShare: share.getRegisteredShare,
@@ -1,6 +1,4 @@
1
1
  import { g as getRegisteredShare, a as getGlobalShareScope, G as Global, n as nativeGlobal, r as resetFederationGlobalInfo, b as getGlobalFederationInstance, s as setGlobalFederationInstance, c as getGlobalFederationConstructor, d as setGlobalFederationConstructor, e as getInfoWithoutType, f as getGlobalSnapshot, h as getTargetSnapshotInfoByModuleInfo, i as getGlobalSnapshotInfoByModuleInfo, j as setGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, l as getRemoteEntryExports, m as registerGlobalPlugins, o as getGlobalHostPlugins, p as getPreloaded, q as setPreloaded } from './share.esm.js';
2
- import './polyfills.esm.js';
3
- import '@module-federation/sdk';
4
2
 
5
3
  const ShareUtils = {
6
4
  getRegisteredShare,
package/dist/index.cjs.js CHANGED
@@ -3,6 +3,7 @@
3
3
  var polyfills = require('./polyfills.cjs.js');
4
4
  var sdk = require('@module-federation/sdk');
5
5
  var share = require('./share.cjs.js');
6
+ var errorCodes = require('@module-federation/error-codes');
6
7
 
7
8
  // Function to match a remote with its name and expose
8
9
  // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
@@ -146,12 +147,11 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
146
147
  }
147
148
  }).then(()=>{
148
149
  const { remoteEntryKey, entryExports } = share.getRemoteEntryExports(name, globalName);
149
- share.assert(entryExports, `
150
- Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
151
- Possible reasons could be:\n
152
- 1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
153
- 2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
154
- `);
150
+ share.assert(entryExports, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_001, errorCodes.runtimeDescMap, {
151
+ remoteName: name,
152
+ remoteEntryUrl: entry,
153
+ remoteEntryKey
154
+ }));
155
155
  return entryExports;
156
156
  }).catch((e)=>{
157
157
  throw e;
@@ -205,12 +205,11 @@ async function loadEntryNode({ remoteInfo, createScriptHook }) {
205
205
  }
206
206
  }).then(()=>{
207
207
  const { remoteEntryKey, entryExports } = share.getRemoteEntryExports(name, globalName);
208
- share.assert(entryExports, `
209
- Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
210
- Possible reasons could be:\n
211
- 1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
212
- 2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
213
- `);
208
+ share.assert(entryExports, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_001, errorCodes.runtimeDescMap, {
209
+ remoteName: name,
210
+ remoteEntryUrl: entry,
211
+ remoteEntryKey
212
+ }));
214
213
  return entryExports;
215
214
  }).catch((e)=>{
216
215
  throw e;
@@ -305,7 +304,11 @@ let Module = class Module {
305
304
  origin: this.host
306
305
  });
307
306
  if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
308
- share.logger.error('The remote entry interface does not contain "init"', '\n', 'Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]', '\n', 'Ensure that window[nameOfRemote] is returning a {get,init} object.');
307
+ share.error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_002, errorCodes.runtimeDescMap, {
308
+ remoteName: name,
309
+ remoteEntryUrl: this.remoteInfo.entry,
310
+ remoteEntryKey: this.remoteInfo.entryGlobalName
311
+ }));
309
312
  }
310
313
  await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
311
314
  await this.host.hooks.lifecycle.initContainer.emit(polyfills._extends({}, initContainerOptions, {
@@ -316,8 +319,16 @@ let Module = class Module {
316
319
  }
317
320
  this.lib = remoteEntryExports;
318
321
  this.inited = true;
322
+ let moduleFactory;
323
+ moduleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
324
+ remoteEntryExports,
325
+ expose,
326
+ moduleInfo: this.remoteInfo
327
+ });
319
328
  // get exposeGetter
320
- const moduleFactory = await remoteEntryExports.get(expose);
329
+ if (!moduleFactory) {
330
+ moduleFactory = await remoteEntryExports.get(expose);
331
+ }
321
332
  share.assert(moduleFactory, `${share.getFMId(this.remoteInfo)} remote don't export ${expose}.`);
322
333
  const wrapModuleFactory = this.wraperFactory(moduleFactory, id);
323
334
  if (!loadFactory) {
@@ -1101,12 +1112,11 @@ class SnapshotHandler {
1101
1112
  globalSnapshot: globalSnapshotRes
1102
1113
  };
1103
1114
  } else {
1104
- share.error(`
1105
- Cannot get remoteSnapshot with the name: '${moduleInfo.name}', version: '${moduleInfo.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:\n
1106
- 1. The Deploy platform did not deliver the correct data. You can use __FEDERATION__.moduleInfo to check the remoteInfo.\n
1107
- 2. The remote '${moduleInfo.name}' version '${moduleInfo.version}' is not released.\n
1108
- The transformed module info: ${JSON.stringify(globalSnapshotRes)}
1109
- `);
1115
+ share.error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_007, errorCodes.runtimeDescMap, {
1116
+ hostName: moduleInfo.name,
1117
+ hostVersion: moduleInfo.version,
1118
+ globalSnapshot: JSON.stringify(globalSnapshotRes)
1119
+ }));
1110
1120
  }
1111
1121
  }
1112
1122
  }
@@ -1130,9 +1140,10 @@ class SnapshotHandler {
1130
1140
  return manifestJson;
1131
1141
  } catch (err) {
1132
1142
  delete this.manifestLoading[manifestUrl];
1133
- share.error(`Failed to get manifestJson for ${moduleInfo.name}. The manifest URL is ${manifestUrl}. Please ensure that the manifestUrl is accessible.
1134
- \n Error message:
1135
- \n ${err}`);
1143
+ share.error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_003, errorCodes.runtimeDescMap, {
1144
+ manifestUrl,
1145
+ moduleName: moduleInfo.name
1146
+ }, `${err}`));
1136
1147
  }
1137
1148
  };
1138
1149
  const asyncLoadProcess = async ()=>{
@@ -1435,12 +1446,11 @@ class SharedHandler {
1435
1446
  if (shareInfo.get) {
1436
1447
  const module = shareInfo.get();
1437
1448
  if (module instanceof Promise) {
1438
- throw new Error(`
1439
- The loadShareSync function was unable to load ${pkgName}. The ${pkgName} could not be found in ${host.options.name}.
1440
- Possible reasons for failure: \n
1441
- 1. The ${pkgName} share was registered with the 'get' attribute, but loadShare was not used beforehand.\n
1442
- 2. The ${pkgName} share was not registered with the 'lib' attribute.\n
1443
- `);
1449
+ const errorCode = (extraOptions == null ? void 0 : extraOptions.from) === 'build' ? errorCodes.RUNTIME_005 : errorCodes.RUNTIME_006;
1450
+ throw new Error(errorCodes.getShortErrorMsg(errorCode, errorCodes.runtimeDescMap, {
1451
+ hostName: host.options.name,
1452
+ sharedPkgName: pkgName
1453
+ }));
1444
1454
  }
1445
1455
  shareInfo.lib = module;
1446
1456
  this.setShared({
@@ -1452,12 +1462,10 @@ class SharedHandler {
1452
1462
  });
1453
1463
  return shareInfo.lib;
1454
1464
  }
1455
- throw new Error(`
1456
- The loadShareSync function was unable to load ${pkgName}. The ${pkgName} could not be found in ${host.options.name}.
1457
- Possible reasons for failure: \n
1458
- 1. The ${pkgName} share was registered with the 'get' attribute, but loadShare was not used beforehand.\n
1459
- 2. The ${pkgName} share was not registered with the 'lib' attribute.\n
1460
- `);
1465
+ throw new Error(errorCodes.getShortErrorMsg(errorCodes.RUNTIME_006, errorCodes.runtimeDescMap, {
1466
+ hostName: host.options.name,
1467
+ sharedPkgName: pkgName
1468
+ }));
1461
1469
  }
1462
1470
  initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
1463
1471
  const { host } = this;
@@ -1677,14 +1685,10 @@ class RemoteHandler {
1677
1685
  }
1678
1686
  const { id: idRes } = loadRemoteArgs;
1679
1687
  const remoteSplitInfo = matchRemoteWithNameAndExpose(host.options.remotes, idRes);
1680
- share.assert(remoteSplitInfo, `
1681
- Unable to locate ${idRes} in ${host.options.name}. Potential reasons for failure include:\n
1682
- 1. ${idRes} was not included in the 'remotes' parameter of ${host.options.name || 'the host'}.\n
1683
- 2. ${idRes} could not be found in the 'remotes' of ${host.options.name} with either 'name' or 'alias' attributes.
1684
- 3. ${idRes} is not online, injected, or loaded.
1685
- 4. ${idRes} cannot be accessed on the expected.
1686
- 5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${idRes}.
1687
- `);
1688
+ share.assert(remoteSplitInfo, errorCodes.getShortErrorMsg(errorCodes.RUNTIME_004, errorCodes.runtimeDescMap, {
1689
+ hostName: host.options.name,
1690
+ requestId: idRes
1691
+ }));
1688
1692
  const { remote: rawRemote } = remoteSplitInfo;
1689
1693
  const remoteInfo = getRemoteInfo(rawRemote);
1690
1694
  const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(polyfills._extends({
@@ -1992,7 +1996,7 @@ class FederationHost {
1992
1996
  // maybe will change, temporarily for internal use only
1993
1997
  initContainer: new AsyncWaterfallHook('initContainer')
1994
1998
  });
1995
- this.version = "0.6.14";
1999
+ this.version = "0.6.16";
1996
2000
  this.moduleCache = new Map();
1997
2001
  this.loaderHook = new PluginSystem({
1998
2002
  // FIXME: may not be suitable , not open to the public yet
@@ -2000,7 +2004,8 @@ class FederationHost {
2000
2004
  createScript: new SyncHook(),
2001
2005
  createLink: new SyncHook(),
2002
2006
  // only work for manifest , so not open to the public yet
2003
- fetch: new AsyncHook()
2007
+ fetch: new AsyncHook(),
2008
+ getModuleFactory: new AsyncHook()
2004
2009
  });
2005
2010
  // TODO: Validate the details of the options
2006
2011
  // Initialize options with default values
package/dist/index.esm.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import { a as _extends, _ as _object_without_properties_loose } from './polyfills.esm.js';
2
2
  import { isBrowserEnv, loadScriptNode, composeKeyWithSeparator, loadScript, safeToString, createLink, createScript, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
3
3
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
4
- import { o as getGlobalHostPlugins, t as globalLoading, D as DEFAULT_REMOTE_TYPE, u as DEFAULT_SCOPE, l as getRemoteEntryExports, v as assert, w as logger, x as getFMId, y as isObject, z as error, A as warn, B as isPlainObject, C as isRemoteInfoWithEntry, E as isPureRemoteEntry, F as getRemoteEntryInfoFromSnapshot, e as getInfoWithoutType, p as getPreloaded, q as setPreloaded, g as getRegisteredShare, H as arrayOptions, i as getGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, j as setGlobalSnapshotInfoByModuleInfo, G as Global, f as getGlobalSnapshot, I as formatShareConfigs, J as getTargetSharedOptions, a as getGlobalShareScope, K as addUniqueItem, L as getBuilderId, d as setGlobalFederationConstructor, b as getGlobalFederationInstance, c as getGlobalFederationConstructor, s as setGlobalFederationInstance } from './share.esm.js';
4
+ import { o as getGlobalHostPlugins, t as globalLoading, D as DEFAULT_REMOTE_TYPE, u as DEFAULT_SCOPE, l as getRemoteEntryExports, v as assert, w as error, x as getFMId, y as isObject, z as warn, A as isPlainObject, B as isRemoteInfoWithEntry, C as isPureRemoteEntry, E as getRemoteEntryInfoFromSnapshot, e as getInfoWithoutType, p as getPreloaded, q as setPreloaded, g as getRegisteredShare, F as arrayOptions, i as getGlobalSnapshotInfoByModuleInfo, k as addGlobalSnapshot, j as setGlobalSnapshotInfoByModuleInfo, G as Global, f as getGlobalSnapshot, H as formatShareConfigs, I as getTargetSharedOptions, a as getGlobalShareScope, J as addUniqueItem, K as logger, L as getBuilderId, d as setGlobalFederationConstructor, b as getGlobalFederationInstance, c as getGlobalFederationConstructor, s as setGlobalFederationInstance } from './share.esm.js';
5
5
  export { m as registerGlobalPlugins } from './share.esm.js';
6
+ import { getShortErrorMsg, RUNTIME_001, runtimeDescMap, RUNTIME_002, RUNTIME_007, RUNTIME_003, RUNTIME_005, RUNTIME_006, RUNTIME_004 } from '@module-federation/error-codes';
6
7
 
7
8
  // Function to match a remote with its name and expose
8
9
  // id: pkgName(@federation/app1) + expose(button) = @federation/app1/button
@@ -146,12 +147,11 @@ async function loadEntryScript({ name, globalName, entry, createScriptHook }) {
146
147
  }
147
148
  }).then(()=>{
148
149
  const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
149
- assert(entryExports, `
150
- Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
151
- Possible reasons could be:\n
152
- 1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
153
- 2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
154
- `);
150
+ assert(entryExports, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
151
+ remoteName: name,
152
+ remoteEntryUrl: entry,
153
+ remoteEntryKey
154
+ }));
155
155
  return entryExports;
156
156
  }).catch((e)=>{
157
157
  throw e;
@@ -205,12 +205,11 @@ async function loadEntryNode({ remoteInfo, createScriptHook }) {
205
205
  }
206
206
  }).then(()=>{
207
207
  const { remoteEntryKey, entryExports } = getRemoteEntryExports(name, globalName);
208
- assert(entryExports, `
209
- Unable to use the ${name}'s '${entry}' URL with ${remoteEntryKey}'s globalName to get remoteEntry exports.
210
- Possible reasons could be:\n
211
- 1. '${entry}' is not the correct URL, or the remoteEntry resource or name is incorrect.\n
212
- 2. ${remoteEntryKey} cannot be used to get remoteEntry exports in the window object.
213
- `);
208
+ assert(entryExports, getShortErrorMsg(RUNTIME_001, runtimeDescMap, {
209
+ remoteName: name,
210
+ remoteEntryUrl: entry,
211
+ remoteEntryKey
212
+ }));
214
213
  return entryExports;
215
214
  }).catch((e)=>{
216
215
  throw e;
@@ -305,7 +304,11 @@ let Module = class Module {
305
304
  origin: this.host
306
305
  });
307
306
  if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === 'undefined') {
308
- logger.error('The remote entry interface does not contain "init"', '\n', 'Ensure the name of this remote is not reserved or in use. Check if anything already exists on window[nameOfRemote]', '\n', 'Ensure that window[nameOfRemote] is returning a {get,init} object.');
307
+ error(getShortErrorMsg(RUNTIME_002, runtimeDescMap, {
308
+ remoteName: name,
309
+ remoteEntryUrl: this.remoteInfo.entry,
310
+ remoteEntryKey: this.remoteInfo.entryGlobalName
311
+ }));
309
312
  }
310
313
  await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
311
314
  await this.host.hooks.lifecycle.initContainer.emit(_extends({}, initContainerOptions, {
@@ -316,8 +319,16 @@ let Module = class Module {
316
319
  }
317
320
  this.lib = remoteEntryExports;
318
321
  this.inited = true;
322
+ let moduleFactory;
323
+ moduleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
324
+ remoteEntryExports,
325
+ expose,
326
+ moduleInfo: this.remoteInfo
327
+ });
319
328
  // get exposeGetter
320
- const moduleFactory = await remoteEntryExports.get(expose);
329
+ if (!moduleFactory) {
330
+ moduleFactory = await remoteEntryExports.get(expose);
331
+ }
321
332
  assert(moduleFactory, `${getFMId(this.remoteInfo)} remote don't export ${expose}.`);
322
333
  const wrapModuleFactory = this.wraperFactory(moduleFactory, id);
323
334
  if (!loadFactory) {
@@ -1101,12 +1112,11 @@ class SnapshotHandler {
1101
1112
  globalSnapshot: globalSnapshotRes
1102
1113
  };
1103
1114
  } else {
1104
- error(`
1105
- Cannot get remoteSnapshot with the name: '${moduleInfo.name}', version: '${moduleInfo.version}' from __FEDERATION__.moduleInfo. The following reasons may be causing the problem:\n
1106
- 1. The Deploy platform did not deliver the correct data. You can use __FEDERATION__.moduleInfo to check the remoteInfo.\n
1107
- 2. The remote '${moduleInfo.name}' version '${moduleInfo.version}' is not released.\n
1108
- The transformed module info: ${JSON.stringify(globalSnapshotRes)}
1109
- `);
1115
+ error(getShortErrorMsg(RUNTIME_007, runtimeDescMap, {
1116
+ hostName: moduleInfo.name,
1117
+ hostVersion: moduleInfo.version,
1118
+ globalSnapshot: JSON.stringify(globalSnapshotRes)
1119
+ }));
1110
1120
  }
1111
1121
  }
1112
1122
  }
@@ -1130,9 +1140,10 @@ class SnapshotHandler {
1130
1140
  return manifestJson;
1131
1141
  } catch (err) {
1132
1142
  delete this.manifestLoading[manifestUrl];
1133
- error(`Failed to get manifestJson for ${moduleInfo.name}. The manifest URL is ${manifestUrl}. Please ensure that the manifestUrl is accessible.
1134
- \n Error message:
1135
- \n ${err}`);
1143
+ error(getShortErrorMsg(RUNTIME_003, runtimeDescMap, {
1144
+ manifestUrl,
1145
+ moduleName: moduleInfo.name
1146
+ }, `${err}`));
1136
1147
  }
1137
1148
  };
1138
1149
  const asyncLoadProcess = async ()=>{
@@ -1435,12 +1446,11 @@ class SharedHandler {
1435
1446
  if (shareInfo.get) {
1436
1447
  const module = shareInfo.get();
1437
1448
  if (module instanceof Promise) {
1438
- throw new Error(`
1439
- The loadShareSync function was unable to load ${pkgName}. The ${pkgName} could not be found in ${host.options.name}.
1440
- Possible reasons for failure: \n
1441
- 1. The ${pkgName} share was registered with the 'get' attribute, but loadShare was not used beforehand.\n
1442
- 2. The ${pkgName} share was not registered with the 'lib' attribute.\n
1443
- `);
1449
+ const errorCode = (extraOptions == null ? void 0 : extraOptions.from) === 'build' ? RUNTIME_005 : RUNTIME_006;
1450
+ throw new Error(getShortErrorMsg(errorCode, runtimeDescMap, {
1451
+ hostName: host.options.name,
1452
+ sharedPkgName: pkgName
1453
+ }));
1444
1454
  }
1445
1455
  shareInfo.lib = module;
1446
1456
  this.setShared({
@@ -1452,12 +1462,10 @@ class SharedHandler {
1452
1462
  });
1453
1463
  return shareInfo.lib;
1454
1464
  }
1455
- throw new Error(`
1456
- The loadShareSync function was unable to load ${pkgName}. The ${pkgName} could not be found in ${host.options.name}.
1457
- Possible reasons for failure: \n
1458
- 1. The ${pkgName} share was registered with the 'get' attribute, but loadShare was not used beforehand.\n
1459
- 2. The ${pkgName} share was not registered with the 'lib' attribute.\n
1460
- `);
1465
+ throw new Error(getShortErrorMsg(RUNTIME_006, runtimeDescMap, {
1466
+ hostName: host.options.name,
1467
+ sharedPkgName: pkgName
1468
+ }));
1461
1469
  }
1462
1470
  initShareScopeMap(scopeName, shareScope, extraOptions = {}) {
1463
1471
  const { host } = this;
@@ -1677,14 +1685,10 @@ class RemoteHandler {
1677
1685
  }
1678
1686
  const { id: idRes } = loadRemoteArgs;
1679
1687
  const remoteSplitInfo = matchRemoteWithNameAndExpose(host.options.remotes, idRes);
1680
- assert(remoteSplitInfo, `
1681
- Unable to locate ${idRes} in ${host.options.name}. Potential reasons for failure include:\n
1682
- 1. ${idRes} was not included in the 'remotes' parameter of ${host.options.name || 'the host'}.\n
1683
- 2. ${idRes} could not be found in the 'remotes' of ${host.options.name} with either 'name' or 'alias' attributes.
1684
- 3. ${idRes} is not online, injected, or loaded.
1685
- 4. ${idRes} cannot be accessed on the expected.
1686
- 5. The 'beforeRequest' hook was provided but did not return the correct 'remoteInfo' when attempting to load ${idRes}.
1687
- `);
1688
+ assert(remoteSplitInfo, getShortErrorMsg(RUNTIME_004, runtimeDescMap, {
1689
+ hostName: host.options.name,
1690
+ requestId: idRes
1691
+ }));
1688
1692
  const { remote: rawRemote } = remoteSplitInfo;
1689
1693
  const remoteInfo = getRemoteInfo(rawRemote);
1690
1694
  const matchInfo = await host.sharedHandler.hooks.lifecycle.afterResolve.emit(_extends({
@@ -1992,7 +1996,7 @@ class FederationHost {
1992
1996
  // maybe will change, temporarily for internal use only
1993
1997
  initContainer: new AsyncWaterfallHook('initContainer')
1994
1998
  });
1995
- this.version = "0.6.14";
1999
+ this.version = "0.6.16";
1996
2000
  this.moduleCache = new Map();
1997
2001
  this.loaderHook = new PluginSystem({
1998
2002
  // FIXME: may not be suitable , not open to the public yet
@@ -2000,7 +2004,8 @@ class FederationHost {
2000
2004
  createScript: new SyncHook(),
2001
2005
  createLink: new SyncHook(),
2002
2006
  // only work for manifest , so not open to the public yet
2003
- fetch: new AsyncHook()
2007
+ fetch: new AsyncHook(),
2008
+ getModuleFactory: new AsyncHook()
2004
2009
  });
2005
2010
  // TODO: Validate the details of the options
2006
2011
  // Initialize options with default values
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.6.14",
3
+ "version": "0.6.16",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./index.cjs.js",
6
6
  "module": "./index.esm.js",
@@ -50,6 +50,7 @@
50
50
  }
51
51
  },
52
52
  "dependencies": {
53
- "@module-federation/sdk": "workspace:*"
53
+ "@module-federation/sdk": "workspace:*",
54
+ "@module-federation/error-codes": "workspace:*"
54
55
  }
55
56
  }
package/dist/share.cjs.js CHANGED
@@ -177,7 +177,7 @@ function getGlobalFederationConstructor() {
177
177
  function setGlobalFederationConstructor(FederationConstructor, isDebug = sdk.isDebugMode()) {
178
178
  if (isDebug) {
179
179
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
180
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.14";
180
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.16";
181
181
  }
182
182
  }
183
183
  // eslint-disable-next-line @typescript-eslint/ban-types
package/dist/share.esm.js CHANGED
@@ -175,7 +175,7 @@ function getGlobalFederationConstructor() {
175
175
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
176
176
  if (isDebug) {
177
177
  globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
178
- globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.14";
178
+ globalThis.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.6.16";
179
179
  }
180
180
  }
181
181
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -867,4 +867,4 @@ function getTargetSharedOptions(options) {
867
867
  return Object.assign({}, resolver(shareInfos[pkgName]), extraOptions == null ? void 0 : extraOptions.customShareInfo);
868
868
  }
869
869
 
870
- export { warn as A, isPlainObject as B, isRemoteInfoWithEntry as C, DEFAULT_REMOTE_TYPE as D, isPureRemoteEntry as E, getRemoteEntryInfoFromSnapshot as F, Global as G, arrayOptions as H, formatShareConfigs as I, getTargetSharedOptions as J, addUniqueItem as K, getBuilderId as L, getGlobalShareScope as a, getGlobalFederationInstance as b, getGlobalFederationConstructor as c, setGlobalFederationConstructor as d, getInfoWithoutType as e, getGlobalSnapshot as f, getRegisteredShare as g, getTargetSnapshotInfoByModuleInfo as h, getGlobalSnapshotInfoByModuleInfo as i, setGlobalSnapshotInfoByModuleInfo as j, addGlobalSnapshot as k, getRemoteEntryExports as l, registerGlobalPlugins as m, nativeGlobal as n, getGlobalHostPlugins as o, getPreloaded as p, setPreloaded as q, resetFederationGlobalInfo as r, setGlobalFederationInstance as s, globalLoading as t, DEFAULT_SCOPE as u, assert as v, logger as w, getFMId as x, isObject as y, error as z };
870
+ export { isPlainObject as A, isRemoteInfoWithEntry as B, isPureRemoteEntry as C, DEFAULT_REMOTE_TYPE as D, getRemoteEntryInfoFromSnapshot as E, arrayOptions as F, Global as G, formatShareConfigs as H, getTargetSharedOptions as I, addUniqueItem as J, logger as K, getBuilderId as L, getGlobalShareScope as a, getGlobalFederationInstance as b, getGlobalFederationConstructor as c, setGlobalFederationConstructor as d, getInfoWithoutType as e, getGlobalSnapshot as f, getRegisteredShare as g, getTargetSnapshotInfoByModuleInfo as h, getGlobalSnapshotInfoByModuleInfo as i, setGlobalSnapshotInfoByModuleInfo as j, addGlobalSnapshot as k, getRemoteEntryExports as l, registerGlobalPlugins as m, nativeGlobal as n, getGlobalHostPlugins as o, getPreloaded as p, setPreloaded as q, resetFederationGlobalInfo as r, setGlobalFederationInstance as s, globalLoading as t, DEFAULT_SCOPE as u, assert as v, error as w, getFMId as x, isObject as y, warn as z };
@@ -60,6 +60,11 @@ export declare class FederationHost {
60
60
  attrs?: Record<string, any>;
61
61
  }], void | HTMLLinkElement>;
62
62
  fetch: AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
63
+ getModuleFactory: AsyncHook<[{
64
+ remoteEntryExports: RemoteEntryExports;
65
+ expose: string;
66
+ moduleInfo: RemoteInfo;
67
+ }], Promise<(() => Promise<Module>) | undefined>>;
63
68
  }>;
64
69
  constructor(userOptions: UserOptions);
65
70
  initOptions(userOptions: UserOptions): Options;
@@ -69,6 +74,7 @@ export declare class FederationHost {
69
74
  }): Promise<false | (() => T | undefined)>;
70
75
  loadShareSync<T>(pkgName: string, extraOptions?: {
71
76
  customShareInfo?: Partial<Shared>;
77
+ from?: 'build' | 'runtime';
72
78
  resolver?: (sharedOptions: ShareInfos[string]) => Shared;
73
79
  }): () => T | never;
74
80
  initializeSharing(shareScopeName?: string, extraOptions?: {
@@ -72,6 +72,11 @@ export declare class FederationHost implements IndexModule.FederationHost {
72
72
  attrs?: Record<string, any>;
73
73
  }], void | HTMLLinkElement>;
74
74
  fetch: import("./utils/hooks").AsyncHook<[string, RequestInit], false | void | Promise<Response>>;
75
+ getModuleFactory: import("./utils/hooks").AsyncHook<[{
76
+ remoteEntryExports: import("./type").RemoteEntryExports;
77
+ expose: string;
78
+ moduleInfo: import("./type").RemoteInfo;
79
+ }], Promise<(() => Promise<IndexModule.Module>) | undefined>>;
75
80
  }>;
76
81
  initOptions(...args: Parameters<IndexModule.FederationHost['initOptions']>): import("./type").Options;
77
82
  loadShare<T>(...args: Parameters<IndexModule.FederationHost['loadShare']>): Promise<false | (() => T | undefined)>;
@@ -54,6 +54,7 @@ export declare class SharedHandler {
54
54
  strategy?: ShareStrategy;
55
55
  }): Array<Promise<void>>;
56
56
  loadShareSync<T>(pkgName: string, extraOptions?: {
57
+ from?: 'build' | 'runtime';
57
58
  customShareInfo?: Partial<Shared>;
58
59
  resolver?: (sharedOptions: ShareInfos[string]) => Shared;
59
60
  }): () => T | never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@module-federation/runtime",
3
- "version": "0.6.14",
3
+ "version": "0.6.16",
4
4
  "author": "zhouxiao <codingzx@gmail.com>",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -50,6 +50,7 @@
50
50
  }
51
51
  },
52
52
  "dependencies": {
53
- "@module-federation/sdk": "0.6.14"
53
+ "@module-federation/sdk": "0.6.16",
54
+ "@module-federation/error-codes": "0.6.14"
54
55
  }
55
56
  }