@module-federation/bridge-react 2.6.0 → 2.8.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/base.cjs.js +4 -4
- package/dist/base.d.ts +8 -311
- package/dist/base.es.js +5 -5
- package/dist/{bridge-base-CIOXqUYV.mjs → bridge-base-BaKy6CY_.mjs} +25 -92
- package/dist/{bridge-base-HLp3d7aF.js → bridge-base-Ch33UJuN.js} +25 -91
- package/dist/{createHelpers-DNBacpxb.js → createHelpers-19BP0xtB.js} +2 -3
- package/dist/{createHelpers-BY5Uj9_Z.mjs → createHelpers-BSHeKyd-.mjs} +2 -3
- package/dist/data-fetch-server-middleware.cjs.js +1 -1
- package/dist/data-fetch-server-middleware.d.ts +1 -15
- package/dist/data-fetch-server-middleware.es.js +1 -1
- package/dist/data-fetch-utils.cjs.js +2 -2
- package/dist/data-fetch-utils.d.ts +1 -81
- package/dist/data-fetch-utils.es.js +4 -4
- package/dist/data-fetch.cjs.js +3 -3
- package/dist/data-fetch.d.ts +4 -140
- package/dist/data-fetch.es.js +3 -3
- package/dist/error-boundary.d.ts +17 -0
- package/dist/error-boundary.spec.d.ts +1 -0
- package/dist/index.cjs.js +4 -4
- package/dist/index.d.ts +12 -299
- package/dist/index.es.js +5 -5
- package/dist/lazy/AwaitDataFetch.d.ts +24 -0
- package/dist/lazy/constant.d.ts +26 -0
- package/dist/lazy/createLazyComponent.d.ts +28 -0
- package/dist/lazy/data-fetch/cache.d.ts +34 -0
- package/dist/lazy/data-fetch/cache.spec.d.ts +1 -0
- package/dist/lazy/data-fetch/call-data-fetch.d.ts +1 -0
- package/dist/lazy/data-fetch/data-fetch-server-middleware.d.ts +3 -0
- package/dist/lazy/data-fetch/index.d.ts +6 -0
- package/dist/lazy/data-fetch/inject-data-fetch.d.ts +4 -0
- package/dist/lazy/data-fetch/prefetch.d.ts +9 -0
- package/dist/lazy/data-fetch/runtime-plugin.d.ts +3 -0
- package/dist/lazy/index.d.ts +9 -0
- package/dist/lazy/logger.d.ts +2 -0
- package/dist/lazy/types.d.ts +60 -0
- package/dist/lazy/utils.d.ts +48 -0
- package/dist/lazy/wrapNoSSR.d.ts +9 -0
- package/dist/{lazy-load-component-plugin-BYI941I2.mjs → lazy-load-component-plugin-DEu-DfZt.mjs} +2 -2
- package/dist/{lazy-load-component-plugin-DG4e3Tib.js → lazy-load-component-plugin-FKp6nQa-.js} +2 -2
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.d.ts +2 -16
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.cjs.js +1 -1
- package/dist/lazy-utils.d.ts +1 -149
- package/dist/lazy-utils.es.js +2 -2
- package/dist/plugin.d.ts +2 -22
- package/dist/plugins/lazy-load-component-plugin.d.ts +12 -0
- package/dist/plugins/lazy-load-component-plugin.spec.d.ts +1 -0
- package/dist/{prefetch-DzO9_QQ-.mjs → prefetch-CTZuFBqh.mjs} +387 -16
- package/dist/{prefetch-CG2l-06N.js → prefetch-D66kL1aM.js} +387 -16
- package/dist/provider/context.d.ts +3 -0
- package/dist/provider/plugin.d.ts +7 -0
- package/dist/provider/versions/bridge-base.d.ts +5 -0
- package/dist/provider/versions/legacy.d.ts +26 -0
- package/dist/provider/versions/v18.d.ts +19 -0
- package/dist/provider/versions/v19.d.ts +21 -0
- package/dist/remote/RemoteAppWrapper.d.ts +7 -0
- package/dist/remote/base-component/component.d.ts +2 -0
- package/dist/remote/base-component/create.d.ts +9 -0
- package/dist/remote/base-component/index.d.ts +5 -0
- package/dist/remote/createHelpers.d.ts +17 -0
- package/dist/remote/router-component/component.d.ts +8 -0
- package/dist/remote/router-component/create.d.ts +9 -0
- package/dist/remote/router-component/index.d.ts +5 -0
- package/dist/router/default.d.ts +7 -0
- package/dist/router/v5.d.ts +4 -0
- package/dist/router/v6.d.ts +7 -0
- package/dist/router/v7.d.ts +6 -0
- package/dist/router-v5.d.ts +1 -17
- package/dist/router-v6.d.ts +1 -20
- package/dist/router-v7.d.ts +1 -19
- package/dist/router.d.ts +1 -20
- package/dist/shared/size-limited-cache.d.ts +29 -0
- package/dist/shared/size-limited-cache.spec.d.ts +1 -0
- package/dist/size-limited-cache.cjs.js +82 -0
- package/dist/size-limited-cache.d.ts +1 -0
- package/dist/size-limited-cache.es.js +82 -0
- package/dist/types.d.ts +137 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils-5dGErM3C.js +588 -0
- package/dist/utils-BBP3hEeV.mjs +589 -0
- package/dist/v18.cjs.js +1 -1
- package/dist/v18.d.ts +3 -114
- package/dist/v18.es.js +1 -1
- package/dist/v19.cjs.js +1 -1
- package/dist/v19.d.ts +3 -115
- package/dist/v19.es.js +1 -1
- package/package.json +20 -13
- package/dist/utils-CFTy4LVE.js +0 -2029
- package/dist/utils-DGS4pYp8.mjs +0 -2030
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as warn, y as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, e as getDataFetchMap, i as initDataFetchMap, o as getDataFetchItem, M as MF_DATA_FETCH_STATUS, q as MF_DATA_FETCH_TYPE, G as DOWNGRADE_KEY, H as callAllDowngrade, I as callDowngrade, J as getDowngradeTag, K as composeKeyWithSeparator, m as getDataFetchInfo, n as getDataFetchMapKey } from "./utils-
|
|
1
|
+
import { B as warn, y as DATA_FETCH_FUNCTION, F as FS_HREF, l as logger, e as getDataFetchMap, i as initDataFetchMap, o as getDataFetchItem, M as MF_DATA_FETCH_STATUS, q as MF_DATA_FETCH_TYPE, G as DOWNGRADE_KEY, H as callAllDowngrade, I as callDowngrade, J as getDowngradeTag, K as composeKeyWithSeparator, N as safeToString, m as getDataFetchInfo, n as getDataFetchMapKey } from "./utils-BBP3hEeV.mjs";
|
|
2
2
|
import { i as isBrowserEnvValue } from "./logger-DwWkXsWl.mjs";
|
|
3
3
|
async function safeWrapper(callback, disableWarn) {
|
|
4
4
|
try {
|
|
@@ -215,16 +215,12 @@ function importNodeModule(name) {
|
|
|
215
215
|
sdkImportCache.set(name, promise);
|
|
216
216
|
return promise;
|
|
217
217
|
}
|
|
218
|
-
const loadNodeFetch = async () => {
|
|
219
|
-
const fetchModule = await importNodeModule("node-fetch");
|
|
220
|
-
return fetchModule.default || fetchModule;
|
|
221
|
-
};
|
|
222
218
|
const lazyLoaderHookFetch = async (input, init, loaderHook) => {
|
|
223
219
|
const hook = (url, init2) => {
|
|
224
220
|
return loaderHook.lifecycle.fetch.emit(url, init2);
|
|
225
221
|
};
|
|
226
222
|
const res = await hook(input, init || {});
|
|
227
|
-
if (!res || !(res instanceof Response)) return
|
|
223
|
+
if (!res || !(res instanceof Response)) return fetch(input, init || {});
|
|
228
224
|
return res;
|
|
229
225
|
};
|
|
230
226
|
const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url, cb, attrs, loaderHook) => {
|
|
@@ -242,7 +238,7 @@ const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "we
|
|
|
242
238
|
}
|
|
243
239
|
const getFetch = async () => {
|
|
244
240
|
if (loaderHook == null ? void 0 : loaderHook.fetch) return (input, init) => lazyLoaderHookFetch(input, init, loaderHook);
|
|
245
|
-
return
|
|
241
|
+
return fetch;
|
|
246
242
|
};
|
|
247
243
|
const handleScriptFetch = async (f, urlObj2) => {
|
|
248
244
|
var _a;
|
|
@@ -306,20 +302,82 @@ const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web"
|
|
|
306
302
|
throw new Error("loadScriptNode is disabled in non-Node.js environment");
|
|
307
303
|
};
|
|
308
304
|
const esmModuleCache = /* @__PURE__ */ new Map();
|
|
305
|
+
const isFetchableRemoteModuleUrl = (url) => url.startsWith("http:") || url.startsWith("https:");
|
|
306
|
+
const isBareModuleSpecifier = (specifier) => !specifier.startsWith("./") && !specifier.startsWith("../") && !specifier.startsWith("/") && !specifier.includes(":");
|
|
307
|
+
function encodeRemoteModulePath(url) {
|
|
308
|
+
const remoteUrl = new URL(url);
|
|
309
|
+
const encodedProtocol = encodeURIComponent(remoteUrl.protocol.slice(0, -1));
|
|
310
|
+
const encodedHost = encodeURIComponent(remoteUrl.host);
|
|
311
|
+
const encodedPathname = remoteUrl.pathname.split("/").map((segment) => encodeURIComponent(segment)).join("/");
|
|
312
|
+
const encodedSearchHash = encodeURIComponent(`${remoteUrl.search}${remoteUrl.hash}`);
|
|
313
|
+
return `/${encodedProtocol}/${encodedHost}${encodedPathname}${encodedSearchHash ? `/${encodedSearchHash}` : ""}`;
|
|
314
|
+
}
|
|
315
|
+
function createImportMetaUrl(url, baseFileUrl) {
|
|
316
|
+
const baseUrl = baseFileUrl.endsWith("/") ? baseFileUrl : `${baseFileUrl}/`;
|
|
317
|
+
return new URL(`__module_federation_remote__${encodeRemoteModulePath(url)}`, baseUrl).href;
|
|
318
|
+
}
|
|
319
|
+
async function isNodeBuiltinSpecifier(specifier) {
|
|
320
|
+
if (specifier.startsWith("node:")) return true;
|
|
321
|
+
if (!isBareModuleSpecifier(specifier)) return false;
|
|
322
|
+
return (await importNodeModule("node:module")).builtinModules.includes(specifier);
|
|
323
|
+
}
|
|
324
|
+
function getSyntheticModuleExports(moduleExports) {
|
|
325
|
+
const namespaceObject = moduleExports && (typeof moduleExports === "object" || typeof moduleExports === "function") ? moduleExports : { default: moduleExports };
|
|
326
|
+
const effectiveExports = { ...namespaceObject };
|
|
327
|
+
if (!Object.prototype.hasOwnProperty.call(effectiveExports, "default")) effectiveExports.default = namespaceObject;
|
|
328
|
+
return effectiveExports;
|
|
329
|
+
}
|
|
330
|
+
async function createSyntheticModuleFromExports(identifier, moduleExports, vm) {
|
|
331
|
+
if (typeof vm.SyntheticModule !== "function") throw new Error("vm.SyntheticModule is required to load Node.js built-in modules in ESM remote entries.");
|
|
332
|
+
const effectiveExports = getSyntheticModuleExports(moduleExports);
|
|
333
|
+
const exportNames = Object.keys(effectiveExports);
|
|
334
|
+
const syntheticModule = new vm.SyntheticModule(exportNames, function setSyntheticModuleExports() {
|
|
335
|
+
for (const name of exportNames) this.setExport(name, effectiveExports[name]);
|
|
336
|
+
}, { identifier });
|
|
337
|
+
esmModuleCache.set(identifier, syntheticModule);
|
|
338
|
+
await syntheticModule.link(async () => {
|
|
339
|
+
throw new Error(`Node.js built-in module "${identifier}" should not request child modules.`);
|
|
340
|
+
});
|
|
341
|
+
await syntheticModule.evaluate();
|
|
342
|
+
return syntheticModule;
|
|
343
|
+
}
|
|
344
|
+
async function loadNodeBuiltinModule(specifier, vm) {
|
|
345
|
+
const cacheKey = `node-builtin:${specifier}`;
|
|
346
|
+
if (esmModuleCache.has(cacheKey)) return esmModuleCache.get(cacheKey);
|
|
347
|
+
return createSyntheticModuleFromExports(cacheKey, await importNodeModule(specifier), vm);
|
|
348
|
+
}
|
|
349
|
+
async function loadResolvedModule(specifier, parentUrl, options) {
|
|
350
|
+
if (await isNodeBuiltinSpecifier(specifier)) return loadNodeBuiltinModule(specifier, options.vm);
|
|
351
|
+
if (isBareModuleSpecifier(specifier)) throw new Error(`Unsupported ESM module specifier "${specifier}". Only relative or absolute http(s) remote modules and Node.js built-in modules are supported.`);
|
|
352
|
+
const resolvedUrl = new URL(specifier, parentUrl).href;
|
|
353
|
+
if (!isFetchableRemoteModuleUrl(resolvedUrl)) throw new Error(`Unsupported ESM module specifier "${specifier}" resolved to "${resolvedUrl}". Only http(s) remote modules and Node.js built-in modules are supported.`);
|
|
354
|
+
return loadModule(resolvedUrl, options);
|
|
355
|
+
}
|
|
356
|
+
async function evaluateDynamicModule(module) {
|
|
357
|
+
if (module.status === "linked") await module.evaluate();
|
|
358
|
+
if (module.status === "errored") throw module.error;
|
|
359
|
+
return module;
|
|
360
|
+
}
|
|
309
361
|
async function loadModule(url, options) {
|
|
310
362
|
if (esmModuleCache.has(url)) return esmModuleCache.get(url);
|
|
311
363
|
const { fetch: fetch2, vm } = options;
|
|
364
|
+
if (!isFetchableRemoteModuleUrl(url)) throw new Error(`Unsupported ESM module URL "${url}". Only http(s) remote modules and Node.js built-in modules are supported.`);
|
|
312
365
|
const code = await (await fetch2(url)).text();
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
366
|
+
const cwdFileUrl = (await importNodeModule("node:url")).pathToFileURL(process.cwd()).href;
|
|
367
|
+
const sourceTextModule = new vm.SourceTextModule(code, {
|
|
368
|
+
identifier: url,
|
|
369
|
+
initializeImportMeta: (meta) => {
|
|
370
|
+
meta.url = createImportMetaUrl(url, cwdFileUrl);
|
|
371
|
+
},
|
|
372
|
+
importModuleDynamically: async (specifier) => {
|
|
373
|
+
return evaluateDynamicModule(await loadResolvedModule(specifier, url, options));
|
|
374
|
+
}
|
|
321
375
|
});
|
|
322
|
-
|
|
376
|
+
esmModuleCache.set(url, sourceTextModule);
|
|
377
|
+
await sourceTextModule.link(async (specifier) => {
|
|
378
|
+
return loadResolvedModule(specifier, url, options);
|
|
379
|
+
});
|
|
380
|
+
return sourceTextModule;
|
|
323
381
|
}
|
|
324
382
|
const dataFetchFunction = async function(options) {
|
|
325
383
|
var _a, _b;
|
|
@@ -411,6 +469,9 @@ function logAndReport(code, descMap, args, logger2, originalErrorMsg, context) {
|
|
|
411
469
|
return logger2(getShortErrorMsg(code, descMap, args, originalErrorMsg));
|
|
412
470
|
}
|
|
413
471
|
const LOG_CATEGORY = "[ Federation Runtime ]";
|
|
472
|
+
function assert(condition, msgOrCode, descMap, args, context) {
|
|
473
|
+
if (!condition) error(msgOrCode);
|
|
474
|
+
}
|
|
414
475
|
function error(msgOrCode, descMap, args, originalErrorMsg, context) {
|
|
415
476
|
if (descMap !== void 0) return logAndReport(msgOrCode, descMap, args ?? {}, (msg2) => {
|
|
416
477
|
throw new Error(`${LOG_CATEGORY}: ${msg2}`);
|
|
@@ -422,6 +483,14 @@ function error(msgOrCode, descMap, args, originalErrorMsg, context) {
|
|
|
422
483
|
}
|
|
423
484
|
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
424
485
|
}
|
|
486
|
+
const processModuleAlias = (name, subPath) => {
|
|
487
|
+
let moduleName;
|
|
488
|
+
if (name.endsWith("/")) moduleName = name.slice(0, -1);
|
|
489
|
+
else moduleName = name;
|
|
490
|
+
if (subPath.startsWith(".")) subPath = subPath.slice(1);
|
|
491
|
+
moduleName = moduleName + subPath;
|
|
492
|
+
return moduleName;
|
|
493
|
+
};
|
|
425
494
|
const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
|
|
426
495
|
const nativeGlobal = (() => {
|
|
427
496
|
try {
|
|
@@ -474,6 +543,10 @@ const getRemoteEntryExports = (name, globalName) => {
|
|
|
474
543
|
};
|
|
475
544
|
const DEFAULT_SCOPE = "default";
|
|
476
545
|
const DEFAULT_REMOTE_TYPE = "global";
|
|
546
|
+
function composeRemoteRequestId(remoteName, expose) {
|
|
547
|
+
if (!expose || expose === ".") return remoteName;
|
|
548
|
+
return `${remoteName}/${expose.replace(/^\.\//, "")}`;
|
|
549
|
+
}
|
|
477
550
|
function matchRemoteWithNameAndExpose(remotes, id) {
|
|
478
551
|
for (const remote of remotes) {
|
|
479
552
|
const isNameMatched = id.startsWith(remote.name);
|
|
@@ -751,6 +824,42 @@ function getRemoteInfo(remote) {
|
|
|
751
824
|
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
752
825
|
};
|
|
753
826
|
}
|
|
827
|
+
function remoteToEntry(r) {
|
|
828
|
+
return {
|
|
829
|
+
name: r.name,
|
|
830
|
+
alias: r.alias,
|
|
831
|
+
entry: "entry" in r ? r.entry : void 0,
|
|
832
|
+
version: "version" in r ? r.version : void 0,
|
|
833
|
+
type: r.type,
|
|
834
|
+
entryGlobalName: r.entryGlobalName,
|
|
835
|
+
shareScope: r.shareScope
|
|
836
|
+
};
|
|
837
|
+
}
|
|
838
|
+
function optionsToMFContext(options) {
|
|
839
|
+
var _a, _b, _c, _d, _e, _f;
|
|
840
|
+
const shared = {};
|
|
841
|
+
for (const [pkgName, versions] of Object.entries(options.shared)) {
|
|
842
|
+
const first = versions[0];
|
|
843
|
+
if (first) shared[pkgName] = {
|
|
844
|
+
version: first.version,
|
|
845
|
+
singleton: (_a = first.shareConfig) == null ? void 0 : _a.singleton,
|
|
846
|
+
requiredVersion: ((_b = first.shareConfig) == null ? void 0 : _b.requiredVersion) === false ? false : (_c = first.shareConfig) == null ? void 0 : _c.requiredVersion,
|
|
847
|
+
eager: first.eager,
|
|
848
|
+
strictVersion: (_d = first.shareConfig) == null ? void 0 : _d.strictVersion
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
return {
|
|
852
|
+
project: {
|
|
853
|
+
name: options.name,
|
|
854
|
+
mfRole: ((_e = options.remotes) == null ? void 0 : _e.length) > 0 ? "host" : "unknown"
|
|
855
|
+
},
|
|
856
|
+
mfConfig: {
|
|
857
|
+
name: options.name,
|
|
858
|
+
remotes: ((_f = options.remotes) == null ? void 0 : _f.map(remoteToEntry)) ?? [],
|
|
859
|
+
shared
|
|
860
|
+
}
|
|
861
|
+
};
|
|
862
|
+
}
|
|
754
863
|
function isTimeoutError(error2) {
|
|
755
864
|
if (!(error2 instanceof Error)) return false;
|
|
756
865
|
return error2.message.includes("timed out") || error2.name.includes("Timeout");
|
|
@@ -928,8 +1037,270 @@ var helpers_default = {
|
|
|
928
1037
|
getRemoteInfo
|
|
929
1038
|
}
|
|
930
1039
|
};
|
|
1040
|
+
function getAvailableExposeNames(remoteSnapshot) {
|
|
1041
|
+
if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;
|
|
1042
|
+
const exposes = remoteSnapshot.modules.map((module) => module.moduleName).filter(Boolean);
|
|
1043
|
+
return exposes.length ? exposes.join(",") : void 0;
|
|
1044
|
+
}
|
|
1045
|
+
function createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {
|
|
1046
|
+
const localShareScopeMap = hostShareScopeMap;
|
|
1047
|
+
const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];
|
|
1048
|
+
if (!shareScopeKeys.length) shareScopeKeys.push("default");
|
|
1049
|
+
shareScopeKeys.forEach((shareScopeKey) => {
|
|
1050
|
+
if (!localShareScopeMap[shareScopeKey]) localShareScopeMap[shareScopeKey] = {};
|
|
1051
|
+
});
|
|
1052
|
+
const remoteEntryInitOptions = {
|
|
1053
|
+
version: remoteInfo.version || "",
|
|
1054
|
+
shareScopeKeys: Array.isArray(remoteInfo.shareScope) ? shareScopeKeys : remoteInfo.shareScope || "default"
|
|
1055
|
+
};
|
|
1056
|
+
Object.defineProperty(remoteEntryInitOptions, "shareScopeMap", {
|
|
1057
|
+
value: localShareScopeMap,
|
|
1058
|
+
enumerable: false
|
|
1059
|
+
});
|
|
1060
|
+
return {
|
|
1061
|
+
remoteEntryInitOptions,
|
|
1062
|
+
shareScope: localShareScopeMap[shareScopeKeys[0]],
|
|
1063
|
+
initScope: rawInitScope ?? []
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
var Module$1 = class {
|
|
1067
|
+
constructor({ remoteInfo, host }) {
|
|
1068
|
+
this.inited = false;
|
|
1069
|
+
this.initing = false;
|
|
1070
|
+
this.lib = void 0;
|
|
1071
|
+
this.remoteInfo = remoteInfo;
|
|
1072
|
+
this.host = host;
|
|
1073
|
+
}
|
|
1074
|
+
async getEntry(expose) {
|
|
1075
|
+
if (this.remoteEntryExports) return this.remoteEntryExports;
|
|
1076
|
+
const remoteEntryExports = await getRemoteEntry({
|
|
1077
|
+
origin: this.host,
|
|
1078
|
+
remoteInfo: this.remoteInfo,
|
|
1079
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
1080
|
+
resourceContext: {
|
|
1081
|
+
initiator: "loadRemote",
|
|
1082
|
+
id: composeRemoteRequestId(this.remoteInfo.name, expose),
|
|
1083
|
+
resourceType: "remoteEntry"
|
|
1084
|
+
}
|
|
1085
|
+
});
|
|
1086
|
+
assert(remoteEntryExports, `remoteEntryExports is undefined
|
|
1087
|
+
${safeToString(this.remoteInfo)}`);
|
|
1088
|
+
this.remoteEntryExports = remoteEntryExports;
|
|
1089
|
+
return this.remoteEntryExports;
|
|
1090
|
+
}
|
|
1091
|
+
async init(id, remoteSnapshot, rawInitScope, expose) {
|
|
1092
|
+
const remoteEntryExports = await this.getEntry(expose);
|
|
1093
|
+
if (this.inited) {
|
|
1094
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1095
|
+
id,
|
|
1096
|
+
remoteInfo: this.remoteInfo,
|
|
1097
|
+
remoteSnapshot,
|
|
1098
|
+
remoteEntryExports,
|
|
1099
|
+
cached: true,
|
|
1100
|
+
origin: this.host
|
|
1101
|
+
});
|
|
1102
|
+
return remoteEntryExports;
|
|
1103
|
+
}
|
|
1104
|
+
if (this.initPromise) {
|
|
1105
|
+
try {
|
|
1106
|
+
await this.initPromise;
|
|
1107
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1108
|
+
id,
|
|
1109
|
+
remoteInfo: this.remoteInfo,
|
|
1110
|
+
remoteSnapshot,
|
|
1111
|
+
remoteEntryExports,
|
|
1112
|
+
cached: true,
|
|
1113
|
+
origin: this.host
|
|
1114
|
+
});
|
|
1115
|
+
} catch (initError) {
|
|
1116
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1117
|
+
id,
|
|
1118
|
+
remoteInfo: this.remoteInfo,
|
|
1119
|
+
remoteSnapshot,
|
|
1120
|
+
remoteEntryExports,
|
|
1121
|
+
error: initError,
|
|
1122
|
+
cached: true,
|
|
1123
|
+
origin: this.host
|
|
1124
|
+
});
|
|
1125
|
+
throw initError;
|
|
1126
|
+
}
|
|
1127
|
+
return remoteEntryExports;
|
|
1128
|
+
}
|
|
1129
|
+
this.initing = true;
|
|
1130
|
+
this.initPromise = (async () => {
|
|
1131
|
+
await this.host.loaderHook.lifecycle.beforeInitRemote.emit({
|
|
1132
|
+
id,
|
|
1133
|
+
remoteInfo: this.remoteInfo,
|
|
1134
|
+
remoteSnapshot,
|
|
1135
|
+
origin: this.host
|
|
1136
|
+
});
|
|
1137
|
+
const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);
|
|
1138
|
+
const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1139
|
+
shareScope,
|
|
1140
|
+
remoteEntryInitOptions,
|
|
1141
|
+
initScope,
|
|
1142
|
+
remoteInfo: this.remoteInfo,
|
|
1143
|
+
origin: this.host
|
|
1144
|
+
});
|
|
1145
|
+
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === "undefined") error(RUNTIME_002, runtimeDescMap, {
|
|
1146
|
+
hostName: this.host.name,
|
|
1147
|
+
remoteName: this.remoteInfo.name,
|
|
1148
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1149
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1150
|
+
}, void 0, optionsToMFContext(this.host.options));
|
|
1151
|
+
try {
|
|
1152
|
+
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
1153
|
+
} catch (initError) {
|
|
1154
|
+
error(RUNTIME_015, runtimeDescMap, {
|
|
1155
|
+
hostName: this.host.name,
|
|
1156
|
+
remoteName: this.remoteInfo.name,
|
|
1157
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1158
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName,
|
|
1159
|
+
shareScope: this.remoteInfo.shareScope
|
|
1160
|
+
}, `${initError}`, optionsToMFContext(this.host.options));
|
|
1161
|
+
}
|
|
1162
|
+
await this.host.hooks.lifecycle.initContainer.emit({
|
|
1163
|
+
...initContainerOptions,
|
|
1164
|
+
id,
|
|
1165
|
+
remoteSnapshot,
|
|
1166
|
+
remoteEntryExports
|
|
1167
|
+
});
|
|
1168
|
+
this.inited = true;
|
|
1169
|
+
})();
|
|
1170
|
+
try {
|
|
1171
|
+
await this.initPromise;
|
|
1172
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1173
|
+
id,
|
|
1174
|
+
remoteInfo: this.remoteInfo,
|
|
1175
|
+
remoteSnapshot,
|
|
1176
|
+
remoteEntryExports,
|
|
1177
|
+
origin: this.host
|
|
1178
|
+
});
|
|
1179
|
+
} catch (initError) {
|
|
1180
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1181
|
+
id,
|
|
1182
|
+
remoteInfo: this.remoteInfo,
|
|
1183
|
+
remoteSnapshot,
|
|
1184
|
+
remoteEntryExports,
|
|
1185
|
+
error: initError,
|
|
1186
|
+
origin: this.host
|
|
1187
|
+
});
|
|
1188
|
+
throw initError;
|
|
1189
|
+
} finally {
|
|
1190
|
+
this.initing = false;
|
|
1191
|
+
this.initPromise = void 0;
|
|
1192
|
+
}
|
|
1193
|
+
return remoteEntryExports;
|
|
1194
|
+
}
|
|
1195
|
+
async get(id, expose, options, remoteSnapshot) {
|
|
1196
|
+
const { loadFactory = true } = options || { loadFactory: true };
|
|
1197
|
+
const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);
|
|
1198
|
+
this.lib = remoteEntryExports;
|
|
1199
|
+
await this.host.loaderHook.lifecycle.beforeGetExpose.emit({
|
|
1200
|
+
id,
|
|
1201
|
+
expose,
|
|
1202
|
+
moduleInfo: this.remoteInfo,
|
|
1203
|
+
remoteEntryExports,
|
|
1204
|
+
origin: this.host
|
|
1205
|
+
});
|
|
1206
|
+
let moduleFactory;
|
|
1207
|
+
try {
|
|
1208
|
+
const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1209
|
+
remoteEntryExports,
|
|
1210
|
+
expose,
|
|
1211
|
+
moduleInfo: this.remoteInfo
|
|
1212
|
+
});
|
|
1213
|
+
moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;
|
|
1214
|
+
if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);
|
|
1215
|
+
if (!moduleFactory) error(RUNTIME_014, runtimeDescMap, {
|
|
1216
|
+
hostName: this.host.name,
|
|
1217
|
+
remoteName: this.remoteInfo.name,
|
|
1218
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1219
|
+
expose,
|
|
1220
|
+
requestId: id,
|
|
1221
|
+
availableExposes: getAvailableExposeNames(remoteSnapshot)
|
|
1222
|
+
}, void 0, optionsToMFContext(this.host.options));
|
|
1223
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
1224
|
+
id,
|
|
1225
|
+
expose,
|
|
1226
|
+
moduleInfo: this.remoteInfo,
|
|
1227
|
+
remoteEntryExports,
|
|
1228
|
+
moduleFactory,
|
|
1229
|
+
origin: this.host
|
|
1230
|
+
});
|
|
1231
|
+
} catch (getExposeError) {
|
|
1232
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
1233
|
+
id,
|
|
1234
|
+
expose,
|
|
1235
|
+
moduleInfo: this.remoteInfo,
|
|
1236
|
+
remoteEntryExports,
|
|
1237
|
+
error: getExposeError,
|
|
1238
|
+
origin: this.host
|
|
1239
|
+
});
|
|
1240
|
+
throw getExposeError;
|
|
1241
|
+
}
|
|
1242
|
+
const symbolName = processModuleAlias(this.remoteInfo.name, expose);
|
|
1243
|
+
const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
|
|
1244
|
+
if (!loadFactory) return wrapModuleFactory;
|
|
1245
|
+
await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({
|
|
1246
|
+
id,
|
|
1247
|
+
expose,
|
|
1248
|
+
moduleInfo: this.remoteInfo,
|
|
1249
|
+
loadFactory,
|
|
1250
|
+
origin: this.host
|
|
1251
|
+
});
|
|
1252
|
+
try {
|
|
1253
|
+
const exposeContent = await wrapModuleFactory();
|
|
1254
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
1255
|
+
id,
|
|
1256
|
+
expose,
|
|
1257
|
+
moduleInfo: this.remoteInfo,
|
|
1258
|
+
loadFactory,
|
|
1259
|
+
exposeModule: exposeContent,
|
|
1260
|
+
origin: this.host
|
|
1261
|
+
});
|
|
1262
|
+
return exposeContent;
|
|
1263
|
+
} catch (executeFactoryError) {
|
|
1264
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
1265
|
+
id,
|
|
1266
|
+
expose,
|
|
1267
|
+
moduleInfo: this.remoteInfo,
|
|
1268
|
+
loadFactory,
|
|
1269
|
+
error: executeFactoryError,
|
|
1270
|
+
origin: this.host
|
|
1271
|
+
});
|
|
1272
|
+
throw executeFactoryError;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
wraperFactory(moduleFactory, id) {
|
|
1276
|
+
function defineModuleId(res, id2) {
|
|
1277
|
+
if (res && typeof res === "object" && Object.isExtensible(res) && !Object.getOwnPropertyDescriptor(res, Symbol.for("mf_module_id"))) Object.defineProperty(res, Symbol.for("mf_module_id"), {
|
|
1278
|
+
value: id2,
|
|
1279
|
+
enumerable: false
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
return () => {
|
|
1283
|
+
const res = moduleFactory();
|
|
1284
|
+
if (res instanceof Promise) return res.then((asyncRes) => {
|
|
1285
|
+
defineModuleId(asyncRes, id);
|
|
1286
|
+
return asyncRes;
|
|
1287
|
+
});
|
|
1288
|
+
defineModuleId(res, id);
|
|
1289
|
+
return res;
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
};
|
|
1293
|
+
const REMOTE_DISABLED_MESSAGE = "Remote loading is disabled by experiments.optimization.disableRemote.";
|
|
1294
|
+
var UnavailableRemoteModule = class {
|
|
1295
|
+
constructor() {
|
|
1296
|
+
throw new Error(REMOTE_DISABLED_MESSAGE);
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
931
1299
|
typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
|
|
1300
|
+
typeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" ? !FEDERATION_OPTIMIZE_NO_REMOTE : true;
|
|
1301
|
+
typeof FEDERATION_OPTIMIZE_NO_SHARED === "boolean" ? !FEDERATION_OPTIMIZE_NO_SHARED : true;
|
|
932
1302
|
const helpers = helpers_default;
|
|
1303
|
+
typeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" && FEDERATION_OPTIMIZE_NO_REMOTE ? UnavailableRemoteModule : Module$1;
|
|
933
1304
|
const utils = helpers.utils;
|
|
934
1305
|
const runtimeHelpers = {
|
|
935
1306
|
utils
|