@module-federation/bridge-react 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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-BjMVNoep.js → lazy-load-component-plugin-DBTxuAYf.js} +2 -2
- package/dist/{lazy-load-component-plugin-aj97Vt-4.mjs → lazy-load-component-plugin-DlagtX0O.mjs} +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-BwRDb4SJ.mjs → prefetch-BzCq3MT3.mjs} +359 -51
- package/dist/{prefetch-DLhPTofn.js → prefetch-QJLnti7A.js} +359 -51
- 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 +16 -11
- 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 {
|
|
@@ -469,6 +469,9 @@ function logAndReport(code, descMap, args, logger2, originalErrorMsg, context) {
|
|
|
469
469
|
return logger2(getShortErrorMsg(code, descMap, args, originalErrorMsg));
|
|
470
470
|
}
|
|
471
471
|
const LOG_CATEGORY = "[ Federation Runtime ]";
|
|
472
|
+
function assert(condition, msgOrCode, descMap, args, context) {
|
|
473
|
+
if (!condition) error(msgOrCode);
|
|
474
|
+
}
|
|
472
475
|
function error(msgOrCode, descMap, args, originalErrorMsg, context) {
|
|
473
476
|
if (descMap !== void 0) return logAndReport(msgOrCode, descMap, args ?? {}, (msg2) => {
|
|
474
477
|
throw new Error(`${LOG_CATEGORY}: ${msg2}`);
|
|
@@ -480,6 +483,14 @@ function error(msgOrCode, descMap, args, originalErrorMsg, context) {
|
|
|
480
483
|
}
|
|
481
484
|
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
482
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
|
+
};
|
|
483
494
|
const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
|
|
484
495
|
const nativeGlobal = (() => {
|
|
485
496
|
try {
|
|
@@ -532,6 +543,10 @@ const getRemoteEntryExports = (name, globalName) => {
|
|
|
532
543
|
};
|
|
533
544
|
const DEFAULT_SCOPE = "default";
|
|
534
545
|
const DEFAULT_REMOTE_TYPE = "global";
|
|
546
|
+
function composeRemoteRequestId(remoteName, expose) {
|
|
547
|
+
if (!expose || expose === ".") return remoteName;
|
|
548
|
+
return `${remoteName}/${expose.replace(/^\.\//, "")}`;
|
|
549
|
+
}
|
|
535
550
|
function matchRemoteWithNameAndExpose(remotes, id) {
|
|
536
551
|
for (const remote of remotes) {
|
|
537
552
|
const isNameMatched = id.startsWith(remote.name);
|
|
@@ -606,6 +621,9 @@ const runtimeDescMap = {
|
|
|
606
621
|
...runtimeDescMap
|
|
607
622
|
});
|
|
608
623
|
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
624
|
+
function isEsmRemoteType(type) {
|
|
625
|
+
return type === "esm" || type === "module";
|
|
626
|
+
}
|
|
609
627
|
async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
610
628
|
return new Promise((resolve, reject) => {
|
|
611
629
|
try {
|
|
@@ -673,29 +691,23 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
673
691
|
}
|
|
674
692
|
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
|
|
675
693
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
remoteInfo,
|
|
694
|
-
loaderHook,
|
|
695
|
-
getEntryUrl,
|
|
696
|
-
resourceContext
|
|
697
|
-
});
|
|
698
|
-
}
|
|
694
|
+
if (isEsmRemoteType(type)) return loadEsmEntry({
|
|
695
|
+
entry,
|
|
696
|
+
remoteEntryExports
|
|
697
|
+
});
|
|
698
|
+
if (type === "system") return loadSystemJsEntry({
|
|
699
|
+
entry,
|
|
700
|
+
remoteEntryExports
|
|
701
|
+
});
|
|
702
|
+
return loadEntryScript({
|
|
703
|
+
entry,
|
|
704
|
+
globalName,
|
|
705
|
+
name,
|
|
706
|
+
remoteInfo,
|
|
707
|
+
loaderHook,
|
|
708
|
+
getEntryUrl,
|
|
709
|
+
resourceContext
|
|
710
|
+
});
|
|
699
711
|
}
|
|
700
712
|
async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
|
|
701
713
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
@@ -809,6 +821,42 @@ function getRemoteInfo(remote) {
|
|
|
809
821
|
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
810
822
|
};
|
|
811
823
|
}
|
|
824
|
+
function remoteToEntry(r) {
|
|
825
|
+
return {
|
|
826
|
+
name: r.name,
|
|
827
|
+
alias: r.alias,
|
|
828
|
+
entry: "entry" in r ? r.entry : void 0,
|
|
829
|
+
version: "version" in r ? r.version : void 0,
|
|
830
|
+
type: r.type,
|
|
831
|
+
entryGlobalName: r.entryGlobalName,
|
|
832
|
+
shareScope: r.shareScope
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function optionsToMFContext(options) {
|
|
836
|
+
var _a, _b, _c, _d, _e, _f;
|
|
837
|
+
const shared = {};
|
|
838
|
+
for (const [pkgName, versions] of Object.entries(options.shared)) {
|
|
839
|
+
const first = versions[0];
|
|
840
|
+
if (first) shared[pkgName] = {
|
|
841
|
+
version: first.version,
|
|
842
|
+
singleton: (_a = first.shareConfig) == null ? void 0 : _a.singleton,
|
|
843
|
+
requiredVersion: ((_b = first.shareConfig) == null ? void 0 : _b.requiredVersion) === false ? false : (_c = first.shareConfig) == null ? void 0 : _c.requiredVersion,
|
|
844
|
+
eager: first.eager,
|
|
845
|
+
strictVersion: (_d = first.shareConfig) == null ? void 0 : _d.strictVersion
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
return {
|
|
849
|
+
project: {
|
|
850
|
+
name: options.name,
|
|
851
|
+
mfRole: ((_e = options.remotes) == null ? void 0 : _e.length) > 0 ? "host" : "unknown"
|
|
852
|
+
},
|
|
853
|
+
mfConfig: {
|
|
854
|
+
name: options.name,
|
|
855
|
+
remotes: ((_f = options.remotes) == null ? void 0 : _f.map(remoteToEntry)) ?? [],
|
|
856
|
+
shared
|
|
857
|
+
}
|
|
858
|
+
};
|
|
859
|
+
}
|
|
812
860
|
function isTimeoutError(error2) {
|
|
813
861
|
if (!(error2 instanceof Error)) return false;
|
|
814
862
|
return error2.message.includes("timed out") || error2.name.includes("Timeout");
|
|
@@ -918,7 +966,7 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
918
966
|
results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
|
|
919
967
|
});
|
|
920
968
|
if (useLinkPreload) {
|
|
921
|
-
const
|
|
969
|
+
const defaultAttrs2 = {
|
|
922
970
|
rel: "preload",
|
|
923
971
|
as: "style"
|
|
924
972
|
};
|
|
@@ -927,12 +975,12 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
927
975
|
host,
|
|
928
976
|
remoteInfo,
|
|
929
977
|
url: cssUrl,
|
|
930
|
-
attrs:
|
|
978
|
+
attrs: defaultAttrs2,
|
|
931
979
|
context: createResourceContext(baseContext, "css")
|
|
932
980
|
}));
|
|
933
981
|
});
|
|
934
982
|
} else {
|
|
935
|
-
const
|
|
983
|
+
const defaultAttrs2 = {
|
|
936
984
|
rel: "stylesheet",
|
|
937
985
|
type: "text/css"
|
|
938
986
|
};
|
|
@@ -941,41 +989,39 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
941
989
|
host,
|
|
942
990
|
remoteInfo,
|
|
943
991
|
url: cssUrl,
|
|
944
|
-
attrs:
|
|
992
|
+
attrs: defaultAttrs2,
|
|
945
993
|
needDeleteLink: false,
|
|
946
994
|
context: createResourceContext(baseContext, "css")
|
|
947
995
|
}));
|
|
948
996
|
});
|
|
949
997
|
}
|
|
998
|
+
let preloadJsAsset = waitForScriptPreload;
|
|
999
|
+
let defaultAttrs = {
|
|
1000
|
+
fetchpriority: "high",
|
|
1001
|
+
type: "text/javascript"
|
|
1002
|
+
};
|
|
950
1003
|
if (useLinkPreload) {
|
|
951
|
-
|
|
1004
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1005
|
+
defaultAttrs = {
|
|
952
1006
|
rel: "preload",
|
|
953
1007
|
as: "script"
|
|
954
1008
|
};
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
attrs: defaultAttrs,
|
|
961
|
-
context: createResourceContext(baseContext, "js")
|
|
962
|
-
}));
|
|
963
|
-
});
|
|
964
|
-
} else {
|
|
965
|
-
const defaultAttrs = {
|
|
966
|
-
fetchpriority: "high",
|
|
967
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
|
|
1009
|
+
} else if (isEsmRemoteType(remoteInfo.type)) {
|
|
1010
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1011
|
+
defaultAttrs = {
|
|
1012
|
+
rel: "modulepreload",
|
|
1013
|
+
fetchpriority: "high"
|
|
968
1014
|
};
|
|
969
|
-
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
970
|
-
results.push(waitForScriptPreload({
|
|
971
|
-
host,
|
|
972
|
-
remoteInfo,
|
|
973
|
-
url: jsUrl,
|
|
974
|
-
attrs: defaultAttrs,
|
|
975
|
-
context: createResourceContext(baseContext, "js")
|
|
976
|
-
}));
|
|
977
|
-
});
|
|
978
1015
|
}
|
|
1016
|
+
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
1017
|
+
results.push(preloadJsAsset({
|
|
1018
|
+
host,
|
|
1019
|
+
remoteInfo,
|
|
1020
|
+
url: jsUrl,
|
|
1021
|
+
attrs: defaultAttrs,
|
|
1022
|
+
context: createResourceContext(baseContext, "js")
|
|
1023
|
+
}));
|
|
1024
|
+
});
|
|
979
1025
|
}
|
|
980
1026
|
return Promise.all(results);
|
|
981
1027
|
}
|
|
@@ -986,8 +1032,270 @@ var helpers_default = {
|
|
|
986
1032
|
getRemoteInfo
|
|
987
1033
|
}
|
|
988
1034
|
};
|
|
1035
|
+
function getAvailableExposeNames(remoteSnapshot) {
|
|
1036
|
+
if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;
|
|
1037
|
+
const exposes = remoteSnapshot.modules.map((module) => module.moduleName).filter(Boolean);
|
|
1038
|
+
return exposes.length ? exposes.join(",") : void 0;
|
|
1039
|
+
}
|
|
1040
|
+
function createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {
|
|
1041
|
+
const localShareScopeMap = hostShareScopeMap;
|
|
1042
|
+
const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];
|
|
1043
|
+
if (!shareScopeKeys.length) shareScopeKeys.push("default");
|
|
1044
|
+
shareScopeKeys.forEach((shareScopeKey) => {
|
|
1045
|
+
if (!localShareScopeMap[shareScopeKey]) localShareScopeMap[shareScopeKey] = {};
|
|
1046
|
+
});
|
|
1047
|
+
const remoteEntryInitOptions = {
|
|
1048
|
+
version: remoteInfo.version || "",
|
|
1049
|
+
shareScopeKeys: Array.isArray(remoteInfo.shareScope) ? shareScopeKeys : remoteInfo.shareScope || "default"
|
|
1050
|
+
};
|
|
1051
|
+
Object.defineProperty(remoteEntryInitOptions, "shareScopeMap", {
|
|
1052
|
+
value: localShareScopeMap,
|
|
1053
|
+
enumerable: false
|
|
1054
|
+
});
|
|
1055
|
+
return {
|
|
1056
|
+
remoteEntryInitOptions,
|
|
1057
|
+
shareScope: localShareScopeMap[shareScopeKeys[0]],
|
|
1058
|
+
initScope: rawInitScope ?? []
|
|
1059
|
+
};
|
|
1060
|
+
}
|
|
1061
|
+
var Module$1 = class {
|
|
1062
|
+
constructor({ remoteInfo, host }) {
|
|
1063
|
+
this.inited = false;
|
|
1064
|
+
this.initing = false;
|
|
1065
|
+
this.lib = void 0;
|
|
1066
|
+
this.remoteInfo = remoteInfo;
|
|
1067
|
+
this.host = host;
|
|
1068
|
+
}
|
|
1069
|
+
async getEntry(expose) {
|
|
1070
|
+
if (this.remoteEntryExports) return this.remoteEntryExports;
|
|
1071
|
+
const remoteEntryExports = await getRemoteEntry({
|
|
1072
|
+
origin: this.host,
|
|
1073
|
+
remoteInfo: this.remoteInfo,
|
|
1074
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
1075
|
+
resourceContext: {
|
|
1076
|
+
initiator: "loadRemote",
|
|
1077
|
+
id: composeRemoteRequestId(this.remoteInfo.name, expose),
|
|
1078
|
+
resourceType: "remoteEntry"
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
assert(remoteEntryExports, `remoteEntryExports is undefined
|
|
1082
|
+
${safeToString(this.remoteInfo)}`);
|
|
1083
|
+
this.remoteEntryExports = remoteEntryExports;
|
|
1084
|
+
return this.remoteEntryExports;
|
|
1085
|
+
}
|
|
1086
|
+
async init(id, remoteSnapshot, rawInitScope, expose) {
|
|
1087
|
+
const remoteEntryExports = await this.getEntry(expose);
|
|
1088
|
+
if (this.inited) {
|
|
1089
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1090
|
+
id,
|
|
1091
|
+
remoteInfo: this.remoteInfo,
|
|
1092
|
+
remoteSnapshot,
|
|
1093
|
+
remoteEntryExports,
|
|
1094
|
+
cached: true,
|
|
1095
|
+
origin: this.host
|
|
1096
|
+
});
|
|
1097
|
+
return remoteEntryExports;
|
|
1098
|
+
}
|
|
1099
|
+
if (this.initPromise) {
|
|
1100
|
+
try {
|
|
1101
|
+
await this.initPromise;
|
|
1102
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1103
|
+
id,
|
|
1104
|
+
remoteInfo: this.remoteInfo,
|
|
1105
|
+
remoteSnapshot,
|
|
1106
|
+
remoteEntryExports,
|
|
1107
|
+
cached: true,
|
|
1108
|
+
origin: this.host
|
|
1109
|
+
});
|
|
1110
|
+
} catch (initError) {
|
|
1111
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1112
|
+
id,
|
|
1113
|
+
remoteInfo: this.remoteInfo,
|
|
1114
|
+
remoteSnapshot,
|
|
1115
|
+
remoteEntryExports,
|
|
1116
|
+
error: initError,
|
|
1117
|
+
cached: true,
|
|
1118
|
+
origin: this.host
|
|
1119
|
+
});
|
|
1120
|
+
throw initError;
|
|
1121
|
+
}
|
|
1122
|
+
return remoteEntryExports;
|
|
1123
|
+
}
|
|
1124
|
+
this.initing = true;
|
|
1125
|
+
this.initPromise = (async () => {
|
|
1126
|
+
await this.host.loaderHook.lifecycle.beforeInitRemote.emit({
|
|
1127
|
+
id,
|
|
1128
|
+
remoteInfo: this.remoteInfo,
|
|
1129
|
+
remoteSnapshot,
|
|
1130
|
+
origin: this.host
|
|
1131
|
+
});
|
|
1132
|
+
const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);
|
|
1133
|
+
const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1134
|
+
shareScope,
|
|
1135
|
+
remoteEntryInitOptions,
|
|
1136
|
+
initScope,
|
|
1137
|
+
remoteInfo: this.remoteInfo,
|
|
1138
|
+
origin: this.host
|
|
1139
|
+
});
|
|
1140
|
+
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === "undefined") error(RUNTIME_002, runtimeDescMap, {
|
|
1141
|
+
hostName: this.host.name,
|
|
1142
|
+
remoteName: this.remoteInfo.name,
|
|
1143
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1144
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1145
|
+
}, void 0, optionsToMFContext(this.host.options));
|
|
1146
|
+
try {
|
|
1147
|
+
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
1148
|
+
} catch (initError) {
|
|
1149
|
+
error(RUNTIME_015, runtimeDescMap, {
|
|
1150
|
+
hostName: this.host.name,
|
|
1151
|
+
remoteName: this.remoteInfo.name,
|
|
1152
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1153
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName,
|
|
1154
|
+
shareScope: this.remoteInfo.shareScope
|
|
1155
|
+
}, `${initError}`, optionsToMFContext(this.host.options));
|
|
1156
|
+
}
|
|
1157
|
+
await this.host.hooks.lifecycle.initContainer.emit({
|
|
1158
|
+
...initContainerOptions,
|
|
1159
|
+
id,
|
|
1160
|
+
remoteSnapshot,
|
|
1161
|
+
remoteEntryExports
|
|
1162
|
+
});
|
|
1163
|
+
this.inited = true;
|
|
1164
|
+
})();
|
|
1165
|
+
try {
|
|
1166
|
+
await this.initPromise;
|
|
1167
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1168
|
+
id,
|
|
1169
|
+
remoteInfo: this.remoteInfo,
|
|
1170
|
+
remoteSnapshot,
|
|
1171
|
+
remoteEntryExports,
|
|
1172
|
+
origin: this.host
|
|
1173
|
+
});
|
|
1174
|
+
} catch (initError) {
|
|
1175
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1176
|
+
id,
|
|
1177
|
+
remoteInfo: this.remoteInfo,
|
|
1178
|
+
remoteSnapshot,
|
|
1179
|
+
remoteEntryExports,
|
|
1180
|
+
error: initError,
|
|
1181
|
+
origin: this.host
|
|
1182
|
+
});
|
|
1183
|
+
throw initError;
|
|
1184
|
+
} finally {
|
|
1185
|
+
this.initing = false;
|
|
1186
|
+
this.initPromise = void 0;
|
|
1187
|
+
}
|
|
1188
|
+
return remoteEntryExports;
|
|
1189
|
+
}
|
|
1190
|
+
async get(id, expose, options, remoteSnapshot) {
|
|
1191
|
+
const { loadFactory = true } = options || { loadFactory: true };
|
|
1192
|
+
const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);
|
|
1193
|
+
this.lib = remoteEntryExports;
|
|
1194
|
+
await this.host.loaderHook.lifecycle.beforeGetExpose.emit({
|
|
1195
|
+
id,
|
|
1196
|
+
expose,
|
|
1197
|
+
moduleInfo: this.remoteInfo,
|
|
1198
|
+
remoteEntryExports,
|
|
1199
|
+
origin: this.host
|
|
1200
|
+
});
|
|
1201
|
+
let moduleFactory;
|
|
1202
|
+
try {
|
|
1203
|
+
const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1204
|
+
remoteEntryExports,
|
|
1205
|
+
expose,
|
|
1206
|
+
moduleInfo: this.remoteInfo
|
|
1207
|
+
});
|
|
1208
|
+
moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;
|
|
1209
|
+
if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);
|
|
1210
|
+
if (!moduleFactory) error(RUNTIME_014, runtimeDescMap, {
|
|
1211
|
+
hostName: this.host.name,
|
|
1212
|
+
remoteName: this.remoteInfo.name,
|
|
1213
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1214
|
+
expose,
|
|
1215
|
+
requestId: id,
|
|
1216
|
+
availableExposes: getAvailableExposeNames(remoteSnapshot)
|
|
1217
|
+
}, void 0, optionsToMFContext(this.host.options));
|
|
1218
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
1219
|
+
id,
|
|
1220
|
+
expose,
|
|
1221
|
+
moduleInfo: this.remoteInfo,
|
|
1222
|
+
remoteEntryExports,
|
|
1223
|
+
moduleFactory,
|
|
1224
|
+
origin: this.host
|
|
1225
|
+
});
|
|
1226
|
+
} catch (getExposeError) {
|
|
1227
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
1228
|
+
id,
|
|
1229
|
+
expose,
|
|
1230
|
+
moduleInfo: this.remoteInfo,
|
|
1231
|
+
remoteEntryExports,
|
|
1232
|
+
error: getExposeError,
|
|
1233
|
+
origin: this.host
|
|
1234
|
+
});
|
|
1235
|
+
throw getExposeError;
|
|
1236
|
+
}
|
|
1237
|
+
const symbolName = processModuleAlias(this.remoteInfo.name, expose);
|
|
1238
|
+
const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
|
|
1239
|
+
if (!loadFactory) return wrapModuleFactory;
|
|
1240
|
+
await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({
|
|
1241
|
+
id,
|
|
1242
|
+
expose,
|
|
1243
|
+
moduleInfo: this.remoteInfo,
|
|
1244
|
+
loadFactory,
|
|
1245
|
+
origin: this.host
|
|
1246
|
+
});
|
|
1247
|
+
try {
|
|
1248
|
+
const exposeContent = await wrapModuleFactory();
|
|
1249
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
1250
|
+
id,
|
|
1251
|
+
expose,
|
|
1252
|
+
moduleInfo: this.remoteInfo,
|
|
1253
|
+
loadFactory,
|
|
1254
|
+
exposeModule: exposeContent,
|
|
1255
|
+
origin: this.host
|
|
1256
|
+
});
|
|
1257
|
+
return exposeContent;
|
|
1258
|
+
} catch (executeFactoryError) {
|
|
1259
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
1260
|
+
id,
|
|
1261
|
+
expose,
|
|
1262
|
+
moduleInfo: this.remoteInfo,
|
|
1263
|
+
loadFactory,
|
|
1264
|
+
error: executeFactoryError,
|
|
1265
|
+
origin: this.host
|
|
1266
|
+
});
|
|
1267
|
+
throw executeFactoryError;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
wraperFactory(moduleFactory, id) {
|
|
1271
|
+
function defineModuleId(res, id2) {
|
|
1272
|
+
if (res && typeof res === "object" && Object.isExtensible(res) && !Object.getOwnPropertyDescriptor(res, Symbol.for("mf_module_id"))) Object.defineProperty(res, Symbol.for("mf_module_id"), {
|
|
1273
|
+
value: id2,
|
|
1274
|
+
enumerable: false
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
return () => {
|
|
1278
|
+
const res = moduleFactory();
|
|
1279
|
+
if (res instanceof Promise) return res.then((asyncRes) => {
|
|
1280
|
+
defineModuleId(asyncRes, id);
|
|
1281
|
+
return asyncRes;
|
|
1282
|
+
});
|
|
1283
|
+
defineModuleId(res, id);
|
|
1284
|
+
return res;
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
};
|
|
1288
|
+
const REMOTE_DISABLED_MESSAGE = "Remote loading is disabled by experiments.optimization.disableRemote.";
|
|
1289
|
+
var UnavailableRemoteModule = class {
|
|
1290
|
+
constructor() {
|
|
1291
|
+
throw new Error(REMOTE_DISABLED_MESSAGE);
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
989
1294
|
typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
|
|
1295
|
+
typeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" ? !FEDERATION_OPTIMIZE_NO_REMOTE : true;
|
|
1296
|
+
typeof FEDERATION_OPTIMIZE_NO_SHARED === "boolean" ? !FEDERATION_OPTIMIZE_NO_SHARED : true;
|
|
990
1297
|
const helpers = helpers_default;
|
|
1298
|
+
typeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" && FEDERATION_OPTIMIZE_NO_REMOTE ? UnavailableRemoteModule : Module$1;
|
|
991
1299
|
const utils = helpers.utils;
|
|
992
1300
|
const runtimeHelpers = {
|
|
993
1301
|
utils
|