@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,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const lazyUtils = require("./utils-
|
|
2
|
+
const lazyUtils = require("./utils-5dGErM3C.js");
|
|
3
3
|
const logger = require("./logger-Dxblx6P-.js");
|
|
4
4
|
async function safeWrapper(callback, disableWarn) {
|
|
5
5
|
try {
|
|
@@ -470,6 +470,9 @@ function logAndReport(code, descMap, args, logger2, originalErrorMsg, context) {
|
|
|
470
470
|
return logger2(getShortErrorMsg(code, descMap, args, originalErrorMsg));
|
|
471
471
|
}
|
|
472
472
|
const LOG_CATEGORY = "[ Federation Runtime ]";
|
|
473
|
+
function assert(condition, msgOrCode, descMap, args, context) {
|
|
474
|
+
if (!condition) error(msgOrCode);
|
|
475
|
+
}
|
|
473
476
|
function error(msgOrCode, descMap, args, originalErrorMsg, context) {
|
|
474
477
|
if (descMap !== void 0) return logAndReport(msgOrCode, descMap, args ?? {}, (msg2) => {
|
|
475
478
|
throw new Error(`${LOG_CATEGORY}: ${msg2}`);
|
|
@@ -481,6 +484,14 @@ function error(msgOrCode, descMap, args, originalErrorMsg, context) {
|
|
|
481
484
|
}
|
|
482
485
|
throw new Error(`${LOG_CATEGORY}: ${msg}`);
|
|
483
486
|
}
|
|
487
|
+
const processModuleAlias = (name, subPath) => {
|
|
488
|
+
let moduleName;
|
|
489
|
+
if (name.endsWith("/")) moduleName = name.slice(0, -1);
|
|
490
|
+
else moduleName = name;
|
|
491
|
+
if (subPath.startsWith(".")) subPath = subPath.slice(1);
|
|
492
|
+
moduleName = moduleName + subPath;
|
|
493
|
+
return moduleName;
|
|
494
|
+
};
|
|
484
495
|
const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
|
|
485
496
|
const nativeGlobal = (() => {
|
|
486
497
|
try {
|
|
@@ -533,6 +544,10 @@ const getRemoteEntryExports = (name, globalName) => {
|
|
|
533
544
|
};
|
|
534
545
|
const DEFAULT_SCOPE = "default";
|
|
535
546
|
const DEFAULT_REMOTE_TYPE = "global";
|
|
547
|
+
function composeRemoteRequestId(remoteName, expose) {
|
|
548
|
+
if (!expose || expose === ".") return remoteName;
|
|
549
|
+
return `${remoteName}/${expose.replace(/^\.\//, "")}`;
|
|
550
|
+
}
|
|
536
551
|
function matchRemoteWithNameAndExpose(remotes, id) {
|
|
537
552
|
for (const remote of remotes) {
|
|
538
553
|
const isNameMatched = id.startsWith(remote.name);
|
|
@@ -607,6 +622,9 @@ const runtimeDescMap = {
|
|
|
607
622
|
...runtimeDescMap
|
|
608
623
|
});
|
|
609
624
|
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
625
|
+
function isEsmRemoteType(type) {
|
|
626
|
+
return type === "esm" || type === "module";
|
|
627
|
+
}
|
|
610
628
|
async function loadEsmEntry({ entry, remoteEntryExports }) {
|
|
611
629
|
return new Promise((resolve, reject) => {
|
|
612
630
|
try {
|
|
@@ -674,29 +692,23 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
674
692
|
}
|
|
675
693
|
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
|
|
676
694
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
remoteInfo,
|
|
695
|
-
loaderHook,
|
|
696
|
-
getEntryUrl,
|
|
697
|
-
resourceContext
|
|
698
|
-
});
|
|
699
|
-
}
|
|
695
|
+
if (isEsmRemoteType(type)) return loadEsmEntry({
|
|
696
|
+
entry,
|
|
697
|
+
remoteEntryExports
|
|
698
|
+
});
|
|
699
|
+
if (type === "system") return loadSystemJsEntry({
|
|
700
|
+
entry,
|
|
701
|
+
remoteEntryExports
|
|
702
|
+
});
|
|
703
|
+
return loadEntryScript({
|
|
704
|
+
entry,
|
|
705
|
+
globalName,
|
|
706
|
+
name,
|
|
707
|
+
remoteInfo,
|
|
708
|
+
loaderHook,
|
|
709
|
+
getEntryUrl,
|
|
710
|
+
resourceContext
|
|
711
|
+
});
|
|
700
712
|
}
|
|
701
713
|
async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
|
|
702
714
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
@@ -810,6 +822,42 @@ function getRemoteInfo(remote) {
|
|
|
810
822
|
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
811
823
|
};
|
|
812
824
|
}
|
|
825
|
+
function remoteToEntry(r) {
|
|
826
|
+
return {
|
|
827
|
+
name: r.name,
|
|
828
|
+
alias: r.alias,
|
|
829
|
+
entry: "entry" in r ? r.entry : void 0,
|
|
830
|
+
version: "version" in r ? r.version : void 0,
|
|
831
|
+
type: r.type,
|
|
832
|
+
entryGlobalName: r.entryGlobalName,
|
|
833
|
+
shareScope: r.shareScope
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
function optionsToMFContext(options) {
|
|
837
|
+
var _a, _b, _c, _d, _e, _f;
|
|
838
|
+
const shared = {};
|
|
839
|
+
for (const [pkgName, versions] of Object.entries(options.shared)) {
|
|
840
|
+
const first = versions[0];
|
|
841
|
+
if (first) shared[pkgName] = {
|
|
842
|
+
version: first.version,
|
|
843
|
+
singleton: (_a = first.shareConfig) == null ? void 0 : _a.singleton,
|
|
844
|
+
requiredVersion: ((_b = first.shareConfig) == null ? void 0 : _b.requiredVersion) === false ? false : (_c = first.shareConfig) == null ? void 0 : _c.requiredVersion,
|
|
845
|
+
eager: first.eager,
|
|
846
|
+
strictVersion: (_d = first.shareConfig) == null ? void 0 : _d.strictVersion
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
return {
|
|
850
|
+
project: {
|
|
851
|
+
name: options.name,
|
|
852
|
+
mfRole: ((_e = options.remotes) == null ? void 0 : _e.length) > 0 ? "host" : "unknown"
|
|
853
|
+
},
|
|
854
|
+
mfConfig: {
|
|
855
|
+
name: options.name,
|
|
856
|
+
remotes: ((_f = options.remotes) == null ? void 0 : _f.map(remoteToEntry)) ?? [],
|
|
857
|
+
shared
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
}
|
|
813
861
|
function isTimeoutError(error2) {
|
|
814
862
|
if (!(error2 instanceof Error)) return false;
|
|
815
863
|
return error2.message.includes("timed out") || error2.name.includes("Timeout");
|
|
@@ -919,7 +967,7 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
919
967
|
results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
|
|
920
968
|
});
|
|
921
969
|
if (useLinkPreload) {
|
|
922
|
-
const
|
|
970
|
+
const defaultAttrs2 = {
|
|
923
971
|
rel: "preload",
|
|
924
972
|
as: "style"
|
|
925
973
|
};
|
|
@@ -928,12 +976,12 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
928
976
|
host,
|
|
929
977
|
remoteInfo,
|
|
930
978
|
url: cssUrl,
|
|
931
|
-
attrs:
|
|
979
|
+
attrs: defaultAttrs2,
|
|
932
980
|
context: createResourceContext(baseContext, "css")
|
|
933
981
|
}));
|
|
934
982
|
});
|
|
935
983
|
} else {
|
|
936
|
-
const
|
|
984
|
+
const defaultAttrs2 = {
|
|
937
985
|
rel: "stylesheet",
|
|
938
986
|
type: "text/css"
|
|
939
987
|
};
|
|
@@ -942,41 +990,39 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
942
990
|
host,
|
|
943
991
|
remoteInfo,
|
|
944
992
|
url: cssUrl,
|
|
945
|
-
attrs:
|
|
993
|
+
attrs: defaultAttrs2,
|
|
946
994
|
needDeleteLink: false,
|
|
947
995
|
context: createResourceContext(baseContext, "css")
|
|
948
996
|
}));
|
|
949
997
|
});
|
|
950
998
|
}
|
|
999
|
+
let preloadJsAsset = waitForScriptPreload;
|
|
1000
|
+
let defaultAttrs = {
|
|
1001
|
+
fetchpriority: "high",
|
|
1002
|
+
type: "text/javascript"
|
|
1003
|
+
};
|
|
951
1004
|
if (useLinkPreload) {
|
|
952
|
-
|
|
1005
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1006
|
+
defaultAttrs = {
|
|
953
1007
|
rel: "preload",
|
|
954
1008
|
as: "script"
|
|
955
1009
|
};
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
attrs: defaultAttrs,
|
|
962
|
-
context: createResourceContext(baseContext, "js")
|
|
963
|
-
}));
|
|
964
|
-
});
|
|
965
|
-
} else {
|
|
966
|
-
const defaultAttrs = {
|
|
967
|
-
fetchpriority: "high",
|
|
968
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
|
|
1010
|
+
} else if (isEsmRemoteType(remoteInfo.type)) {
|
|
1011
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1012
|
+
defaultAttrs = {
|
|
1013
|
+
rel: "modulepreload",
|
|
1014
|
+
fetchpriority: "high"
|
|
969
1015
|
};
|
|
970
|
-
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
971
|
-
results.push(waitForScriptPreload({
|
|
972
|
-
host,
|
|
973
|
-
remoteInfo,
|
|
974
|
-
url: jsUrl,
|
|
975
|
-
attrs: defaultAttrs,
|
|
976
|
-
context: createResourceContext(baseContext, "js")
|
|
977
|
-
}));
|
|
978
|
-
});
|
|
979
1016
|
}
|
|
1017
|
+
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
1018
|
+
results.push(preloadJsAsset({
|
|
1019
|
+
host,
|
|
1020
|
+
remoteInfo,
|
|
1021
|
+
url: jsUrl,
|
|
1022
|
+
attrs: defaultAttrs,
|
|
1023
|
+
context: createResourceContext(baseContext, "js")
|
|
1024
|
+
}));
|
|
1025
|
+
});
|
|
980
1026
|
}
|
|
981
1027
|
return Promise.all(results);
|
|
982
1028
|
}
|
|
@@ -987,8 +1033,270 @@ var helpers_default = {
|
|
|
987
1033
|
getRemoteInfo
|
|
988
1034
|
}
|
|
989
1035
|
};
|
|
1036
|
+
function getAvailableExposeNames(remoteSnapshot) {
|
|
1037
|
+
if (!remoteSnapshot || !("modules" in remoteSnapshot) || !Array.isArray(remoteSnapshot.modules)) return;
|
|
1038
|
+
const exposes = remoteSnapshot.modules.map((module2) => module2.moduleName).filter(Boolean);
|
|
1039
|
+
return exposes.length ? exposes.join(",") : void 0;
|
|
1040
|
+
}
|
|
1041
|
+
function createRemoteEntryInitOptions(remoteInfo, hostShareScopeMap, rawInitScope) {
|
|
1042
|
+
const localShareScopeMap = hostShareScopeMap;
|
|
1043
|
+
const shareScopeKeys = Array.isArray(remoteInfo.shareScope) ? remoteInfo.shareScope : [remoteInfo.shareScope];
|
|
1044
|
+
if (!shareScopeKeys.length) shareScopeKeys.push("default");
|
|
1045
|
+
shareScopeKeys.forEach((shareScopeKey) => {
|
|
1046
|
+
if (!localShareScopeMap[shareScopeKey]) localShareScopeMap[shareScopeKey] = {};
|
|
1047
|
+
});
|
|
1048
|
+
const remoteEntryInitOptions = {
|
|
1049
|
+
version: remoteInfo.version || "",
|
|
1050
|
+
shareScopeKeys: Array.isArray(remoteInfo.shareScope) ? shareScopeKeys : remoteInfo.shareScope || "default"
|
|
1051
|
+
};
|
|
1052
|
+
Object.defineProperty(remoteEntryInitOptions, "shareScopeMap", {
|
|
1053
|
+
value: localShareScopeMap,
|
|
1054
|
+
enumerable: false
|
|
1055
|
+
});
|
|
1056
|
+
return {
|
|
1057
|
+
remoteEntryInitOptions,
|
|
1058
|
+
shareScope: localShareScopeMap[shareScopeKeys[0]],
|
|
1059
|
+
initScope: rawInitScope ?? []
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
var Module$1 = class {
|
|
1063
|
+
constructor({ remoteInfo, host }) {
|
|
1064
|
+
this.inited = false;
|
|
1065
|
+
this.initing = false;
|
|
1066
|
+
this.lib = void 0;
|
|
1067
|
+
this.remoteInfo = remoteInfo;
|
|
1068
|
+
this.host = host;
|
|
1069
|
+
}
|
|
1070
|
+
async getEntry(expose) {
|
|
1071
|
+
if (this.remoteEntryExports) return this.remoteEntryExports;
|
|
1072
|
+
const remoteEntryExports = await getRemoteEntry({
|
|
1073
|
+
origin: this.host,
|
|
1074
|
+
remoteInfo: this.remoteInfo,
|
|
1075
|
+
remoteEntryExports: this.remoteEntryExports,
|
|
1076
|
+
resourceContext: {
|
|
1077
|
+
initiator: "loadRemote",
|
|
1078
|
+
id: composeRemoteRequestId(this.remoteInfo.name, expose),
|
|
1079
|
+
resourceType: "remoteEntry"
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
assert(remoteEntryExports, `remoteEntryExports is undefined
|
|
1083
|
+
${lazyUtils.safeToString(this.remoteInfo)}`);
|
|
1084
|
+
this.remoteEntryExports = remoteEntryExports;
|
|
1085
|
+
return this.remoteEntryExports;
|
|
1086
|
+
}
|
|
1087
|
+
async init(id, remoteSnapshot, rawInitScope, expose) {
|
|
1088
|
+
const remoteEntryExports = await this.getEntry(expose);
|
|
1089
|
+
if (this.inited) {
|
|
1090
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1091
|
+
id,
|
|
1092
|
+
remoteInfo: this.remoteInfo,
|
|
1093
|
+
remoteSnapshot,
|
|
1094
|
+
remoteEntryExports,
|
|
1095
|
+
cached: true,
|
|
1096
|
+
origin: this.host
|
|
1097
|
+
});
|
|
1098
|
+
return remoteEntryExports;
|
|
1099
|
+
}
|
|
1100
|
+
if (this.initPromise) {
|
|
1101
|
+
try {
|
|
1102
|
+
await this.initPromise;
|
|
1103
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1104
|
+
id,
|
|
1105
|
+
remoteInfo: this.remoteInfo,
|
|
1106
|
+
remoteSnapshot,
|
|
1107
|
+
remoteEntryExports,
|
|
1108
|
+
cached: true,
|
|
1109
|
+
origin: this.host
|
|
1110
|
+
});
|
|
1111
|
+
} catch (initError) {
|
|
1112
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1113
|
+
id,
|
|
1114
|
+
remoteInfo: this.remoteInfo,
|
|
1115
|
+
remoteSnapshot,
|
|
1116
|
+
remoteEntryExports,
|
|
1117
|
+
error: initError,
|
|
1118
|
+
cached: true,
|
|
1119
|
+
origin: this.host
|
|
1120
|
+
});
|
|
1121
|
+
throw initError;
|
|
1122
|
+
}
|
|
1123
|
+
return remoteEntryExports;
|
|
1124
|
+
}
|
|
1125
|
+
this.initing = true;
|
|
1126
|
+
this.initPromise = (async () => {
|
|
1127
|
+
await this.host.loaderHook.lifecycle.beforeInitRemote.emit({
|
|
1128
|
+
id,
|
|
1129
|
+
remoteInfo: this.remoteInfo,
|
|
1130
|
+
remoteSnapshot,
|
|
1131
|
+
origin: this.host
|
|
1132
|
+
});
|
|
1133
|
+
const { remoteEntryInitOptions, shareScope, initScope } = createRemoteEntryInitOptions(this.remoteInfo, this.host.shareScopeMap, rawInitScope);
|
|
1134
|
+
const initContainerOptions = await this.host.hooks.lifecycle.beforeInitContainer.emit({
|
|
1135
|
+
shareScope,
|
|
1136
|
+
remoteEntryInitOptions,
|
|
1137
|
+
initScope,
|
|
1138
|
+
remoteInfo: this.remoteInfo,
|
|
1139
|
+
origin: this.host
|
|
1140
|
+
});
|
|
1141
|
+
if (typeof (remoteEntryExports == null ? void 0 : remoteEntryExports.init) === "undefined") error(RUNTIME_002, runtimeDescMap, {
|
|
1142
|
+
hostName: this.host.name,
|
|
1143
|
+
remoteName: this.remoteInfo.name,
|
|
1144
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1145
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName
|
|
1146
|
+
}, void 0, optionsToMFContext(this.host.options));
|
|
1147
|
+
try {
|
|
1148
|
+
await remoteEntryExports.init(initContainerOptions.shareScope, initContainerOptions.initScope, initContainerOptions.remoteEntryInitOptions);
|
|
1149
|
+
} catch (initError) {
|
|
1150
|
+
error(RUNTIME_015, runtimeDescMap, {
|
|
1151
|
+
hostName: this.host.name,
|
|
1152
|
+
remoteName: this.remoteInfo.name,
|
|
1153
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1154
|
+
remoteEntryKey: this.remoteInfo.entryGlobalName,
|
|
1155
|
+
shareScope: this.remoteInfo.shareScope
|
|
1156
|
+
}, `${initError}`, optionsToMFContext(this.host.options));
|
|
1157
|
+
}
|
|
1158
|
+
await this.host.hooks.lifecycle.initContainer.emit({
|
|
1159
|
+
...initContainerOptions,
|
|
1160
|
+
id,
|
|
1161
|
+
remoteSnapshot,
|
|
1162
|
+
remoteEntryExports
|
|
1163
|
+
});
|
|
1164
|
+
this.inited = true;
|
|
1165
|
+
})();
|
|
1166
|
+
try {
|
|
1167
|
+
await this.initPromise;
|
|
1168
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1169
|
+
id,
|
|
1170
|
+
remoteInfo: this.remoteInfo,
|
|
1171
|
+
remoteSnapshot,
|
|
1172
|
+
remoteEntryExports,
|
|
1173
|
+
origin: this.host
|
|
1174
|
+
});
|
|
1175
|
+
} catch (initError) {
|
|
1176
|
+
await this.host.loaderHook.lifecycle.afterInitRemote.emit({
|
|
1177
|
+
id,
|
|
1178
|
+
remoteInfo: this.remoteInfo,
|
|
1179
|
+
remoteSnapshot,
|
|
1180
|
+
remoteEntryExports,
|
|
1181
|
+
error: initError,
|
|
1182
|
+
origin: this.host
|
|
1183
|
+
});
|
|
1184
|
+
throw initError;
|
|
1185
|
+
} finally {
|
|
1186
|
+
this.initing = false;
|
|
1187
|
+
this.initPromise = void 0;
|
|
1188
|
+
}
|
|
1189
|
+
return remoteEntryExports;
|
|
1190
|
+
}
|
|
1191
|
+
async get(id, expose, options, remoteSnapshot) {
|
|
1192
|
+
const { loadFactory = true } = options || { loadFactory: true };
|
|
1193
|
+
const remoteEntryExports = await this.init(id, remoteSnapshot, void 0, expose);
|
|
1194
|
+
this.lib = remoteEntryExports;
|
|
1195
|
+
await this.host.loaderHook.lifecycle.beforeGetExpose.emit({
|
|
1196
|
+
id,
|
|
1197
|
+
expose,
|
|
1198
|
+
moduleInfo: this.remoteInfo,
|
|
1199
|
+
remoteEntryExports,
|
|
1200
|
+
origin: this.host
|
|
1201
|
+
});
|
|
1202
|
+
let moduleFactory;
|
|
1203
|
+
try {
|
|
1204
|
+
const hookModuleFactory = await this.host.loaderHook.lifecycle.getModuleFactory.emit({
|
|
1205
|
+
remoteEntryExports,
|
|
1206
|
+
expose,
|
|
1207
|
+
moduleInfo: this.remoteInfo
|
|
1208
|
+
});
|
|
1209
|
+
moduleFactory = typeof hookModuleFactory === "function" ? hookModuleFactory : void 0;
|
|
1210
|
+
if (!moduleFactory) moduleFactory = await remoteEntryExports.get(expose);
|
|
1211
|
+
if (!moduleFactory) error(RUNTIME_014, runtimeDescMap, {
|
|
1212
|
+
hostName: this.host.name,
|
|
1213
|
+
remoteName: this.remoteInfo.name,
|
|
1214
|
+
remoteEntryUrl: this.remoteInfo.entry,
|
|
1215
|
+
expose,
|
|
1216
|
+
requestId: id,
|
|
1217
|
+
availableExposes: getAvailableExposeNames(remoteSnapshot)
|
|
1218
|
+
}, void 0, optionsToMFContext(this.host.options));
|
|
1219
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
1220
|
+
id,
|
|
1221
|
+
expose,
|
|
1222
|
+
moduleInfo: this.remoteInfo,
|
|
1223
|
+
remoteEntryExports,
|
|
1224
|
+
moduleFactory,
|
|
1225
|
+
origin: this.host
|
|
1226
|
+
});
|
|
1227
|
+
} catch (getExposeError) {
|
|
1228
|
+
await this.host.loaderHook.lifecycle.afterGetExpose.emit({
|
|
1229
|
+
id,
|
|
1230
|
+
expose,
|
|
1231
|
+
moduleInfo: this.remoteInfo,
|
|
1232
|
+
remoteEntryExports,
|
|
1233
|
+
error: getExposeError,
|
|
1234
|
+
origin: this.host
|
|
1235
|
+
});
|
|
1236
|
+
throw getExposeError;
|
|
1237
|
+
}
|
|
1238
|
+
const symbolName = processModuleAlias(this.remoteInfo.name, expose);
|
|
1239
|
+
const wrapModuleFactory = this.wraperFactory(moduleFactory, symbolName);
|
|
1240
|
+
if (!loadFactory) return wrapModuleFactory;
|
|
1241
|
+
await this.host.loaderHook.lifecycle.beforeExecuteFactory.emit({
|
|
1242
|
+
id,
|
|
1243
|
+
expose,
|
|
1244
|
+
moduleInfo: this.remoteInfo,
|
|
1245
|
+
loadFactory,
|
|
1246
|
+
origin: this.host
|
|
1247
|
+
});
|
|
1248
|
+
try {
|
|
1249
|
+
const exposeContent = await wrapModuleFactory();
|
|
1250
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
1251
|
+
id,
|
|
1252
|
+
expose,
|
|
1253
|
+
moduleInfo: this.remoteInfo,
|
|
1254
|
+
loadFactory,
|
|
1255
|
+
exposeModule: exposeContent,
|
|
1256
|
+
origin: this.host
|
|
1257
|
+
});
|
|
1258
|
+
return exposeContent;
|
|
1259
|
+
} catch (executeFactoryError) {
|
|
1260
|
+
await this.host.loaderHook.lifecycle.afterExecuteFactory.emit({
|
|
1261
|
+
id,
|
|
1262
|
+
expose,
|
|
1263
|
+
moduleInfo: this.remoteInfo,
|
|
1264
|
+
loadFactory,
|
|
1265
|
+
error: executeFactoryError,
|
|
1266
|
+
origin: this.host
|
|
1267
|
+
});
|
|
1268
|
+
throw executeFactoryError;
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
wraperFactory(moduleFactory, id) {
|
|
1272
|
+
function defineModuleId(res, id2) {
|
|
1273
|
+
if (res && typeof res === "object" && Object.isExtensible(res) && !Object.getOwnPropertyDescriptor(res, Symbol.for("mf_module_id"))) Object.defineProperty(res, Symbol.for("mf_module_id"), {
|
|
1274
|
+
value: id2,
|
|
1275
|
+
enumerable: false
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
return () => {
|
|
1279
|
+
const res = moduleFactory();
|
|
1280
|
+
if (res instanceof Promise) return res.then((asyncRes) => {
|
|
1281
|
+
defineModuleId(asyncRes, id);
|
|
1282
|
+
return asyncRes;
|
|
1283
|
+
});
|
|
1284
|
+
defineModuleId(res, id);
|
|
1285
|
+
return res;
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
};
|
|
1289
|
+
const REMOTE_DISABLED_MESSAGE = "Remote loading is disabled by experiments.optimization.disableRemote.";
|
|
1290
|
+
var UnavailableRemoteModule = class {
|
|
1291
|
+
constructor() {
|
|
1292
|
+
throw new Error(REMOTE_DISABLED_MESSAGE);
|
|
1293
|
+
}
|
|
1294
|
+
};
|
|
990
1295
|
typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
|
|
1296
|
+
typeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" ? !FEDERATION_OPTIMIZE_NO_REMOTE : true;
|
|
1297
|
+
typeof FEDERATION_OPTIMIZE_NO_SHARED === "boolean" ? !FEDERATION_OPTIMIZE_NO_SHARED : true;
|
|
991
1298
|
const helpers = helpers_default;
|
|
1299
|
+
typeof FEDERATION_OPTIMIZE_NO_REMOTE === "boolean" && FEDERATION_OPTIMIZE_NO_REMOTE ? UnavailableRemoteModule : Module$1;
|
|
992
1300
|
const utils = helpers.utils;
|
|
993
1301
|
const runtimeHelpers = {
|
|
994
1302
|
utils
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ModuleFederationRuntimePlugin, ModuleFederation } from '@module-federation/runtime';
|
|
2
|
+
export type FederationRuntimeType = {
|
|
3
|
+
instance: ModuleFederation | null;
|
|
4
|
+
};
|
|
5
|
+
export declare const federationRuntime: FederationRuntimeType;
|
|
6
|
+
declare function BridgeReactPlugin(): ModuleFederationRuntimePlugin;
|
|
7
|
+
export default BridgeReactPlugin;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ProviderFnParams, DestroyParams, RenderParams } from '../../types';
|
|
2
|
+
export declare function createBaseBridgeComponent<T>({ createRoot, defaultRootOptions, ...bridgeInfo }: ProviderFnParams<T>): () => {
|
|
3
|
+
render(info: RenderParams): Promise<void>;
|
|
4
|
+
destroy(info: DestroyParams): void;
|
|
5
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for React 16/17 (legacy) specific bridge components
|
|
3
|
+
* This file provides support for React 16 and 17 versions, using the traditional ReactDOM.render API
|
|
4
|
+
*/
|
|
5
|
+
import type { ProviderFnParams } from '../../types';
|
|
6
|
+
export interface CreateRootOptions {
|
|
7
|
+
identifierPrefix?: string;
|
|
8
|
+
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface Root {
|
|
11
|
+
render(children: React.ReactNode): void;
|
|
12
|
+
unmount(): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Default createRoot function that automatically detects React version and uses the appropriate API(only support React 16/17, 18)
|
|
16
|
+
*
|
|
17
|
+
* Note: Users can also directly import version-specific bridge components:
|
|
18
|
+
* - import { createBridgeComponent } from '@module-federation/bridge-react'
|
|
19
|
+
* - import { createBridgeComponent } from '@module-federation/bridge-react/v18'
|
|
20
|
+
* - import { createBridgeComponent } from '@module-federation/bridge-react/v19'
|
|
21
|
+
*/
|
|
22
|
+
export declare function createReact16Or17Root(container: Element | DocumentFragment): Root;
|
|
23
|
+
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
24
|
+
render(info: import("../..").RenderParams): Promise<void>;
|
|
25
|
+
destroy(info: import("../..").DestroyParams): void;
|
|
26
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for React 18 specific bridge components
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import type { ProviderFnParams } from '../../types';
|
|
6
|
+
export interface CreateRootOptions {
|
|
7
|
+
identifierPrefix?: string;
|
|
8
|
+
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
9
|
+
}
|
|
10
|
+
export interface Root {
|
|
11
|
+
render(children: React.ReactNode): void;
|
|
12
|
+
unmount(): void;
|
|
13
|
+
}
|
|
14
|
+
export declare function createReact18Root(container: Element | DocumentFragment, options?: CreateRootOptions): Root;
|
|
15
|
+
export declare function hydrateReact18Root(container: Element | DocumentFragment, initialChildren: React.ReactNode, options?: CreateRootOptions): import("node_modules/@types/react-dom/client").Root;
|
|
16
|
+
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
17
|
+
render(info: import("../..").RenderParams): Promise<void>;
|
|
18
|
+
destroy(info: import("../..").DestroyParams): void;
|
|
19
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point for React 19 specific bridge components
|
|
3
|
+
* This file provides support for React 19 version, using the new ReactDOM.createRoot API
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { ProviderFnParams } from '../../types';
|
|
7
|
+
export interface CreateRootOptions {
|
|
8
|
+
identifierPrefix?: string;
|
|
9
|
+
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
10
|
+
transitionCallbacks?: unknown;
|
|
11
|
+
}
|
|
12
|
+
export interface Root {
|
|
13
|
+
render(children: React.ReactNode): void;
|
|
14
|
+
unmount(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createReact19Root(container: Element | DocumentFragment, options?: CreateRootOptions): Root;
|
|
17
|
+
export declare function hydrateReact19Root(container: Element | DocumentFragment, initialChildren: React.ReactNode, options?: CreateRootOptions): Root;
|
|
18
|
+
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
19
|
+
render(info: import("../..").RenderParams): Promise<void>;
|
|
20
|
+
destroy(info: import("../..").DestroyParams): void;
|
|
21
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared RemoteAppWrapper component used by both base and router versions
|
|
3
|
+
* This component handles the lifecycle of remote Module Federation apps
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { RemoteComponentProps, RemoteAppParams } from '../types';
|
|
7
|
+
export declare const RemoteAppWrapper: React.ForwardRefExoticComponent<Omit<RemoteAppParams & RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type LazyRemoteComponentInfo } from '../createHelpers';
|
|
2
|
+
export type { LazyRemoteComponentInfo };
|
|
3
|
+
declare const createLazyRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").LazyExoticComponent<import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>>;
|
|
4
|
+
export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
7
|
+
*/
|
|
8
|
+
export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
|
|
9
|
+
export { createLazyRemoteComponent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RemoteComponentParams, RemoteComponentProps } from '../types';
|
|
3
|
+
export type LazyRemoteComponentInfo<T, _E extends keyof T> = RemoteComponentParams<T>;
|
|
4
|
+
/**
|
|
5
|
+
* Creates a factory function for creating lazy remote components
|
|
6
|
+
* @param RemoteApp The RemoteAppWrapper component to use (with or without router)
|
|
7
|
+
*/
|
|
8
|
+
export declare function createLazyRemoteComponentFactory(RemoteApp: React.ComponentType<any>): <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => React.LazyExoticComponent<React.ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<HTMLDivElement>>>;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a factory function for creating remote app components
|
|
11
|
+
* @param RemoteApp The RemoteAppWrapper component to use (with or without router)
|
|
12
|
+
*/
|
|
13
|
+
export declare function createRemoteAppComponentFactory(RemoteApp: React.ComponentType<any>): <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => React.ForwardRefExoticComponent<Omit<RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates the deprecated createRemoteComponent function
|
|
16
|
+
*/
|
|
17
|
+
export declare function createDeprecatedRemoteComponentFactory<T = Record<string, unknown>, E extends keyof T = keyof T>(createFn: (info: LazyRemoteComponentInfo<T, E>) => any): (info: LazyRemoteComponentInfo<T, E>) => any;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { RemoteAppWrapper } from '../RemoteAppWrapper';
|
|
3
|
+
interface ExtraDataProps {
|
|
4
|
+
basename?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function withRouterData<P extends Parameters<typeof RemoteAppWrapper>[0]>(WrappedComponent: React.ComponentType<P & ExtraDataProps>): React.FC<Omit<P, keyof ExtraDataProps>>;
|
|
7
|
+
declare const _default: React.FC<Omit<Omit<import("../../types").RemoteAppParams & import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & React.RefAttributes<unknown>, "basename">>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type LazyRemoteComponentInfo } from '../createHelpers';
|
|
2
|
+
export type { LazyRemoteComponentInfo };
|
|
3
|
+
declare const createLazyRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").LazyExoticComponent<import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>>;
|
|
4
|
+
export declare const createRemoteAppComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => import("node_modules/@types/react").ForwardRefExoticComponent<Omit<import("../..").RemoteComponentProps<Record<string, unknown>>, "ref"> & import("node_modules/@types/react").RefAttributes<HTMLDivElement>>;
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated createRemoteComponent is deprecated, please use createRemoteAppComponent instead!
|
|
7
|
+
*/
|
|
8
|
+
export declare const createRemoteComponent: <T = Record<string, unknown>, E extends keyof T = keyof T>(info: LazyRemoteComponentInfo<T, E>) => any;
|
|
9
|
+
export { createLazyRemoteComponent };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as ReactRouterDom from 'react-router-dom/';
|
|
3
|
+
declare function WrapperRouter(props: Parameters<typeof ReactRouterDom.BrowserRouter>[0] | Parameters<typeof ReactRouterDom.MemoryRouter>[0]): React.JSX.Element;
|
|
4
|
+
declare function WrapperRouterProvider(props: Parameters<typeof ReactRouterDom.RouterProvider>[0]): React.JSX.Element;
|
|
5
|
+
export * from 'react-router-dom/';
|
|
6
|
+
export { WrapperRouter as BrowserRouter };
|
|
7
|
+
export { WrapperRouterProvider as RouterProvider };
|