@module-federation/runtime-core 2.9.0 → 2.9.1
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/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/global.cjs +1 -1
- package/dist/global.js +1 -1
- package/dist/utils/load.cjs +6 -2
- package/dist/utils/load.cjs.map +1 -1
- package/dist/utils/load.js +6 -2
- package/dist/utils/load.js.map +1 -1
- package/package.json +3 -3
package/dist/core.cjs
CHANGED
|
@@ -33,7 +33,7 @@ var ModuleFederation = class {
|
|
|
33
33
|
beforeInitContainer: new require_asyncWaterfallHooks.AsyncWaterfallHook("beforeInitContainer"),
|
|
34
34
|
initContainer: new require_asyncWaterfallHooks.AsyncWaterfallHook("initContainer")
|
|
35
35
|
});
|
|
36
|
-
this.version = "2.9.
|
|
36
|
+
this.version = "2.9.1";
|
|
37
37
|
this.moduleCache = /* @__PURE__ */ new Map();
|
|
38
38
|
this.loaderHook = new require_pluginSystem.PluginSystem({
|
|
39
39
|
getModuleInfo: new require_syncHook.SyncHook(),
|
package/dist/core.js
CHANGED
|
@@ -33,7 +33,7 @@ var ModuleFederation = class {
|
|
|
33
33
|
beforeInitContainer: new AsyncWaterfallHook("beforeInitContainer"),
|
|
34
34
|
initContainer: new AsyncWaterfallHook("initContainer")
|
|
35
35
|
});
|
|
36
|
-
this.version = "2.9.
|
|
36
|
+
this.version = "2.9.1";
|
|
37
37
|
this.moduleCache = /* @__PURE__ */ new Map();
|
|
38
38
|
this.loaderHook = new PluginSystem({
|
|
39
39
|
getModuleInfo: new SyncHook(),
|
package/dist/global.cjs
CHANGED
|
@@ -69,7 +69,7 @@ function getGlobalFederationConstructor() {
|
|
|
69
69
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = (0, _module_federation_sdk.isDebugMode)()) {
|
|
70
70
|
if (isDebug) {
|
|
71
71
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
72
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.9.
|
|
72
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.9.1";
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
function getInfoWithoutType(target, key) {
|
package/dist/global.js
CHANGED
|
@@ -69,7 +69,7 @@ function getGlobalFederationConstructor() {
|
|
|
69
69
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = isDebugMode()) {
|
|
70
70
|
if (isDebug) {
|
|
71
71
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
72
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.9.
|
|
72
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "2.9.1";
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
function getInfoWithoutType(target, key) {
|
package/dist/utils/load.cjs
CHANGED
|
@@ -171,7 +171,7 @@ async function getRemoteEntry(params) {
|
|
|
171
171
|
if (!require_global.globalLoading[uniqueKey]) {
|
|
172
172
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
173
173
|
const loaderHook = origin.loaderHook;
|
|
174
|
-
|
|
174
|
+
const loading = loadEntryHook.emit({
|
|
175
175
|
origin,
|
|
176
176
|
loaderHook,
|
|
177
177
|
remoteInfo,
|
|
@@ -235,7 +235,11 @@ async function getRemoteEntry(params) {
|
|
|
235
235
|
});
|
|
236
236
|
throw loadError;
|
|
237
237
|
});
|
|
238
|
-
|
|
238
|
+
require_global.globalLoading[uniqueKey] = loading;
|
|
239
|
+
loading.then(void 0, () => {
|
|
240
|
+
if (require_global.globalLoading[uniqueKey] === loading) delete require_global.globalLoading[uniqueKey];
|
|
241
|
+
});
|
|
242
|
+
remoteEntryLoadingOrigins.set(loading, origin);
|
|
239
243
|
}
|
|
240
244
|
const remoteEntryLoading = require_global.globalLoading[uniqueKey];
|
|
241
245
|
if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) try {
|
package/dist/utils/load.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.cjs","names":["RUNTIME_008","runtimeDescMap","getRemoteEntryExports","RUNTIME_001","globalLoading","isBrowserEnvValue","DEFAULT_REMOTE_TYPE","DEFAULT_SCOPE"],"sources":["../../src/utils/load.ts"],"sourcesContent":["import {\n loadScript,\n loadScriptNode,\n composeKeyWithSeparator,\n isBrowserEnvValue,\n} from '@module-federation/sdk';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { ModuleFederation } from '../core';\nimport { globalLoading, getRemoteEntryExports } from '../global';\nimport {\n Remote,\n RemoteEntryExports,\n RemoteInfo,\n ResourceLoadContext,\n} from '../type';\nimport { assert, error } from './logger';\nimport {\n RUNTIME_001,\n RUNTIME_008,\n runtimeDescMap,\n} from '@module-federation/error-codes';\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\nconst importCallback = '.then(callbacks[0]).catch(callbacks[1])';\nconst remoteEntryLoadingOrigins = new WeakMap<\n Promise<RemoteEntryExports | void>,\n ModuleFederation\n>();\n\nconst esmRemoteEntryLoadErrorMessages = [\n 'Failed to fetch dynamically imported module',\n 'Importing a module script failed',\n 'error loading dynamically imported module',\n];\n\nfunction isEsmRemoteEntryLoadError(err: unknown): boolean {\n if (!(err instanceof TypeError)) {\n return false;\n }\n\n return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) =>\n err.message.includes(loadErrorMessage),\n );\n}\n\nexport function isEsmRemoteType(type: RemoteInfo['type']): boolean {\n return type === 'esm' || type === 'module';\n}\n\nasync function loadEsmEntry({\n entry,\n remoteEntryExports,\n name,\n getEntryUrl,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n name: string;\n getEntryUrl?: (url: string) => string;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n const rejectEntry = (loadError: unknown) => {\n if (isEsmRemoteEntryLoadError(loadError)) {\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n try {\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n } catch (runtimeError) {\n reject(runtimeError);\n return;\n }\n }\n\n reject(loadError);\n };\n\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n try {\n if (!remoteEntryExports) {\n if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {\n new Function('callbacks', `import(\"${url}\")${importCallback}`)([\n resolve,\n rejectEntry,\n ]);\n } else {\n import(/* webpackIgnore: true */ /* @vite-ignore */ url)\n .then(resolve)\n .catch(rejectEntry);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load ESM entry from \"${url}\". ${msg}`);\n }\n });\n}\n\nasync function loadSystemJsEntry({\n entry,\n remoteEntryExports,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n try {\n if (!remoteEntryExports) {\n //@ts-ignore\n if (typeof __system_context__ === 'undefined') {\n //@ts-ignore\n System.import(entry).then(resolve).catch(reject);\n } else {\n new Function(\n 'callbacks',\n `System.import(\"${entry}\")${importCallback}`,\n )([resolve, reject]);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load SystemJS entry from \"${entry}\". ${msg}`);\n }\n });\n}\n\nfunction handleRemoteEntryLoaded(\n name: string,\n globalName: string,\n entry: string,\n): RemoteEntryExports {\n const { remoteEntryKey, entryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (!entryExports) {\n error(RUNTIME_001, runtimeDescMap, {\n remoteName: name,\n remoteEntryUrl: entry,\n remoteEntryKey,\n });\n }\n\n return entryExports;\n}\n\nasync function loadEntryScript({\n name,\n globalName,\n entry,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n name: string;\n globalName: string;\n entry: string;\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports> {\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n // if getEntryUrl is passed, use the getEntryUrl to get the entry url\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n return loadScript(url, {\n attrs: {},\n createScriptHook: (url, attrs) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if (res instanceof HTMLScriptElement) {\n return res;\n }\n\n if ('script' in res || 'timeout' in res) {\n return res;\n }\n\n return;\n },\n }).then(\n () => {\n // loadScript resolved: script was fetched, executed without throwing, and\n // did not trigger a ScriptExecutionError listener. Now verify the global was registered.\n return handleRemoteEntryLoaded(name, globalName, entry);\n },\n (loadError: unknown) => {\n // loadScript rejected — one of three causes, all with descriptive messages:\n // ScriptNetworkError — URL unreachable, 404, CORS, etc.\n // ScriptExecutionError — script fetched OK but IIFE threw during execution\n // timeout — script took too long to load\n // Errors thrown inside handleRemoteEntryLoaded above are NOT caught here.\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n },\n );\n}\nasync function loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n if (isEsmRemoteType(type)) {\n return loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl });\n }\n\n if (type === 'system') {\n return loadSystemJsEntry({ entry, remoteEntryExports });\n }\n\n return loadEntryScript({\n entry,\n globalName,\n name,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n });\n}\n\nasync function loadEntryNode({\n remoteInfo,\n loaderHook,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n return loadScriptNode(entry, {\n attrs: { name, globalName, type },\n loaderHook: {\n createScriptHook: (url: string, attrs: Record<string, any> = {}) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if ('url' in res) {\n return res;\n }\n\n return;\n },\n },\n })\n .then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n })\n .catch((e) => {\n const msg = e instanceof Error ? e.message : String(e);\n error(\n `Failed to load Node.js entry for remote \"${name}\" from \"${entry}\". ${msg}`,\n );\n });\n}\n\nexport function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string {\n const { entry, name } = remoteInfo;\n return composeKeyWithSeparator(name, entry);\n}\n\nexport async function getRemoteEntry(params: {\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | undefined;\n getEntryUrl?: (url: string) => string;\n _inErrorHandling?: boolean; // Add flag to prevent recursion\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports | false | void> {\n const {\n origin,\n remoteEntryExports,\n remoteInfo,\n getEntryUrl,\n resourceContext,\n _inErrorHandling = false,\n } = params;\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n\n if (remoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n cached: true,\n });\n return remoteEntryExports;\n }\n\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n globalLoading[uniqueKey] = loadEntryHook\n .emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n })\n .then((res) => {\n if (res) {\n return res;\n }\n const isWebEnvironment =\n typeof ENV_TARGET !== 'undefined'\n ? ENV_TARGET === 'web'\n : isBrowserEnvValue;\n\n return isWebEnvironment\n ? loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n })\n : loadEntryNode({ remoteInfo, loaderHook, resourceContext });\n })\n .then(async (res) => {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: res,\n resourceContext,\n });\n return res;\n })\n .catch(async (loadError) => {\n const isScriptExecutionError =\n loadError instanceof Error &&\n loadError.message.includes('ScriptExecutionError');\n const isScriptLoadError =\n loadError instanceof Error &&\n loadError.message.includes(RUNTIME_008) &&\n !isScriptExecutionError;\n\n if (isScriptLoadError && !_inErrorHandling) {\n const wrappedGetRemoteEntry = (\n params: Parameters<typeof getRemoteEntry>[0],\n ) => {\n return getRemoteEntry({ ...params, _inErrorHandling: true });\n };\n\n const recoveredRemoteEntryExports =\n await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey,\n });\n\n if (recoveredRemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: recoveredRemoteEntryExports,\n resourceContext,\n error: loadError,\n recovered: true,\n });\n return recoveredRemoteEntryExports;\n }\n }\n\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n });\n remoteEntryLoadingOrigins.set(globalLoading[uniqueKey], origin);\n }\n\n const remoteEntryLoading = globalLoading[uniqueKey];\n if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) {\n try {\n const result = await remoteEntryLoading;\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: result,\n resourceContext,\n });\n return result;\n } catch (loadError) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n }\n }\n\n return remoteEntryLoading;\n}\n\nexport function getRemoteInfo(remote: Remote): RemoteInfo {\n return {\n ...remote,\n entry: 'entry' in remote ? remote.entry : '',\n type: remote.type || DEFAULT_REMOTE_TYPE,\n entryGlobalName: remote.entryGlobalName || remote.name,\n shareScope: remote.shareScope || DEFAULT_SCOPE,\n };\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,iBAAiB;AACvB,MAAM,4CAA4B,IAAI,SAGnC;AAEH,MAAM,kCAAkC;CACtC;CACA;CACA;CACD;AAED,SAAS,0BAA0B,KAAuB;AACxD,KAAI,EAAE,eAAe,WACnB,QAAO;AAGT,QAAO,gCAAgC,MAAM,qBAC3C,IAAI,QAAQ,SAAS,iBAAiB,CACvC;;AAGH,SAAgB,gBAAgB,MAAmC;AACjE,QAAO,SAAS,SAAS,SAAS;;AAGpC,eAAe,aAAa,EAC1B,OACA,oBACA,MACA,eAM8B;AAC9B,QAAO,IAAI,SAA6B,SAAS,WAAW;EAC1D,MAAM,eAAe,cAAu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SACrB,UAAU,QAAQ,SAASL,2CAAY,IACvC,CAAC,0BAEsB,CAAC,kBAAkB;IAC1C,MAAM,yBACJ,WACG;AACH,YAAO,eAAe;MAAE,GAAG;MAAQ,kBAAkB;MAAM,CAAC;;IAG9D,MAAM,8BACJ,MAAM,OAAO,WAAW,UAAU,eAAe,KAAK;KACpD,gBAAgB;KAChB;KACA;KACA;KACA;KACA;KACD,CAAC;AAEJ,QAAI,6BAA6B;AAC/B,WAAM,OAAO,WAAW,UAAU,eAAe,KAAK;MACpD;MACA;MACA,oBAAoB;MACpB;MACA,OAAO;MACP,WAAW;MACZ,CAAC;AACF,YAAO;;;AAIX,SAAM,OAAO,WAAW,UAAU,eAAe,KAAK;IACpD;IACA;IACA;IACA,OAAO;IACR,CAAC;AACF,SAAM;IACN;AACJ,4BAA0B,IAAII,6BAAc,YAAY,OAAO;;CAGjE,MAAM,qBAAqBA,6BAAc;AACzC,KAAI,0BAA0B,IAAI,mBAAmB,KAAK,OACxD,KAAI;EACF,MAAM,SAAS,MAAM;AACrB,QAAM,OAAO,WAAW,UAAU,eAAe,KAAK;GACpD;GACA;GACA,oBAAoB;GACpB;GACD,CAAC;AACF,SAAO;UACA,WAAW;AAClB,QAAM,OAAO,WAAW,UAAU,eAAe,KAAK;GACpD;GACA;GACA;GACA,OAAO;GACR,CAAC;AACF,QAAM;;AAIV,QAAO;;AAGT,SAAgB,cAAc,QAA4B;AACxD,QAAO;EACL,GAAG;EACH,OAAO,WAAW,SAAS,OAAO,QAAQ;EAC1C,MAAM,OAAO,QAAQE;EACrB,iBAAiB,OAAO,mBAAmB,OAAO;EAClD,YAAY,OAAO,cAAcC;EAClC"}
|
|
1
|
+
{"version":3,"file":"load.cjs","names":["RUNTIME_008","runtimeDescMap","getRemoteEntryExports","RUNTIME_001","globalLoading","isBrowserEnvValue","DEFAULT_REMOTE_TYPE","DEFAULT_SCOPE"],"sources":["../../src/utils/load.ts"],"sourcesContent":["import {\n loadScript,\n loadScriptNode,\n composeKeyWithSeparator,\n isBrowserEnvValue,\n} from '@module-federation/sdk';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { ModuleFederation } from '../core';\nimport { globalLoading, getRemoteEntryExports } from '../global';\nimport {\n Remote,\n RemoteEntryExports,\n RemoteInfo,\n ResourceLoadContext,\n} from '../type';\nimport { assert, error } from './logger';\nimport {\n RUNTIME_001,\n RUNTIME_008,\n runtimeDescMap,\n} from '@module-federation/error-codes';\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\nconst importCallback = '.then(callbacks[0]).catch(callbacks[1])';\nconst remoteEntryLoadingOrigins = new WeakMap<\n Promise<RemoteEntryExports | void>,\n ModuleFederation\n>();\n\nconst esmRemoteEntryLoadErrorMessages = [\n 'Failed to fetch dynamically imported module',\n 'Importing a module script failed',\n 'error loading dynamically imported module',\n];\n\nfunction isEsmRemoteEntryLoadError(err: unknown): boolean {\n if (!(err instanceof TypeError)) {\n return false;\n }\n\n return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) =>\n err.message.includes(loadErrorMessage),\n );\n}\n\nexport function isEsmRemoteType(type: RemoteInfo['type']): boolean {\n return type === 'esm' || type === 'module';\n}\n\nasync function loadEsmEntry({\n entry,\n remoteEntryExports,\n name,\n getEntryUrl,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n name: string;\n getEntryUrl?: (url: string) => string;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n const rejectEntry = (loadError: unknown) => {\n if (isEsmRemoteEntryLoadError(loadError)) {\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n try {\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n } catch (runtimeError) {\n reject(runtimeError);\n return;\n }\n }\n\n reject(loadError);\n };\n\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n try {\n if (!remoteEntryExports) {\n if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {\n new Function('callbacks', `import(\"${url}\")${importCallback}`)([\n resolve,\n rejectEntry,\n ]);\n } else {\n import(/* webpackIgnore: true */ /* @vite-ignore */ url)\n .then(resolve)\n .catch(rejectEntry);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load ESM entry from \"${url}\". ${msg}`);\n }\n });\n}\n\nasync function loadSystemJsEntry({\n entry,\n remoteEntryExports,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n try {\n if (!remoteEntryExports) {\n //@ts-ignore\n if (typeof __system_context__ === 'undefined') {\n //@ts-ignore\n System.import(entry).then(resolve).catch(reject);\n } else {\n new Function(\n 'callbacks',\n `System.import(\"${entry}\")${importCallback}`,\n )([resolve, reject]);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load SystemJS entry from \"${entry}\". ${msg}`);\n }\n });\n}\n\nfunction handleRemoteEntryLoaded(\n name: string,\n globalName: string,\n entry: string,\n): RemoteEntryExports {\n const { remoteEntryKey, entryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (!entryExports) {\n error(RUNTIME_001, runtimeDescMap, {\n remoteName: name,\n remoteEntryUrl: entry,\n remoteEntryKey,\n });\n }\n\n return entryExports;\n}\n\nasync function loadEntryScript({\n name,\n globalName,\n entry,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n name: string;\n globalName: string;\n entry: string;\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports> {\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n // if getEntryUrl is passed, use the getEntryUrl to get the entry url\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n return loadScript(url, {\n attrs: {},\n createScriptHook: (url, attrs) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if (res instanceof HTMLScriptElement) {\n return res;\n }\n\n if ('script' in res || 'timeout' in res) {\n return res;\n }\n\n return;\n },\n }).then(\n () => {\n // loadScript resolved: script was fetched, executed without throwing, and\n // did not trigger a ScriptExecutionError listener. Now verify the global was registered.\n return handleRemoteEntryLoaded(name, globalName, entry);\n },\n (loadError: unknown) => {\n // loadScript rejected — one of three causes, all with descriptive messages:\n // ScriptNetworkError — URL unreachable, 404, CORS, etc.\n // ScriptExecutionError — script fetched OK but IIFE threw during execution\n // timeout — script took too long to load\n // Errors thrown inside handleRemoteEntryLoaded above are NOT caught here.\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n },\n );\n}\nasync function loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n if (isEsmRemoteType(type)) {\n return loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl });\n }\n\n if (type === 'system') {\n return loadSystemJsEntry({ entry, remoteEntryExports });\n }\n\n return loadEntryScript({\n entry,\n globalName,\n name,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n });\n}\n\nasync function loadEntryNode({\n remoteInfo,\n loaderHook,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n return loadScriptNode(entry, {\n attrs: { name, globalName, type },\n loaderHook: {\n createScriptHook: (url: string, attrs: Record<string, any> = {}) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if ('url' in res) {\n return res;\n }\n\n return;\n },\n },\n })\n .then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n })\n .catch((e) => {\n const msg = e instanceof Error ? e.message : String(e);\n error(\n `Failed to load Node.js entry for remote \"${name}\" from \"${entry}\". ${msg}`,\n );\n });\n}\n\nexport function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string {\n const { entry, name } = remoteInfo;\n return composeKeyWithSeparator(name, entry);\n}\n\nexport async function getRemoteEntry(params: {\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | undefined;\n getEntryUrl?: (url: string) => string;\n _inErrorHandling?: boolean; // Add flag to prevent recursion\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports | false | void> {\n const {\n origin,\n remoteEntryExports,\n remoteInfo,\n getEntryUrl,\n resourceContext,\n _inErrorHandling = false,\n } = params;\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n\n if (remoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n cached: true,\n });\n return remoteEntryExports;\n }\n\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n const loading = loadEntryHook\n .emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n })\n .then((res) => {\n if (res) {\n return res;\n }\n const isWebEnvironment =\n typeof ENV_TARGET !== 'undefined'\n ? ENV_TARGET === 'web'\n : isBrowserEnvValue;\n\n return isWebEnvironment\n ? loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n })\n : loadEntryNode({ remoteInfo, loaderHook, resourceContext });\n })\n .then(async (res) => {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: res,\n resourceContext,\n });\n return res;\n })\n .catch(async (loadError) => {\n const isScriptExecutionError =\n loadError instanceof Error &&\n loadError.message.includes('ScriptExecutionError');\n const isScriptLoadError =\n loadError instanceof Error &&\n loadError.message.includes(RUNTIME_008) &&\n !isScriptExecutionError;\n\n if (isScriptLoadError && !_inErrorHandling) {\n const wrappedGetRemoteEntry = (\n params: Parameters<typeof getRemoteEntry>[0],\n ) => {\n return getRemoteEntry({ ...params, _inErrorHandling: true });\n };\n\n const recoveredRemoteEntryExports =\n await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey,\n });\n\n if (recoveredRemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: recoveredRemoteEntryExports,\n resourceContext,\n error: loadError,\n recovered: true,\n });\n return recoveredRemoteEntryExports;\n }\n }\n\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n });\n\n globalLoading[uniqueKey] = loading;\n // Clear rejected entries so a later call can retry. Keep the original\n // promise identity in the cache (do not replace with a cleanup thenable).\n // Identity check: an older rejection must not delete a newer in-flight request.\n loading.then(undefined, () => {\n if (globalLoading[uniqueKey] === loading) {\n delete globalLoading[uniqueKey];\n }\n });\n remoteEntryLoadingOrigins.set(loading, origin);\n }\n\n const remoteEntryLoading = globalLoading[uniqueKey];\n if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) {\n try {\n const result = await remoteEntryLoading;\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: result,\n resourceContext,\n });\n return result;\n } catch (loadError) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n }\n }\n\n return remoteEntryLoading;\n}\n\nexport function getRemoteInfo(remote: Remote): RemoteInfo {\n return {\n ...remote,\n entry: 'entry' in remote ? remote.entry : '',\n type: remote.type || DEFAULT_REMOTE_TYPE,\n entryGlobalName: remote.entryGlobalName || remote.name,\n shareScope: remote.shareScope || DEFAULT_SCOPE,\n };\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,iBAAiB;AACvB,MAAM,4CAA4B,IAAI,SAGnC;AAEH,MAAM,kCAAkC;CACtC;CACA;CACA;CACD;AAED,SAAS,0BAA0B,KAAuB;AACxD,KAAI,EAAE,eAAe,WACnB,QAAO;AAGT,QAAO,gCAAgC,MAAM,qBAC3C,IAAI,QAAQ,SAAS,iBAAiB,CACvC;;AAGH,SAAgB,gBAAgB,MAAmC;AACjE,QAAO,SAAS,SAAS,SAAS;;AAGpC,eAAe,aAAa,EAC1B,OACA,oBACA,MACA,eAM8B;AAC9B,QAAO,IAAI,SAA6B,SAAS,WAAW;EAC1D,MAAM,eAAe,cAAuB;AAC1C,OAAI,0BAA0B,UAAU,EAAE;IACxC,MAAM,cACJ,qBAAqB,QAAQ,UAAU,UAAU,OAAO,UAAU;AACpE,QAAI;AACF,0BACEA,4CACAC,+CACA;MACE,YAAY;MACZ,aAAa;MACd,EACD,YACD;aACM,cAAc;AACr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AW,UAAU,eAAe,KAAK;KACpD,gBAAgB;KAChB;KACA;KACA;KACA;KACA;KACD,CAAC;AAEJ,QAAI,6BAA6B;AAC/B,WAAM,OAAO,WAAW,UAAU,eAAe,KAAK;MACpD;MACA;MACA,oBAAoB;MACpB;MACA,OAAO;MACP,WAAW;MACZ,CAAC;AACF,YAAO;;;AAIX,SAAM,OAAO,WAAW,UAAU,eAAe,KAAK;IACpD;IACA;IACA;IACA,OAAO;IACR,CAAC;AACF,SAAM;IACN;AAEJ,+BAAc,aAAa;AAI3B,UAAQ,KAAK,cAAiB;AAC5B,OAAII,6BAAc,eAAe,QAC/B,QAAOA,6BAAc;IAEvB;AACF,4BAA0B,IAAI,SAAS,OAAO;;CAGhD,MAAM,qBAAqBA,6BAAc;AACzC,KAAI,0BAA0B,IAAI,mBAAmB,KAAK,OACxD,KAAI;EACF,MAAM,SAAS,MAAM;AACrB,QAAM,OAAO,WAAW,UAAU,eAAe,KAAK;GACpD;GACA;GACA,oBAAoB;GACpB;GACD,CAAC;AACF,SAAO;UACA,WAAW;AAClB,QAAM,OAAO,WAAW,UAAU,eAAe,KAAK;GACpD;GACA;GACA;GACA,OAAO;GACR,CAAC;AACF,QAAM;;AAIV,QAAO;;AAGT,SAAgB,cAAc,QAA4B;AACxD,QAAO;EACL,GAAG;EACH,OAAO,WAAW,SAAS,OAAO,QAAQ;EAC1C,MAAM,OAAO,QAAQE;EACrB,iBAAiB,OAAO,mBAAmB,OAAO;EAClD,YAAY,OAAO,cAAcC;EAClC"}
|
package/dist/utils/load.js
CHANGED
|
@@ -171,7 +171,7 @@ async function getRemoteEntry(params) {
|
|
|
171
171
|
if (!globalLoading[uniqueKey]) {
|
|
172
172
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
173
173
|
const loaderHook = origin.loaderHook;
|
|
174
|
-
|
|
174
|
+
const loading = loadEntryHook.emit({
|
|
175
175
|
origin,
|
|
176
176
|
loaderHook,
|
|
177
177
|
remoteInfo,
|
|
@@ -235,7 +235,11 @@ async function getRemoteEntry(params) {
|
|
|
235
235
|
});
|
|
236
236
|
throw loadError;
|
|
237
237
|
});
|
|
238
|
-
|
|
238
|
+
globalLoading[uniqueKey] = loading;
|
|
239
|
+
loading.then(void 0, () => {
|
|
240
|
+
if (globalLoading[uniqueKey] === loading) delete globalLoading[uniqueKey];
|
|
241
|
+
});
|
|
242
|
+
remoteEntryLoadingOrigins.set(loading, origin);
|
|
239
243
|
}
|
|
240
244
|
const remoteEntryLoading = globalLoading[uniqueKey];
|
|
241
245
|
if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) try {
|
package/dist/utils/load.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","names":[],"sources":["../../src/utils/load.ts"],"sourcesContent":["import {\n loadScript,\n loadScriptNode,\n composeKeyWithSeparator,\n isBrowserEnvValue,\n} from '@module-federation/sdk';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { ModuleFederation } from '../core';\nimport { globalLoading, getRemoteEntryExports } from '../global';\nimport {\n Remote,\n RemoteEntryExports,\n RemoteInfo,\n ResourceLoadContext,\n} from '../type';\nimport { assert, error } from './logger';\nimport {\n RUNTIME_001,\n RUNTIME_008,\n runtimeDescMap,\n} from '@module-federation/error-codes';\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\nconst importCallback = '.then(callbacks[0]).catch(callbacks[1])';\nconst remoteEntryLoadingOrigins = new WeakMap<\n Promise<RemoteEntryExports | void>,\n ModuleFederation\n>();\n\nconst esmRemoteEntryLoadErrorMessages = [\n 'Failed to fetch dynamically imported module',\n 'Importing a module script failed',\n 'error loading dynamically imported module',\n];\n\nfunction isEsmRemoteEntryLoadError(err: unknown): boolean {\n if (!(err instanceof TypeError)) {\n return false;\n }\n\n return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) =>\n err.message.includes(loadErrorMessage),\n );\n}\n\nexport function isEsmRemoteType(type: RemoteInfo['type']): boolean {\n return type === 'esm' || type === 'module';\n}\n\nasync function loadEsmEntry({\n entry,\n remoteEntryExports,\n name,\n getEntryUrl,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n name: string;\n getEntryUrl?: (url: string) => string;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n const rejectEntry = (loadError: unknown) => {\n if (isEsmRemoteEntryLoadError(loadError)) {\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n try {\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n } catch (runtimeError) {\n reject(runtimeError);\n return;\n }\n }\n\n reject(loadError);\n };\n\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n try {\n if (!remoteEntryExports) {\n if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {\n new Function('callbacks', `import(\"${url}\")${importCallback}`)([\n resolve,\n rejectEntry,\n ]);\n } else {\n import(/* webpackIgnore: true */ /* @vite-ignore */ url)\n .then(resolve)\n .catch(rejectEntry);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load ESM entry from \"${url}\". ${msg}`);\n }\n });\n}\n\nasync function loadSystemJsEntry({\n entry,\n remoteEntryExports,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n try {\n if (!remoteEntryExports) {\n //@ts-ignore\n if (typeof __system_context__ === 'undefined') {\n //@ts-ignore\n System.import(entry).then(resolve).catch(reject);\n } else {\n new Function(\n 'callbacks',\n `System.import(\"${entry}\")${importCallback}`,\n )([resolve, reject]);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load SystemJS entry from \"${entry}\". ${msg}`);\n }\n });\n}\n\nfunction handleRemoteEntryLoaded(\n name: string,\n globalName: string,\n entry: string,\n): RemoteEntryExports {\n const { remoteEntryKey, entryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (!entryExports) {\n error(RUNTIME_001, runtimeDescMap, {\n remoteName: name,\n remoteEntryUrl: entry,\n remoteEntryKey,\n });\n }\n\n return entryExports;\n}\n\nasync function loadEntryScript({\n name,\n globalName,\n entry,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n name: string;\n globalName: string;\n entry: string;\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports> {\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n // if getEntryUrl is passed, use the getEntryUrl to get the entry url\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n return loadScript(url, {\n attrs: {},\n createScriptHook: (url, attrs) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if (res instanceof HTMLScriptElement) {\n return res;\n }\n\n if ('script' in res || 'timeout' in res) {\n return res;\n }\n\n return;\n },\n }).then(\n () => {\n // loadScript resolved: script was fetched, executed without throwing, and\n // did not trigger a ScriptExecutionError listener. Now verify the global was registered.\n return handleRemoteEntryLoaded(name, globalName, entry);\n },\n (loadError: unknown) => {\n // loadScript rejected — one of three causes, all with descriptive messages:\n // ScriptNetworkError — URL unreachable, 404, CORS, etc.\n // ScriptExecutionError — script fetched OK but IIFE threw during execution\n // timeout — script took too long to load\n // Errors thrown inside handleRemoteEntryLoaded above are NOT caught here.\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n },\n );\n}\nasync function loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n if (isEsmRemoteType(type)) {\n return loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl });\n }\n\n if (type === 'system') {\n return loadSystemJsEntry({ entry, remoteEntryExports });\n }\n\n return loadEntryScript({\n entry,\n globalName,\n name,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n });\n}\n\nasync function loadEntryNode({\n remoteInfo,\n loaderHook,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n return loadScriptNode(entry, {\n attrs: { name, globalName, type },\n loaderHook: {\n createScriptHook: (url: string, attrs: Record<string, any> = {}) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if ('url' in res) {\n return res;\n }\n\n return;\n },\n },\n })\n .then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n })\n .catch((e) => {\n const msg = e instanceof Error ? e.message : String(e);\n error(\n `Failed to load Node.js entry for remote \"${name}\" from \"${entry}\". ${msg}`,\n );\n });\n}\n\nexport function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string {\n const { entry, name } = remoteInfo;\n return composeKeyWithSeparator(name, entry);\n}\n\nexport async function getRemoteEntry(params: {\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | undefined;\n getEntryUrl?: (url: string) => string;\n _inErrorHandling?: boolean; // Add flag to prevent recursion\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports | false | void> {\n const {\n origin,\n remoteEntryExports,\n remoteInfo,\n getEntryUrl,\n resourceContext,\n _inErrorHandling = false,\n } = params;\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n\n if (remoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n cached: true,\n });\n return remoteEntryExports;\n }\n\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n globalLoading[uniqueKey] = loadEntryHook\n .emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n })\n .then((res) => {\n if (res) {\n return res;\n }\n const isWebEnvironment =\n typeof ENV_TARGET !== 'undefined'\n ? ENV_TARGET === 'web'\n : isBrowserEnvValue;\n\n return isWebEnvironment\n ? loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n })\n : loadEntryNode({ remoteInfo, loaderHook, resourceContext });\n })\n .then(async (res) => {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: res,\n resourceContext,\n });\n return res;\n })\n .catch(async (loadError) => {\n const isScriptExecutionError =\n loadError instanceof Error &&\n loadError.message.includes('ScriptExecutionError');\n const isScriptLoadError =\n loadError instanceof Error &&\n loadError.message.includes(RUNTIME_008) &&\n !isScriptExecutionError;\n\n if (isScriptLoadError && !_inErrorHandling) {\n const wrappedGetRemoteEntry = (\n params: Parameters<typeof getRemoteEntry>[0],\n ) => {\n return getRemoteEntry({ ...params, _inErrorHandling: true });\n };\n\n const recoveredRemoteEntryExports =\n await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey,\n });\n\n if (recoveredRemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: recoveredRemoteEntryExports,\n resourceContext,\n error: loadError,\n recovered: true,\n });\n return recoveredRemoteEntryExports;\n }\n }\n\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n });\n remoteEntryLoadingOrigins.set(globalLoading[uniqueKey], origin);\n }\n\n const remoteEntryLoading = globalLoading[uniqueKey];\n if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) {\n try {\n const result = await remoteEntryLoading;\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: result,\n resourceContext,\n });\n return result;\n } catch (loadError) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n }\n }\n\n return remoteEntryLoading;\n}\n\nexport function getRemoteInfo(remote: Remote): RemoteInfo {\n return {\n ...remote,\n entry: 'entry' in remote ? remote.entry : '',\n type: remote.type || DEFAULT_REMOTE_TYPE,\n entryGlobalName: remote.entryGlobalName || remote.name,\n shareScope: remote.shareScope || DEFAULT_SCOPE,\n };\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,iBAAiB;AACvB,MAAM,4CAA4B,IAAI,SAGnC;AAEH,MAAM,kCAAkC;CACtC;CACA;CACA;CACD;AAED,SAAS,0BAA0B,KAAuB;AACxD,KAAI,EAAE,eAAe,WACnB,QAAO;AAGT,QAAO,gCAAgC,MAAM,qBAC3C,IAAI,QAAQ,SAAS,iBA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"sources":["../../src/utils/load.ts"],"sourcesContent":["import {\n loadScript,\n loadScriptNode,\n composeKeyWithSeparator,\n isBrowserEnvValue,\n} from '@module-federation/sdk';\nimport { DEFAULT_REMOTE_TYPE, DEFAULT_SCOPE } from '../constant';\nimport { ModuleFederation } from '../core';\nimport { globalLoading, getRemoteEntryExports } from '../global';\nimport {\n Remote,\n RemoteEntryExports,\n RemoteInfo,\n ResourceLoadContext,\n} from '../type';\nimport { assert, error } from './logger';\nimport {\n RUNTIME_001,\n RUNTIME_008,\n runtimeDescMap,\n} from '@module-federation/error-codes';\n\n// Declare the ENV_TARGET constant that will be defined by DefinePlugin\ndeclare const ENV_TARGET: 'web' | 'node';\nconst importCallback = '.then(callbacks[0]).catch(callbacks[1])';\nconst remoteEntryLoadingOrigins = new WeakMap<\n Promise<RemoteEntryExports | void>,\n ModuleFederation\n>();\n\nconst esmRemoteEntryLoadErrorMessages = [\n 'Failed to fetch dynamically imported module',\n 'Importing a module script failed',\n 'error loading dynamically imported module',\n];\n\nfunction isEsmRemoteEntryLoadError(err: unknown): boolean {\n if (!(err instanceof TypeError)) {\n return false;\n }\n\n return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) =>\n err.message.includes(loadErrorMessage),\n );\n}\n\nexport function isEsmRemoteType(type: RemoteInfo['type']): boolean {\n return type === 'esm' || type === 'module';\n}\n\nasync function loadEsmEntry({\n entry,\n remoteEntryExports,\n name,\n getEntryUrl,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n name: string;\n getEntryUrl?: (url: string) => string;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n const rejectEntry = (loadError: unknown) => {\n if (isEsmRemoteEntryLoadError(loadError)) {\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n try {\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n } catch (runtimeError) {\n reject(runtimeError);\n return;\n }\n }\n\n reject(loadError);\n };\n\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n try {\n if (!remoteEntryExports) {\n if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {\n new Function('callbacks', `import(\"${url}\")${importCallback}`)([\n resolve,\n rejectEntry,\n ]);\n } else {\n import(/* webpackIgnore: true */ /* @vite-ignore */ url)\n .then(resolve)\n .catch(rejectEntry);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load ESM entry from \"${url}\". ${msg}`);\n }\n });\n}\n\nasync function loadSystemJsEntry({\n entry,\n remoteEntryExports,\n}: {\n entry: string;\n remoteEntryExports: RemoteEntryExports | undefined;\n}): Promise<RemoteEntryExports> {\n return new Promise<RemoteEntryExports>((resolve, reject) => {\n try {\n if (!remoteEntryExports) {\n //@ts-ignore\n if (typeof __system_context__ === 'undefined') {\n //@ts-ignore\n System.import(entry).then(resolve).catch(reject);\n } else {\n new Function(\n 'callbacks',\n `System.import(\"${entry}\")${importCallback}`,\n )([resolve, reject]);\n }\n } else {\n resolve(remoteEntryExports);\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n error(`Failed to load SystemJS entry from \"${entry}\". ${msg}`);\n }\n });\n}\n\nfunction handleRemoteEntryLoaded(\n name: string,\n globalName: string,\n entry: string,\n): RemoteEntryExports {\n const { remoteEntryKey, entryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (!entryExports) {\n error(RUNTIME_001, runtimeDescMap, {\n remoteName: name,\n remoteEntryUrl: entry,\n remoteEntryKey,\n });\n }\n\n return entryExports;\n}\n\nasync function loadEntryScript({\n name,\n globalName,\n entry,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n name: string;\n globalName: string;\n entry: string;\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports> {\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n // if getEntryUrl is passed, use the getEntryUrl to get the entry url\n const url = getEntryUrl ? getEntryUrl(entry) : entry;\n return loadScript(url, {\n attrs: {},\n createScriptHook: (url, attrs) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if (res instanceof HTMLScriptElement) {\n return res;\n }\n\n if ('script' in res || 'timeout' in res) {\n return res;\n }\n\n return;\n },\n }).then(\n () => {\n // loadScript resolved: script was fetched, executed without throwing, and\n // did not trigger a ScriptExecutionError listener. Now verify the global was registered.\n return handleRemoteEntryLoaded(name, globalName, entry);\n },\n (loadError: unknown) => {\n // loadScript rejected — one of three causes, all with descriptive messages:\n // ScriptNetworkError — URL unreachable, 404, CORS, etc.\n // ScriptExecutionError — script fetched OK but IIFE threw during execution\n // timeout — script took too long to load\n // Errors thrown inside handleRemoteEntryLoaded above are NOT caught here.\n const originalMsg =\n loadError instanceof Error ? loadError.message : String(loadError);\n error(\n RUNTIME_008,\n runtimeDescMap,\n {\n remoteName: name,\n resourceUrl: url,\n },\n originalMsg,\n );\n },\n );\n}\nasync function loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports;\n loaderHook: ModuleFederation['loaderHook'];\n getEntryUrl?: (url: string) => string;\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n if (isEsmRemoteType(type)) {\n return loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl });\n }\n\n if (type === 'system') {\n return loadSystemJsEntry({ entry, remoteEntryExports });\n }\n\n return loadEntryScript({\n entry,\n globalName,\n name,\n remoteInfo,\n loaderHook,\n getEntryUrl,\n resourceContext,\n });\n}\n\nasync function loadEntryNode({\n remoteInfo,\n loaderHook,\n resourceContext,\n}: {\n remoteInfo: RemoteInfo;\n loaderHook: ModuleFederation['loaderHook'];\n resourceContext?: ResourceLoadContext;\n}) {\n const { entry, entryGlobalName: globalName, name, type } = remoteInfo;\n const { entryExports: remoteEntryExports } = getRemoteEntryExports(\n name,\n globalName,\n );\n\n if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n return loadScriptNode(entry, {\n attrs: { name, globalName, type },\n loaderHook: {\n createScriptHook: (url: string, attrs: Record<string, any> = {}) => {\n const res = loaderHook.lifecycle.createScript.emit({\n url,\n attrs,\n remoteInfo,\n resourceContext: resourceContext\n ? {\n ...resourceContext,\n url,\n }\n : undefined,\n });\n\n if (!res) return;\n\n if ('url' in res) {\n return res;\n }\n\n return;\n },\n },\n })\n .then(() => {\n return handleRemoteEntryLoaded(name, globalName, entry);\n })\n .catch((e) => {\n const msg = e instanceof Error ? e.message : String(e);\n error(\n `Failed to load Node.js entry for remote \"${name}\" from \"${entry}\". ${msg}`,\n );\n });\n}\n\nexport function getRemoteEntryUniqueKey(remoteInfo: RemoteInfo): string {\n const { entry, name } = remoteInfo;\n return composeKeyWithSeparator(name, entry);\n}\n\nexport async function getRemoteEntry(params: {\n origin: ModuleFederation;\n remoteInfo: RemoteInfo;\n remoteEntryExports?: RemoteEntryExports | undefined;\n getEntryUrl?: (url: string) => string;\n _inErrorHandling?: boolean; // Add flag to prevent recursion\n resourceContext?: ResourceLoadContext;\n}): Promise<RemoteEntryExports | false | void> {\n const {\n origin,\n remoteEntryExports,\n remoteInfo,\n getEntryUrl,\n resourceContext,\n _inErrorHandling = false,\n } = params;\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n\n if (remoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n cached: true,\n });\n return remoteEntryExports;\n }\n\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n const loading = loadEntryHook\n .emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports,\n resourceContext,\n })\n .then((res) => {\n if (res) {\n return res;\n }\n const isWebEnvironment =\n typeof ENV_TARGET !== 'undefined'\n ? ENV_TARGET === 'web'\n : isBrowserEnvValue;\n\n return isWebEnvironment\n ? loadEntryDom({\n remoteInfo,\n remoteEntryExports,\n loaderHook,\n getEntryUrl,\n resourceContext,\n })\n : loadEntryNode({ remoteInfo, loaderHook, resourceContext });\n })\n .then(async (res) => {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: res,\n resourceContext,\n });\n return res;\n })\n .catch(async (loadError) => {\n const isScriptExecutionError =\n loadError instanceof Error &&\n loadError.message.includes('ScriptExecutionError');\n const isScriptLoadError =\n loadError instanceof Error &&\n loadError.message.includes(RUNTIME_008) &&\n !isScriptExecutionError;\n\n if (isScriptLoadError && !_inErrorHandling) {\n const wrappedGetRemoteEntry = (\n params: Parameters<typeof getRemoteEntry>[0],\n ) => {\n return getRemoteEntry({ ...params, _inErrorHandling: true });\n };\n\n const recoveredRemoteEntryExports =\n await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey,\n });\n\n if (recoveredRemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: recoveredRemoteEntryExports,\n resourceContext,\n error: loadError,\n recovered: true,\n });\n return recoveredRemoteEntryExports;\n }\n }\n\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n });\n\n globalLoading[uniqueKey] = loading;\n // Clear rejected entries so a later call can retry. Keep the original\n // promise identity in the cache (do not replace with a cleanup thenable).\n // Identity check: an older rejection must not delete a newer in-flight request.\n loading.then(undefined, () => {\n if (globalLoading[uniqueKey] === loading) {\n delete globalLoading[uniqueKey];\n }\n });\n remoteEntryLoadingOrigins.set(loading, origin);\n }\n\n const remoteEntryLoading = globalLoading[uniqueKey];\n if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) {\n try {\n const result = await remoteEntryLoading;\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: result,\n resourceContext,\n });\n return result;\n } catch (loadError) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n resourceContext,\n error: loadError,\n });\n throw loadError;\n }\n }\n\n return remoteEntryLoading;\n}\n\nexport function getRemoteInfo(remote: Remote): RemoteInfo {\n return {\n ...remote,\n entry: 'entry' in remote ? remote.entry : '',\n type: remote.type || DEFAULT_REMOTE_TYPE,\n entryGlobalName: remote.entryGlobalName || remote.name,\n shareScope: remote.shareScope || DEFAULT_SCOPE,\n };\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,iBAAiB;AACvB,MAAM,4CAA4B,IAAI,SAGnC;AAEH,MAAM,kCAAkC;CACtC;CACA;CACA;CACD;AAED,SAAS,0BAA0B,KAAuB;AACxD,KAAI,EAAE,eAAe,WACnB,QAAO;AAGT,QAAO,gCAAgC,MAAM,qBAC3C,IAAI,QAAQ,SAAS,iBAAiB,CACvC;;AAGH,SAAgB,gBAAgB,MAAmC;AACjE,QAAO,SAAS,SAAS,SAAS;;AAGpC,eAAe,aAAa,EAC1B,OACA,oBACA,MACA,eAM8B;AAC9B,QAAO,IAAI,SAA6B,SAAS,WAAW;EAC1D,MAAM,eAAe,cAAuB;AAC1C,OAAI,0BAA0B,UAAU,EAAE;IACxC,MAAM,cACJ,qBAAqB,QAAQ,UAAU,UAAU,OAAO,UAAU;AACpE,QAAI;AACF,WACE,aACA,g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;MAAM,CAAC;;IAG9D,MAAM,8BACJ,MAAM,OAAO,WAAW,UAAU,eAAe,KAAK;KACpD,gBAAgB;KAChB;KACA;KACA;KACA;KACA;KACD,CAAC;AAEJ,QAAI,6BAA6B;AAC/B,WAAM,OAAO,WAAW,UAAU,eAAe,KAAK;MACpD;MACA;MACA,oBAAoB;MACpB;MACA,OAAO;MACP,WAAW;MACZ,CAAC;AACF,YAAO;;;AAIX,SAAM,OAAO,WAAW,UAAU,eAAe,KAAK;IACpD;IACA;IACA;IACA,OAAO;IACR,CAAC;AACF,SAAM;IACN;AAEJ,gBAAc,aAAa;AAI3B,UAAQ,KAAK,cAAiB;AAC5B,OAAI,cAAc,eAAe,QAC/B,QAAO,cAAc;IAEvB;AACF,4BAA0B,IAAI,SAAS,OAAO;;CAGhD,MAAM,qBAAqB,cAAc;AACzC,KAAI,0BAA0B,IAAI,mBAAmB,KAAK,OACxD,KAAI;EACF,MAAM,SAAS,MAAM;AACrB,QAAM,OAAO,WAAW,UAAU,eAAe,KAAK;GACpD;GACA;GACA,oBAAoB;GACpB;GACD,CAAC;AACF,SAAO;UACA,WAAW;AAClB,QAAM,OAAO,WAAW,UAAU,eAAe,KAAK;GACpD;GACA;GACA;GACA,OAAO;GACR,CAAC;AACF,QAAM;;AAIV,QAAO;;AAGT,SAAgB,cAAc,QAA4B;AACxD,QAAO;EACL,GAAG;EACH,OAAO,WAAW,SAAS,OAAO,QAAQ;EAC1C,MAAM,OAAO,QAAQ;EACrB,iBAAiB,OAAO,mBAAmB,OAAO;EAClD,YAAY,OAAO,cAAc;EAClC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/runtime-core",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "zhouxiao <codingzx@gmail.com>",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
}
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@module-federation/sdk": "2.9.
|
|
56
|
-
"@module-federation/error-codes": "2.9.
|
|
55
|
+
"@module-federation/sdk": "2.9.1",
|
|
56
|
+
"@module-federation/error-codes": "2.9.1"
|
|
57
57
|
},
|
|
58
58
|
"scripts": {
|
|
59
59
|
"build": "tsdown --config tsdown.config.ts",
|