@module-federation/runtime-core 0.0.0-next-20250920074657 → 0.0.0-next-20250922150632

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.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { _ as _extends, a as _object_without_properties_loose } from './polyfills.esm.js';
2
2
  import { createLogger, isBrowserEnv, isReactNativeEnv, isDebugMode, composeKeyWithSeparator, loadScriptNode, loadScript, createLink, createScript, safeToString, getResourceUrl, isManifestProvider, generateSnapshotFromManifest, warn as warn$1 } from '@module-federation/sdk';
3
3
  export { loadScript, loadScriptNode } from '@module-federation/sdk';
4
- import { getShortErrorMsg, RUNTIME_008, runtimeDescMap, RUNTIME_001, RUNTIME_002, RUNTIME_007, RUNTIME_003, RUNTIME_005, RUNTIME_006, RUNTIME_004 } from '@module-federation/error-codes';
4
+ import { RUNTIME_008, getShortErrorMsg, runtimeDescMap, RUNTIME_001, RUNTIME_002, RUNTIME_007, RUNTIME_003, RUNTIME_005, RUNTIME_006, RUNTIME_004 } from '@module-federation/error-codes';
5
5
 
6
6
  const LOG_CATEGORY = '[ Federation Runtime ]';
7
7
  // FIXME: pre-bundle ?
@@ -201,7 +201,7 @@ function getGlobalFederationConstructor() {
201
201
  function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
202
202
  if (isDebug) {
203
203
  CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
204
- CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-next-20250920074657";
204
+ CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.0.0-next-20250922150632";
205
205
  }
206
206
  }
207
207
  // eslint-disable-next-line @typescript-eslint/ban-types
@@ -301,8 +301,8 @@ const getGlobalHostPlugins = ()=>nativeGlobal.__FEDERATION__.__GLOBAL_PLUGIN__;
301
301
  const getPreloaded = (id)=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.get(id);
302
302
  const setPreloaded = (id)=>CurrentGlobal.__FEDERATION__.__PRELOADED_MAP__.set(id, true);
303
303
 
304
- const DEFAULT_REMOTE_TYPE = 'global';
305
304
  const DEFAULT_SCOPE = 'default';
305
+ const DEFAULT_REMOTE_TYPE = 'global';
306
306
 
307
307
  // fork from https://github.com/originjs/vite-plugin-federation/blob/v1.1.12/packages/lib/src/utils/semver/index.ts
308
308
  // those constants are based on https://www.rubydoc.info/gems/semantic_range/3.0.0/SemanticRange#BUILDIDENTIFIER-constant
@@ -1190,7 +1190,7 @@ function getRemoteEntryUniqueKey(remoteInfo) {
1190
1190
  return composeKeyWithSeparator(name, entry);
1191
1191
  }
1192
1192
  async function getRemoteEntry(params) {
1193
- const { origin, remoteEntryExports, remoteInfo, getEntryUrl } = params;
1193
+ const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
1194
1194
  const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
1195
1195
  if (remoteEntryExports) {
1196
1196
  return remoteEntryExports;
@@ -1217,6 +1217,28 @@ async function getRemoteEntry(params) {
1217
1217
  remoteInfo,
1218
1218
  loaderHook
1219
1219
  });
1220
+ }).catch(async (err)=>{
1221
+ const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
1222
+ const isScriptLoadError = err instanceof Error && err.message.includes(RUNTIME_008);
1223
+ if (isScriptLoadError && !_inErrorHandling) {
1224
+ const wrappedGetRemoteEntry = (params)=>{
1225
+ return getRemoteEntry(_extends({}, params, {
1226
+ _inErrorHandling: true
1227
+ }));
1228
+ };
1229
+ const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
1230
+ getRemoteEntry: wrappedGetRemoteEntry,
1231
+ origin,
1232
+ remoteInfo: remoteInfo,
1233
+ remoteEntryExports,
1234
+ globalLoading,
1235
+ uniqueKey
1236
+ });
1237
+ if (RemoteEntryExports) {
1238
+ return RemoteEntryExports;
1239
+ }
1240
+ }
1241
+ throw err;
1220
1242
  });
1221
1243
  }
1222
1244
  return globalLoading[uniqueKey];
@@ -1432,26 +1454,11 @@ let Module = class Module {
1432
1454
  return this.remoteEntryExports;
1433
1455
  }
1434
1456
  let remoteEntryExports;
1435
- try {
1436
- remoteEntryExports = await getRemoteEntry({
1437
- origin: this.host,
1438
- remoteInfo: this.remoteInfo,
1439
- remoteEntryExports: this.remoteEntryExports
1440
- });
1441
- } catch (err) {
1442
- const uniqueKey = getRemoteEntryUniqueKey(this.remoteInfo);
1443
- const isScriptLoadError = err instanceof Error && err.message.includes(RUNTIME_008);
1444
- if (isScriptLoadError) {
1445
- remoteEntryExports = await this.host.loaderHook.lifecycle.loadEntryError.emit({
1446
- getRemoteEntry,
1447
- origin: this.host,
1448
- remoteInfo: this.remoteInfo,
1449
- remoteEntryExports: this.remoteEntryExports,
1450
- globalLoading,
1451
- uniqueKey
1452
- });
1453
- }
1454
- }
1457
+ remoteEntryExports = await getRemoteEntry({
1458
+ origin: this.host,
1459
+ remoteInfo: this.remoteInfo,
1460
+ remoteEntryExports: this.remoteEntryExports
1461
+ });
1455
1462
  assert(remoteEntryExports, `remoteEntryExports is undefined \n ${safeToString(this.remoteInfo)}`);
1456
1463
  this.remoteEntryExports = remoteEntryExports;
1457
1464
  return this.remoteEntryExports;
@@ -3042,7 +3049,7 @@ class ModuleFederation {
3042
3049
  // maybe will change, temporarily for internal use only
3043
3050
  initContainer: new AsyncWaterfallHook('initContainer')
3044
3051
  });
3045
- this.version = "0.0.0-next-20250920074657";
3052
+ this.version = "0.0.0-next-20250922150632";
3046
3053
  this.moduleCache = new Map();
3047
3054
  this.loaderHook = new PluginSystem({
3048
3055
  // FIXME: may not be suitable , not open to the public yet