@module-federation/runtime-core 2.8.1 → 2.9.0
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 +4 -8
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.ts +16 -14
- package/dist/core.js +4 -8
- package/dist/core.js.map +1 -1
- package/dist/global.cjs +17 -2
- package/dist/global.cjs.map +1 -1
- package/dist/global.d.ts +1 -0
- package/dist/global.js +16 -3
- package/dist/global.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/module/index.cjs +11 -9
- package/dist/module/index.cjs.map +1 -1
- package/dist/module/index.d.ts +3 -2
- package/dist/module/index.js +11 -9
- package/dist/module/index.js.map +1 -1
- package/dist/plugins/snapshot/SnapshotHandler.cjs +48 -5
- package/dist/plugins/snapshot/SnapshotHandler.cjs.map +1 -1
- package/dist/plugins/snapshot/SnapshotHandler.d.ts +23 -0
- package/dist/plugins/snapshot/SnapshotHandler.js +48 -5
- package/dist/plugins/snapshot/SnapshotHandler.js.map +1 -1
- package/dist/plugins/snapshot/index.cjs +31 -21
- package/dist/plugins/snapshot/index.cjs.map +1 -1
- package/dist/plugins/snapshot/index.js +31 -21
- package/dist/plugins/snapshot/index.js.map +1 -1
- package/dist/remote/index.cjs +1 -1
- package/dist/remote/index.cjs.map +1 -1
- package/dist/remote/index.d.ts +1 -0
- package/dist/remote/index.js +1 -1
- package/dist/remote/index.js.map +1 -1
- package/dist/shared/index.cjs +86 -27
- package/dist/shared/index.cjs.map +1 -1
- package/dist/shared/index.d.ts +19 -10
- package/dist/shared/index.js +86 -27
- package/dist/shared/index.js.map +1 -1
- package/dist/type/config.d.ts +9 -1
- package/dist/type/index.d.ts +3 -3
- package/dist/type/plugin.d.ts +4 -3
- package/dist/type/preload.d.ts +7 -1
- package/dist/types.d.ts +3 -3
- package/dist/utils/hooks/pluginSystem.cjs +6 -5
- package/dist/utils/hooks/pluginSystem.cjs.map +1 -1
- package/dist/utils/hooks/pluginSystem.d.ts +2 -5
- package/dist/utils/hooks/pluginSystem.js +6 -5
- package/dist/utils/hooks/pluginSystem.js.map +1 -1
- package/dist/utils/load.cjs +81 -20
- package/dist/utils/load.cjs.map +1 -1
- package/dist/utils/load.js +81 -20
- package/dist/utils/load.js.map +1 -1
- package/dist/utils/plugin.cjs +30 -7
- package/dist/utils/plugin.cjs.map +1 -1
- package/dist/utils/plugin.js +30 -7
- package/dist/utils/plugin.js.map +1 -1
- package/dist/utils/preload.cjs +21 -10
- package/dist/utils/preload.cjs.map +1 -1
- package/dist/utils/preload.d.ts +1 -1
- package/dist/utils/preload.js +21 -10
- package/dist/utils/preload.js.map +1 -1
- package/dist/utils/share.cjs +3 -2
- package/dist/utils/share.cjs.map +1 -1
- package/dist/utils/share.d.ts +3 -2
- package/dist/utils/share.js +3 -2
- package/dist/utils/share.js.map +1 -1
- package/package.json +3 -3
- package/dist/utils/hooks/index.d.ts +0 -5
|
@@ -9,14 +9,13 @@ var PluginSystem = class {
|
|
|
9
9
|
this.lifecycle = lifecycle;
|
|
10
10
|
this.lifecycleKeys = Object.keys(lifecycle);
|
|
11
11
|
}
|
|
12
|
-
applyPlugin(plugin
|
|
12
|
+
applyPlugin(plugin) {
|
|
13
13
|
require_logger.assert(require_tool.isPlainObject(plugin), "Plugin configuration is invalid.");
|
|
14
14
|
const pluginName = plugin.name;
|
|
15
15
|
require_logger.assert(pluginName, "A name must be provided by the plugin.");
|
|
16
16
|
if (!this.registerPlugins[pluginName]) {
|
|
17
17
|
this.registerPlugins[pluginName] = plugin;
|
|
18
|
-
|
|
19
|
-
Object.keys(this.lifecycle).forEach((key) => {
|
|
18
|
+
this.lifecycleKeys.forEach((key) => {
|
|
20
19
|
const pluginLife = plugin[key];
|
|
21
20
|
if (pluginLife) this.lifecycle[key].on(pluginLife);
|
|
22
21
|
});
|
|
@@ -26,9 +25,11 @@ var PluginSystem = class {
|
|
|
26
25
|
require_logger.assert(pluginName, "A name is required.");
|
|
27
26
|
const plugin = this.registerPlugins[pluginName];
|
|
28
27
|
require_logger.assert(plugin, `The plugin "${pluginName}" is not registered.`);
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
this.lifecycleKeys.forEach((key) => {
|
|
29
|
+
const pluginLife = plugin[key];
|
|
30
|
+
if (pluginLife) this.lifecycle[key].remove(pluginLife);
|
|
31
31
|
});
|
|
32
|
+
delete this.registerPlugins[pluginName];
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginSystem.cjs","names":["isPlainObject"],"sources":["../../../src/utils/hooks/pluginSystem.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"pluginSystem.cjs","names":["isPlainObject"],"sources":["../../../src/utils/hooks/pluginSystem.ts"],"sourcesContent":["import { assert, isPlainObject } from '../../utils';\n\nexport type Plugin<T extends Record<string, any>> = {\n [k in keyof T]?: Parameters<T[k]['on']>[0];\n} & {\n name: string;\n version?: string;\n};\n\nexport class PluginSystem<T extends Record<string, any>> {\n lifecycle: T;\n lifecycleKeys: Array<keyof T>;\n registerPlugins: Record<string, Plugin<T>> = {};\n\n constructor(lifecycle: T) {\n this.lifecycle = lifecycle;\n this.lifecycleKeys = Object.keys(lifecycle);\n }\n\n applyPlugin(plugin: Plugin<T>): void {\n assert(isPlainObject(plugin), 'Plugin configuration is invalid.');\n // The plugin's name is mandatory and must be unique\n const pluginName = plugin.name;\n assert(pluginName, 'A name must be provided by the plugin.');\n\n if (!this.registerPlugins[pluginName]) {\n this.registerPlugins[pluginName] = plugin;\n\n this.lifecycleKeys.forEach((key) => {\n const pluginLife = plugin[key];\n if (pluginLife) {\n this.lifecycle[key].on(pluginLife);\n }\n });\n }\n }\n\n removePlugin(pluginName: string): void {\n assert(pluginName, 'A name is required.');\n const plugin = this.registerPlugins[pluginName];\n assert(plugin, `The plugin \"${pluginName}\" is not registered.`);\n\n this.lifecycleKeys.forEach((key) => {\n const pluginLife = plugin[key];\n if (pluginLife) {\n this.lifecycle[key].remove(pluginLife);\n }\n });\n delete this.registerPlugins[pluginName];\n }\n}\n"],"mappings":";;;;;AASA,IAAa,eAAb,MAAyD;CAKvD,YAAY,WAAc;yBAFmB,EAAE;AAG7C,OAAK,YAAY;AACjB,OAAK,gBAAgB,OAAO,KAAK,UAAU;;CAG7C,YAAY,QAAyB;AACnC,wBAAOA,2BAAc,OAAO,EAAE,mCAAmC;EAEjE,MAAM,aAAa,OAAO;AAC1B,wBAAO,YAAY,yCAAyC;AAE5D,MAAI,CAAC,KAAK,gBAAgB,aAAa;AACrC,QAAK,gBAAgB,cAAc;AAEnC,QAAK,cAAc,SAAS,QAAQ;IAClC,MAAM,aAAa,OAAO;AAC1B,QAAI,WACF,MAAK,UAAU,KAAK,GAAG,WAAW;KAEpC;;;CAIN,aAAa,YAA0B;AACrC,wBAAO,YAAY,sBAAsB;EACzC,MAAM,SAAS,KAAK,gBAAgB;AACpC,wBAAO,QAAQ,eAAe,WAAW,sBAAsB;AAE/D,OAAK,cAAc,SAAS,QAAQ;GAClC,MAAM,aAAa,OAAO;AAC1B,OAAI,WACF,MAAK,UAAU,KAAK,OAAO,WAAW;IAExC;AACF,SAAO,KAAK,gBAAgB"}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { ModuleFederation } from "../../core.js";
|
|
2
|
-
|
|
3
1
|
//#region src/utils/hooks/pluginSystem.d.ts
|
|
4
2
|
type Plugin<T extends Record<string, any>> = { [k in keyof T]?: Parameters<T[k]['on']>[0] } & {
|
|
5
3
|
name: string;
|
|
6
4
|
version?: string;
|
|
7
|
-
apply?: (instance: ModuleFederation) => void;
|
|
8
5
|
};
|
|
9
6
|
declare class PluginSystem<T extends Record<string, any>> {
|
|
10
7
|
lifecycle: T;
|
|
11
8
|
lifecycleKeys: Array<keyof T>;
|
|
12
9
|
registerPlugins: Record<string, Plugin<T>>;
|
|
13
10
|
constructor(lifecycle: T);
|
|
14
|
-
applyPlugin(plugin: Plugin<T
|
|
11
|
+
applyPlugin(plugin: Plugin<T>): void;
|
|
15
12
|
removePlugin(pluginName: string): void;
|
|
16
13
|
}
|
|
17
14
|
//#endregion
|
|
18
|
-
export {
|
|
15
|
+
export { PluginSystem };
|
|
19
16
|
//# sourceMappingURL=pluginSystem.d.ts.map
|
|
@@ -9,14 +9,13 @@ var PluginSystem = class {
|
|
|
9
9
|
this.lifecycle = lifecycle;
|
|
10
10
|
this.lifecycleKeys = Object.keys(lifecycle);
|
|
11
11
|
}
|
|
12
|
-
applyPlugin(plugin
|
|
12
|
+
applyPlugin(plugin) {
|
|
13
13
|
assert(isPlainObject(plugin), "Plugin configuration is invalid.");
|
|
14
14
|
const pluginName = plugin.name;
|
|
15
15
|
assert(pluginName, "A name must be provided by the plugin.");
|
|
16
16
|
if (!this.registerPlugins[pluginName]) {
|
|
17
17
|
this.registerPlugins[pluginName] = plugin;
|
|
18
|
-
|
|
19
|
-
Object.keys(this.lifecycle).forEach((key) => {
|
|
18
|
+
this.lifecycleKeys.forEach((key) => {
|
|
20
19
|
const pluginLife = plugin[key];
|
|
21
20
|
if (pluginLife) this.lifecycle[key].on(pluginLife);
|
|
22
21
|
});
|
|
@@ -26,9 +25,11 @@ var PluginSystem = class {
|
|
|
26
25
|
assert(pluginName, "A name is required.");
|
|
27
26
|
const plugin = this.registerPlugins[pluginName];
|
|
28
27
|
assert(plugin, `The plugin "${pluginName}" is not registered.`);
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
this.lifecycleKeys.forEach((key) => {
|
|
29
|
+
const pluginLife = plugin[key];
|
|
30
|
+
if (pluginLife) this.lifecycle[key].remove(pluginLife);
|
|
31
31
|
});
|
|
32
|
+
delete this.registerPlugins[pluginName];
|
|
32
33
|
}
|
|
33
34
|
};
|
|
34
35
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginSystem.js","names":[],"sources":["../../../src/utils/hooks/pluginSystem.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"pluginSystem.js","names":[],"sources":["../../../src/utils/hooks/pluginSystem.ts"],"sourcesContent":["import { assert, isPlainObject } from '../../utils';\n\nexport type Plugin<T extends Record<string, any>> = {\n [k in keyof T]?: Parameters<T[k]['on']>[0];\n} & {\n name: string;\n version?: string;\n};\n\nexport class PluginSystem<T extends Record<string, any>> {\n lifecycle: T;\n lifecycleKeys: Array<keyof T>;\n registerPlugins: Record<string, Plugin<T>> = {};\n\n constructor(lifecycle: T) {\n this.lifecycle = lifecycle;\n this.lifecycleKeys = Object.keys(lifecycle);\n }\n\n applyPlugin(plugin: Plugin<T>): void {\n assert(isPlainObject(plugin), 'Plugin configuration is invalid.');\n // The plugin's name is mandatory and must be unique\n const pluginName = plugin.name;\n assert(pluginName, 'A name must be provided by the plugin.');\n\n if (!this.registerPlugins[pluginName]) {\n this.registerPlugins[pluginName] = plugin;\n\n this.lifecycleKeys.forEach((key) => {\n const pluginLife = plugin[key];\n if (pluginLife) {\n this.lifecycle[key].on(pluginLife);\n }\n });\n }\n }\n\n removePlugin(pluginName: string): void {\n assert(pluginName, 'A name is required.');\n const plugin = this.registerPlugins[pluginName];\n assert(plugin, `The plugin \"${pluginName}\" is not registered.`);\n\n this.lifecycleKeys.forEach((key) => {\n const pluginLife = plugin[key];\n if (pluginLife) {\n this.lifecycle[key].remove(pluginLife);\n }\n });\n delete this.registerPlugins[pluginName];\n }\n}\n"],"mappings":";;;;;AASA,IAAa,eAAb,MAAyD;CAKvD,YAAY,WAAc;yBAFmB,EAAE;AAG7C,OAAK,YAAY;AACjB,OAAK,gBAAgB,OAAO,KAAK,UAAU;;CAG7C,YAAY,QAAyB;AACnC,SAAO,cAAc,OAAO,EAAE,mCAAmC;EAEjE,MAAM,aAAa,OAAO;AAC1B,SAAO,YAAY,yCAAyC;AAE5D,MAAI,CAAC,KAAK,gBAAgB,aAAa;AACrC,QAAK,gBAAgB,cAAc;AAEnC,QAAK,cAAc,SAAS,QAAQ;IAClC,MAAM,aAAa,OAAO;AAC1B,QAAI,WACF,MAAK,UAAU,KAAK,GAAG,WAAW;KAEpC;;;CAIN,aAAa,YAA0B;AACrC,SAAO,YAAY,sBAAsB;EACzC,MAAM,SAAS,KAAK,gBAAgB;AACpC,SAAO,QAAQ,eAAe,WAAW,sBAAsB;AAE/D,OAAK,cAAc,SAAS,QAAQ;GAClC,MAAM,aAAa,OAAO;AAC1B,OAAI,WACF,MAAK,UAAU,KAAK,OAAO,WAAW;IAExC;AACF,SAAO,KAAK,gBAAgB"}
|
package/dist/utils/load.cjs
CHANGED
|
@@ -6,21 +6,47 @@ let _module_federation_error_codes = require("@module-federation/error-codes");
|
|
|
6
6
|
|
|
7
7
|
//#region src/utils/load.ts
|
|
8
8
|
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
9
|
+
const remoteEntryLoadingOrigins = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
const esmRemoteEntryLoadErrorMessages = [
|
|
11
|
+
"Failed to fetch dynamically imported module",
|
|
12
|
+
"Importing a module script failed",
|
|
13
|
+
"error loading dynamically imported module"
|
|
14
|
+
];
|
|
15
|
+
function isEsmRemoteEntryLoadError(err) {
|
|
16
|
+
if (!(err instanceof TypeError)) return false;
|
|
17
|
+
return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) => err.message.includes(loadErrorMessage));
|
|
18
|
+
}
|
|
9
19
|
function isEsmRemoteType(type) {
|
|
10
20
|
return type === "esm" || type === "module";
|
|
11
21
|
}
|
|
12
|
-
async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
22
|
+
async function loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl }) {
|
|
13
23
|
return new Promise((resolve, reject) => {
|
|
24
|
+
const rejectEntry = (loadError) => {
|
|
25
|
+
if (isEsmRemoteEntryLoadError(loadError)) {
|
|
26
|
+
const originalMsg = loadError instanceof Error ? loadError.message : String(loadError);
|
|
27
|
+
try {
|
|
28
|
+
require_logger.error(_module_federation_error_codes.RUNTIME_008, _module_federation_error_codes.runtimeDescMap, {
|
|
29
|
+
remoteName: name,
|
|
30
|
+
resourceUrl: url
|
|
31
|
+
}, originalMsg);
|
|
32
|
+
} catch (runtimeError) {
|
|
33
|
+
reject(runtimeError);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
reject(loadError);
|
|
38
|
+
};
|
|
39
|
+
const url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
14
40
|
try {
|
|
15
|
-
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${
|
|
41
|
+
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${url}")${importCallback}`)([resolve, rejectEntry]);
|
|
16
42
|
else import(
|
|
17
43
|
/* webpackIgnore: true */
|
|
18
44
|
/* @vite-ignore */
|
|
19
|
-
|
|
20
|
-
).then(resolve).catch(
|
|
45
|
+
url
|
|
46
|
+
).then(resolve).catch(rejectEntry);
|
|
21
47
|
else resolve(remoteEntryExports);
|
|
22
48
|
} catch (e) {
|
|
23
|
-
require_logger.error(`Failed to load ESM entry from "${
|
|
49
|
+
require_logger.error(`Failed to load ESM entry from "${url}". ${e instanceof Error ? e.message : String(e)}`);
|
|
24
50
|
}
|
|
25
51
|
});
|
|
26
52
|
}
|
|
@@ -78,7 +104,9 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEnt
|
|
|
78
104
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
79
105
|
if (isEsmRemoteType(type)) return loadEsmEntry({
|
|
80
106
|
entry,
|
|
81
|
-
remoteEntryExports
|
|
107
|
+
remoteEntryExports,
|
|
108
|
+
name,
|
|
109
|
+
getEntryUrl
|
|
82
110
|
});
|
|
83
111
|
if (type === "system") return loadSystemJsEntry({
|
|
84
112
|
entry,
|
|
@@ -130,7 +158,16 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
130
158
|
async function getRemoteEntry(params) {
|
|
131
159
|
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
|
|
132
160
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
133
|
-
if (remoteEntryExports)
|
|
161
|
+
if (remoteEntryExports) {
|
|
162
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
163
|
+
origin,
|
|
164
|
+
remoteInfo,
|
|
165
|
+
remoteEntryExports,
|
|
166
|
+
resourceContext,
|
|
167
|
+
cached: true
|
|
168
|
+
});
|
|
169
|
+
return remoteEntryExports;
|
|
170
|
+
}
|
|
134
171
|
if (!require_global.globalLoading[uniqueKey]) {
|
|
135
172
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
136
173
|
const loaderHook = origin.loaderHook;
|
|
@@ -138,7 +175,8 @@ async function getRemoteEntry(params) {
|
|
|
138
175
|
origin,
|
|
139
176
|
loaderHook,
|
|
140
177
|
remoteInfo,
|
|
141
|
-
remoteEntryExports
|
|
178
|
+
remoteEntryExports,
|
|
179
|
+
resourceContext
|
|
142
180
|
}).then((res) => {
|
|
143
181
|
if (res) return res;
|
|
144
182
|
return (typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : _module_federation_sdk.isBrowserEnvValue) ? loadEntryDom({
|
|
@@ -156,20 +194,20 @@ async function getRemoteEntry(params) {
|
|
|
156
194
|
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
157
195
|
origin,
|
|
158
196
|
remoteInfo,
|
|
159
|
-
remoteEntryExports: res
|
|
197
|
+
remoteEntryExports: res,
|
|
198
|
+
resourceContext
|
|
160
199
|
});
|
|
161
200
|
return res;
|
|
162
|
-
}).catch(async (
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
if (err instanceof Error && err.message.includes(_module_federation_error_codes.RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
|
|
201
|
+
}).catch(async (loadError) => {
|
|
202
|
+
const isScriptExecutionError = loadError instanceof Error && loadError.message.includes("ScriptExecutionError");
|
|
203
|
+
if (loadError instanceof Error && loadError.message.includes(_module_federation_error_codes.RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
|
|
166
204
|
const wrappedGetRemoteEntry = (params) => {
|
|
167
205
|
return getRemoteEntry({
|
|
168
206
|
...params,
|
|
169
207
|
_inErrorHandling: true
|
|
170
208
|
});
|
|
171
209
|
};
|
|
172
|
-
const
|
|
210
|
+
const recoveredRemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
|
|
173
211
|
getRemoteEntry: wrappedGetRemoteEntry,
|
|
174
212
|
origin,
|
|
175
213
|
remoteInfo,
|
|
@@ -177,25 +215,48 @@ async function getRemoteEntry(params) {
|
|
|
177
215
|
globalLoading: require_global.globalLoading,
|
|
178
216
|
uniqueKey
|
|
179
217
|
});
|
|
180
|
-
if (
|
|
218
|
+
if (recoveredRemoteEntryExports) {
|
|
181
219
|
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
182
220
|
origin,
|
|
183
221
|
remoteInfo,
|
|
184
|
-
remoteEntryExports:
|
|
222
|
+
remoteEntryExports: recoveredRemoteEntryExports,
|
|
223
|
+
resourceContext,
|
|
224
|
+
error: loadError,
|
|
185
225
|
recovered: true
|
|
186
226
|
});
|
|
187
|
-
return
|
|
227
|
+
return recoveredRemoteEntryExports;
|
|
188
228
|
}
|
|
189
229
|
}
|
|
190
230
|
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
191
231
|
origin,
|
|
192
232
|
remoteInfo,
|
|
193
|
-
|
|
233
|
+
resourceContext,
|
|
234
|
+
error: loadError
|
|
194
235
|
});
|
|
195
|
-
throw
|
|
236
|
+
throw loadError;
|
|
237
|
+
});
|
|
238
|
+
remoteEntryLoadingOrigins.set(require_global.globalLoading[uniqueKey], origin);
|
|
239
|
+
}
|
|
240
|
+
const remoteEntryLoading = require_global.globalLoading[uniqueKey];
|
|
241
|
+
if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) try {
|
|
242
|
+
const result = await remoteEntryLoading;
|
|
243
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
244
|
+
origin,
|
|
245
|
+
remoteInfo,
|
|
246
|
+
remoteEntryExports: result,
|
|
247
|
+
resourceContext
|
|
248
|
+
});
|
|
249
|
+
return result;
|
|
250
|
+
} catch (loadError) {
|
|
251
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
252
|
+
origin,
|
|
253
|
+
remoteInfo,
|
|
254
|
+
resourceContext,
|
|
255
|
+
error: loadError
|
|
196
256
|
});
|
|
257
|
+
throw loadError;
|
|
197
258
|
}
|
|
198
|
-
return
|
|
259
|
+
return remoteEntryLoading;
|
|
199
260
|
}
|
|
200
261
|
function getRemoteInfo(remote) {
|
|
201
262
|
return {
|
package/dist/utils/load.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.cjs","names":["getRemoteEntryExports","RUNTIME_001","runtimeDescMap","RUNTIME_008","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])';\n\nexport function isEsmRemoteType(type: RemoteInfo['type']): boolean {\n return type === 'esm' || type === 'module';\n}\n\nasync function loadEsmEntry({\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 if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {\n new Function('callbacks', `import(\"${entry}\")${importCallback}`)([\n resolve,\n reject,\n ]);\n } else {\n import(/* webpackIgnore: true */ /* @vite-ignore */ entry)\n .then(resolve)\n .catch(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 ESM entry from \"${entry}\". ${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 });\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 if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n\n globalLoading[uniqueKey] = loadEntryHook\n .emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports,\n })\n .then((res) => {\n if (res) {\n return res;\n }\n // Use ENV_TARGET if defined, otherwise fallback to isBrowserEnvValue\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 });\n return res;\n })\n .catch(async (err) => {\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n // ScriptExecutionError means the script downloaded fine but its IIFE\n // threw at runtime — retrying would reproduce the same error, so exclude it.\n const isScriptExecutionError =\n err instanceof Error && err.message.includes('ScriptExecutionError');\n const isScriptLoadError =\n err instanceof Error &&\n err.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 RemoteEntryExports =\n await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo: remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey,\n });\n\n if (RemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: RemoteEntryExports,\n recovered: true,\n });\n return RemoteEntryExports;\n }\n }\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n error: err,\n });\n throw err;\n });\n }\n\n return globalLoading[uniqueKey];\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;AAEvB,SAAgB,gBAAgB,MAAmC;AACjE,QAAO,SAAS,SAAS,SAAS;;AAGpC,eAAe,aAAa,EAC1B,OACA,sBAI8B;AAC9B,QAAO,IAAI,SAA6B,SAAS,WAAW;AAC1D,MAAI;AACF,OAAI,CAAC,mBACH,KAAI,OAAO,kCAAkC,YAC3C,KAAI,SAAS,aAAa,WAAW,MAAM,IAAI,iBAAiB,CAAC,CAC/D,SACA,OACD,CAAC;OAEF;;;IAAoD;EACjD,KAAK,QAAQ,CACb,MAAM,OAAO;OAGlB,SAAQ,mBAAmB;WAEtB,GAAG;AAEV,wBAAM,kCAAkC,MAAM,KADlC,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE,GACG;;GAE3D;;AAGJ,eAAe,kBAAkB,EAC/B,OACA,sBAI8B;AAC9B,QAAO,IAAI,SAA6B,SAAS,WAAW;AAC1D,MAAI;AACF,OAAI,CAAC,mBAEH,KAAI,OAAO,uBAAuB,YAEhC,QAAO,OAAO,MAAM,CAAC,KAAK,QAAQ,CAAC,MAAM,OAAO;OAEhD,KAAI,SACF,aACA,kBAAkB,MAAM,IAAI,iBAC7B,CAAC,CAAC,SAAS,OAAO,CAAC;OAGtB,SAAQ,mBAAmB;WAEtB,GAAG;AAEV,wBAAM,uCAAuC,MAAM,KADvC,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE,GACQ;;GAEhE;;AAGJ,SAAS,wBACP,MACA,YACA,OACoB;CACpB,M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AAQ;GACpB,MAAM,YAAY,wBAAwB,WAAW;GAGrD,MAAM,yBACJ,eAAe,SAAS,IAAI,QAAQ,SAAS,uBAAuB;AAMtE,OAJE,eAAe,SACf,IAAI,QAAQ,SAASF,2CAAY,IACjC,CAAC,0BAEsB,CAAC,kBAAkB;IAC1C,MAAM,yBACJ,WACG;AACH,YAAO,eAAe;MAAE,GAAG;MAAQ,kBAAkB;MAAM,CAAC;;IAG9D,MAAM,qBACJ,MAAM,OAAO,WAAW,UAAU,eAAe,KAAK;KACpD,gBAAgB;KAChB;KACY;KACZ;KACA;KACA;KACD,CAAC;AAEJ,QAAI,oBAAoB;AACtB,WAAM,OAAO,WAAW,UAAU,eAAe,KAAK;MACpD;MACA;MACA,oBAAoB;MACpB,WAAW;MACZ,CAAC;AACF,YAAO;;;AAGX,SAAM,OAAO,WAAW,UAAU,eAAe,KAAK;IACpD;IACA;IACA,OAAO;IACR,CAAC;AACF,SAAM;IACN;;AAGN,QAAOC,6BAAc;;AAGvB,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 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,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;AACrB,YAAO,aAAa;AACpB;;;AAIJ,UAAO,UAAU;;EAGnB,MAAM,MAAM,cAAc,YAAY,MAAM,GAAG;AAC/C,MAAI;AACF,OAAI,CAAC,mBACH,KAAI,OAAO,kCAAkC,YAC3C,KAAI,SAAS,aAAa,WAAW,IAAI,IAAI,iBAAiB,CAAC,CAC7D,SACA,YACD,CAAC;OAEF;;;IAAoD;EACjD,KAAK,QAAQ,CACb,MAAM,YAAY;OAGvB,SAAQ,mBAAmB;WAEtB,GAAG;AAEV,wBAAM,kCAAkC,IAAI,KADhC,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE,GACC;;GAEzD;;AA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0B,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
|
@@ -6,21 +6,47 @@ import { RUNTIME_001, RUNTIME_008, runtimeDescMap } from "@module-federation/err
|
|
|
6
6
|
|
|
7
7
|
//#region src/utils/load.ts
|
|
8
8
|
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
9
|
+
const remoteEntryLoadingOrigins = /* @__PURE__ */ new WeakMap();
|
|
10
|
+
const esmRemoteEntryLoadErrorMessages = [
|
|
11
|
+
"Failed to fetch dynamically imported module",
|
|
12
|
+
"Importing a module script failed",
|
|
13
|
+
"error loading dynamically imported module"
|
|
14
|
+
];
|
|
15
|
+
function isEsmRemoteEntryLoadError(err) {
|
|
16
|
+
if (!(err instanceof TypeError)) return false;
|
|
17
|
+
return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) => err.message.includes(loadErrorMessage));
|
|
18
|
+
}
|
|
9
19
|
function isEsmRemoteType(type) {
|
|
10
20
|
return type === "esm" || type === "module";
|
|
11
21
|
}
|
|
12
|
-
async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
22
|
+
async function loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl }) {
|
|
13
23
|
return new Promise((resolve, reject) => {
|
|
24
|
+
const rejectEntry = (loadError) => {
|
|
25
|
+
if (isEsmRemoteEntryLoadError(loadError)) {
|
|
26
|
+
const originalMsg = loadError instanceof Error ? loadError.message : String(loadError);
|
|
27
|
+
try {
|
|
28
|
+
error(RUNTIME_008, runtimeDescMap, {
|
|
29
|
+
remoteName: name,
|
|
30
|
+
resourceUrl: url
|
|
31
|
+
}, originalMsg);
|
|
32
|
+
} catch (runtimeError) {
|
|
33
|
+
reject(runtimeError);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
reject(loadError);
|
|
38
|
+
};
|
|
39
|
+
const url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
14
40
|
try {
|
|
15
|
-
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${
|
|
41
|
+
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${url}")${importCallback}`)([resolve, rejectEntry]);
|
|
16
42
|
else import(
|
|
17
43
|
/* webpackIgnore: true */
|
|
18
44
|
/* @vite-ignore */
|
|
19
|
-
|
|
20
|
-
).then(resolve).catch(
|
|
45
|
+
url
|
|
46
|
+
).then(resolve).catch(rejectEntry);
|
|
21
47
|
else resolve(remoteEntryExports);
|
|
22
48
|
} catch (e) {
|
|
23
|
-
error(`Failed to load ESM entry from "${
|
|
49
|
+
error(`Failed to load ESM entry from "${url}". ${e instanceof Error ? e.message : String(e)}`);
|
|
24
50
|
}
|
|
25
51
|
});
|
|
26
52
|
}
|
|
@@ -78,7 +104,9 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEnt
|
|
|
78
104
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
79
105
|
if (isEsmRemoteType(type)) return loadEsmEntry({
|
|
80
106
|
entry,
|
|
81
|
-
remoteEntryExports
|
|
107
|
+
remoteEntryExports,
|
|
108
|
+
name,
|
|
109
|
+
getEntryUrl
|
|
82
110
|
});
|
|
83
111
|
if (type === "system") return loadSystemJsEntry({
|
|
84
112
|
entry,
|
|
@@ -130,7 +158,16 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
130
158
|
async function getRemoteEntry(params) {
|
|
131
159
|
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
|
|
132
160
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
133
|
-
if (remoteEntryExports)
|
|
161
|
+
if (remoteEntryExports) {
|
|
162
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
163
|
+
origin,
|
|
164
|
+
remoteInfo,
|
|
165
|
+
remoteEntryExports,
|
|
166
|
+
resourceContext,
|
|
167
|
+
cached: true
|
|
168
|
+
});
|
|
169
|
+
return remoteEntryExports;
|
|
170
|
+
}
|
|
134
171
|
if (!globalLoading[uniqueKey]) {
|
|
135
172
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
136
173
|
const loaderHook = origin.loaderHook;
|
|
@@ -138,7 +175,8 @@ async function getRemoteEntry(params) {
|
|
|
138
175
|
origin,
|
|
139
176
|
loaderHook,
|
|
140
177
|
remoteInfo,
|
|
141
|
-
remoteEntryExports
|
|
178
|
+
remoteEntryExports,
|
|
179
|
+
resourceContext
|
|
142
180
|
}).then((res) => {
|
|
143
181
|
if (res) return res;
|
|
144
182
|
return (typeof ENV_TARGET !== "undefined" ? ENV_TARGET === "web" : isBrowserEnvValue) ? loadEntryDom({
|
|
@@ -156,20 +194,20 @@ async function getRemoteEntry(params) {
|
|
|
156
194
|
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
157
195
|
origin,
|
|
158
196
|
remoteInfo,
|
|
159
|
-
remoteEntryExports: res
|
|
197
|
+
remoteEntryExports: res,
|
|
198
|
+
resourceContext
|
|
160
199
|
});
|
|
161
200
|
return res;
|
|
162
|
-
}).catch(async (
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
if (err instanceof Error && err.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
|
|
201
|
+
}).catch(async (loadError) => {
|
|
202
|
+
const isScriptExecutionError = loadError instanceof Error && loadError.message.includes("ScriptExecutionError");
|
|
203
|
+
if (loadError instanceof Error && loadError.message.includes(RUNTIME_008) && !isScriptExecutionError && !_inErrorHandling) {
|
|
166
204
|
const wrappedGetRemoteEntry = (params) => {
|
|
167
205
|
return getRemoteEntry({
|
|
168
206
|
...params,
|
|
169
207
|
_inErrorHandling: true
|
|
170
208
|
});
|
|
171
209
|
};
|
|
172
|
-
const
|
|
210
|
+
const recoveredRemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
|
|
173
211
|
getRemoteEntry: wrappedGetRemoteEntry,
|
|
174
212
|
origin,
|
|
175
213
|
remoteInfo,
|
|
@@ -177,25 +215,48 @@ async function getRemoteEntry(params) {
|
|
|
177
215
|
globalLoading,
|
|
178
216
|
uniqueKey
|
|
179
217
|
});
|
|
180
|
-
if (
|
|
218
|
+
if (recoveredRemoteEntryExports) {
|
|
181
219
|
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
182
220
|
origin,
|
|
183
221
|
remoteInfo,
|
|
184
|
-
remoteEntryExports:
|
|
222
|
+
remoteEntryExports: recoveredRemoteEntryExports,
|
|
223
|
+
resourceContext,
|
|
224
|
+
error: loadError,
|
|
185
225
|
recovered: true
|
|
186
226
|
});
|
|
187
|
-
return
|
|
227
|
+
return recoveredRemoteEntryExports;
|
|
188
228
|
}
|
|
189
229
|
}
|
|
190
230
|
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
191
231
|
origin,
|
|
192
232
|
remoteInfo,
|
|
193
|
-
|
|
233
|
+
resourceContext,
|
|
234
|
+
error: loadError
|
|
194
235
|
});
|
|
195
|
-
throw
|
|
236
|
+
throw loadError;
|
|
237
|
+
});
|
|
238
|
+
remoteEntryLoadingOrigins.set(globalLoading[uniqueKey], origin);
|
|
239
|
+
}
|
|
240
|
+
const remoteEntryLoading = globalLoading[uniqueKey];
|
|
241
|
+
if (remoteEntryLoadingOrigins.get(remoteEntryLoading) !== origin) try {
|
|
242
|
+
const result = await remoteEntryLoading;
|
|
243
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
244
|
+
origin,
|
|
245
|
+
remoteInfo,
|
|
246
|
+
remoteEntryExports: result,
|
|
247
|
+
resourceContext
|
|
248
|
+
});
|
|
249
|
+
return result;
|
|
250
|
+
} catch (loadError) {
|
|
251
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
252
|
+
origin,
|
|
253
|
+
remoteInfo,
|
|
254
|
+
resourceContext,
|
|
255
|
+
error: loadError
|
|
196
256
|
});
|
|
257
|
+
throw loadError;
|
|
197
258
|
}
|
|
198
|
-
return
|
|
259
|
+
return remoteEntryLoading;
|
|
199
260
|
}
|
|
200
261
|
function getRemoteInfo(remote) {
|
|
201
262
|
return {
|
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])';\n\nexport function isEsmRemoteType(type: RemoteInfo['type']): boolean {\n return type === 'esm' || type === 'module';\n}\n\nasync function loadEsmEntry({\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 if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== 'undefined') {\n new Function('callbacks', `import(\"${entry}\")${importCallback}`)([\n resolve,\n reject,\n ]);\n } else {\n import(/* webpackIgnore: true */ /* @vite-ignore */ entry)\n .then(resolve)\n .catch(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 ESM entry from \"${entry}\". ${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 });\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 if (remoteEntryExports) {\n return remoteEntryExports;\n }\n\n if (!globalLoading[uniqueKey]) {\n const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;\n const loaderHook = origin.loaderHook;\n\n globalLoading[uniqueKey] = loadEntryHook\n .emit({\n origin,\n loaderHook,\n remoteInfo,\n remoteEntryExports,\n })\n .then((res) => {\n if (res) {\n return res;\n }\n // Use ENV_TARGET if defined, otherwise fallback to isBrowserEnvValue\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 });\n return res;\n })\n .catch(async (err) => {\n const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);\n // ScriptExecutionError means the script downloaded fine but its IIFE\n // threw at runtime — retrying would reproduce the same error, so exclude it.\n const isScriptExecutionError =\n err instanceof Error && err.message.includes('ScriptExecutionError');\n const isScriptLoadError =\n err instanceof Error &&\n err.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 RemoteEntryExports =\n await origin.loaderHook.lifecycle.loadEntryError.emit({\n getRemoteEntry: wrappedGetRemoteEntry,\n origin,\n remoteInfo: remoteInfo,\n remoteEntryExports,\n globalLoading,\n uniqueKey,\n });\n\n if (RemoteEntryExports) {\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n remoteEntryExports: RemoteEntryExports,\n recovered: true,\n });\n return RemoteEntryExports;\n }\n }\n await origin.loaderHook.lifecycle.afterLoadEntry.emit({\n origin,\n remoteInfo,\n error: err,\n });\n throw err;\n });\n }\n\n return globalLoading[uniqueKey];\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;AAEvB,SAAgB,gBAAgB,MAAmC;AACjE,QAAO,SAAS,SAAS,SAAS;;AAGpC,eAAe,aAAa,EAC1B,OACA,sBAI8B;AAC9B,QAAO,IAAI,SAA6B,SAAS,WAAW;AAC1D,MAAI;AACF,OAAI,CAAC,mBACH,KAAI,OAAO,kCAAkC,YAC3C,KAAI,SAAS,aAAa,WAAW,MAAM,IAAI,iBAAiB,CAAC,CAC/D,SACA,OACD,CAAC;OAEF;;;IAAoD;EACjD,KAAK,QAAQ,CACb,MAAM,OAAO;OAGlB,SAAQ,mBAAmB;WAEtB,GAAG;AAEV,SAAM,kCAAkC,MAAM,KADlC,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE,GACG;;GAE3D;;AAGJ,eAAe,kBAAkB,EAC/B,OACA,sBAI8B;AAC9B,QAAO,IAAI,SAA6B,SAAS,WAAW;AAC1D,MAAI;AACF,OAAI,CAAC,mBAEH,KAAI,OAAO,uBAAuB,YAEhC,QAAO,OAAO,MAAM,CAAC,KAAK,QAAQ,CAAC,MAAM,OAAO;OAEhD,KAAI,SACF,aACA,kBAAkB,MAAM,IAAI,iBAC7B,CAAC,CAAC,SAAS,OAAO,CAAC;OAGtB,SAAQ,mBAAmB;WAEtB,GAAG;AAEV,SAAM,uCAAuC,MAAM,KADvC,aAAa,QAAQ,EAAE,UAAU,OAAO,EAAE,GACQ;;GAEhE;;AAGJ,SAAS,wBACP,MACA,YACA,OACoB;CACpB,MAAM,EAAE,gBAAgB,iBAAiB,sBACvC,MACA,WACD;AAED,KAAI,CAAC,aACH,OAAM,aAAa,gBAAgB;EACjC,YAAY;EACZ,gBAAgB;EACh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f,IAAI,QAAQ,SAAS,YAAY,IACjC,CAAC,0BAEsB,CAAC,kBAAkB;IAC1C,MAAM,yBACJ,WACG;AACH,YAAO,eAAe;MAAE,GAAG;MAAQ,kBAAkB;MAAM,CAAC;;IAG9D,MAAM,qBACJ,MAAM,OAAO,WAAW,UAAU,eAAe,KAAK;KACpD,gBAAgB;KAChB;KACY;KACZ;KACA;KACA;KACD,CAAC;AAEJ,QAAI,oBAAoB;AACtB,WAAM,OAAO,WAAW,UAAU,eAAe,KAAK;MACpD;MACA;MACA,oBAAoB;MACpB,WAAW;MACZ,CAAC;AACF,YAAO;;;AAGX,SAAM,OAAO,WAAW,UAAU,eAAe,KAAK;IACpD;IACA;IACA,OAAO;IACR,CAAC;AACF,SAAM;IACN;;AAGN,QAAO,cAAc;;AAGvB,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"}
|
|
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}\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