@module-federation/bridge-react 2.4.0 → 2.5.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 +2 -2
- package/dist/base.es.js +3 -3
- package/dist/data-fetch-server-middleware.es.js +1 -1
- package/dist/data-fetch-utils.cjs.js +1 -1
- package/dist/data-fetch-utils.es.js +4 -4
- package/dist/data-fetch.cjs.js +22 -0
- package/dist/data-fetch.d.ts +140 -0
- package/dist/data-fetch.es.js +22 -0
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +3 -3
- package/dist/{lazy-load-component-plugin-DZDwZ0Kz.js → lazy-load-component-plugin-8zeSnzyV.js} +1 -1
- package/dist/{lazy-load-component-plugin-Bf_HsMyF.mjs → lazy-load-component-plugin-B3GJRx1-.mjs} +2 -2
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.es.js +17 -17
- package/dist/{prefetch-DYFX9hl9.js → prefetch-DVsz9M2C.js} +210 -82
- package/dist/{prefetch-ByDYONsx.mjs → prefetch-zNZ70qRm.mjs} +211 -83
- package/dist/{utils-D4k5eixv.mjs → utils-DGS4pYp8.mjs} +23 -23
- package/package.json +14 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-DGS4pYp8.mjs";
|
|
2
2
|
import { i as isBrowserEnvValue } from "./logger-DwWkXsWl.mjs";
|
|
3
3
|
async function safeWrapper(callback, disableWarn) {
|
|
4
4
|
try {
|
|
@@ -104,6 +104,8 @@ function createScript(info) {
|
|
|
104
104
|
function createLink(info) {
|
|
105
105
|
let link = null;
|
|
106
106
|
let needAttach = true;
|
|
107
|
+
let timeout = 2e4;
|
|
108
|
+
let timeoutId;
|
|
107
109
|
const links = document.getElementsByTagName("link");
|
|
108
110
|
for (let i = 0; i < links.length; i++) {
|
|
109
111
|
const l = links[i];
|
|
@@ -119,19 +121,42 @@ function createLink(info) {
|
|
|
119
121
|
link = document.createElement("link");
|
|
120
122
|
link.setAttribute("href", info.url);
|
|
121
123
|
let createLinkRes = void 0;
|
|
124
|
+
let shouldApplyAttrs = true;
|
|
122
125
|
const attrs = info.attrs;
|
|
123
126
|
if (info.createLinkHook) {
|
|
124
127
|
createLinkRes = info.createLinkHook(info.url, attrs);
|
|
125
|
-
if (createLinkRes instanceof HTMLLinkElement)
|
|
128
|
+
if (createLinkRes instanceof HTMLLinkElement) {
|
|
129
|
+
link = createLinkRes;
|
|
130
|
+
shouldApplyAttrs = false;
|
|
131
|
+
} else if (typeof createLinkRes === "object") {
|
|
132
|
+
if ("link" in createLinkRes && createLinkRes.link) {
|
|
133
|
+
link = createLinkRes.link;
|
|
134
|
+
shouldApplyAttrs = false;
|
|
135
|
+
}
|
|
136
|
+
if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;
|
|
137
|
+
}
|
|
126
138
|
}
|
|
127
|
-
if (attrs &&
|
|
139
|
+
if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {
|
|
128
140
|
if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);
|
|
129
141
|
});
|
|
130
142
|
}
|
|
143
|
+
if (!needAttach) {
|
|
144
|
+
Promise.resolve().then(() => {
|
|
145
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
146
|
+
});
|
|
147
|
+
return {
|
|
148
|
+
link,
|
|
149
|
+
needAttach
|
|
150
|
+
};
|
|
151
|
+
}
|
|
131
152
|
const onLinkComplete = (prev, event) => {
|
|
153
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
132
154
|
const onLinkCompleteCallback = () => {
|
|
133
|
-
if ((event == null ? void 0 : event.type) === "error")
|
|
134
|
-
|
|
155
|
+
if ((event == null ? void 0 : event.type) === "error") {
|
|
156
|
+
const linkError = /* @__PURE__ */ new Error((event == null ? void 0 : event.isTimeout) ? `LinkNetworkError: Link "${info.url}" timed out.` : `LinkNetworkError: Failed to load link "${info.url}" - the URL is unreachable or the server returned an error.`);
|
|
157
|
+
linkError.name = "LinkNetworkError";
|
|
158
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(linkError));
|
|
159
|
+
} else (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
135
160
|
};
|
|
136
161
|
if (link) {
|
|
137
162
|
link.onerror = null;
|
|
@@ -150,6 +175,12 @@ function createLink(info) {
|
|
|
150
175
|
};
|
|
151
176
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
152
177
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
178
|
+
timeoutId = setTimeout(() => {
|
|
179
|
+
onLinkComplete(null, {
|
|
180
|
+
type: "error",
|
|
181
|
+
isTimeout: true
|
|
182
|
+
});
|
|
183
|
+
}, timeout);
|
|
153
184
|
return {
|
|
154
185
|
link,
|
|
155
186
|
needAttach
|
|
@@ -493,6 +524,9 @@ const RUNTIME_009 = "RUNTIME-009";
|
|
|
493
524
|
const RUNTIME_010 = "RUNTIME-010";
|
|
494
525
|
const RUNTIME_011 = "RUNTIME-011";
|
|
495
526
|
const RUNTIME_012 = "RUNTIME-012";
|
|
527
|
+
const RUNTIME_013 = "RUNTIME-013";
|
|
528
|
+
const RUNTIME_014 = "RUNTIME-014";
|
|
529
|
+
const RUNTIME_015 = "RUNTIME-015";
|
|
496
530
|
const runtimeDescMap = {
|
|
497
531
|
[RUNTIME_001]: "Failed to get remoteEntry exports.",
|
|
498
532
|
[RUNTIME_002]: 'The remote entry interface does not contain "init"',
|
|
@@ -505,7 +539,10 @@ const runtimeDescMap = {
|
|
|
505
539
|
[RUNTIME_009]: "Please call createInstance first.",
|
|
506
540
|
[RUNTIME_010]: 'The name option cannot be changed after initialization. If you want to create a new instance with a different name, please use "createInstance" api.',
|
|
507
541
|
[RUNTIME_011]: "The remoteEntry URL is missing from the remote snapshot.",
|
|
508
|
-
[RUNTIME_012]: 'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.'
|
|
542
|
+
[RUNTIME_012]: 'The getter for the shared module is not a function. This may be caused by setting "shared.import: false" without the host providing the corresponding lib.',
|
|
543
|
+
[RUNTIME_013]: "The manifest is not a valid Module Federation manifest.",
|
|
544
|
+
[RUNTIME_014]: "The remote does not expose the requested module.",
|
|
545
|
+
[RUNTIME_015]: "Remote container initialization failed."
|
|
509
546
|
};
|
|
510
547
|
({
|
|
511
548
|
...runtimeDescMap
|
|
@@ -546,7 +583,7 @@ function handleRemoteEntryLoaded(name, globalName, entry) {
|
|
|
546
583
|
});
|
|
547
584
|
return entryExports;
|
|
548
585
|
}
|
|
549
|
-
async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl }) {
|
|
586
|
+
async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl, resourceContext }) {
|
|
550
587
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
551
588
|
if (remoteEntryExports) return remoteEntryExports;
|
|
552
589
|
const url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
@@ -556,7 +593,11 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
556
593
|
const res = loaderHook.lifecycle.createScript.emit({
|
|
557
594
|
url: url2,
|
|
558
595
|
attrs,
|
|
559
|
-
remoteInfo
|
|
596
|
+
remoteInfo,
|
|
597
|
+
resourceContext: resourceContext ? {
|
|
598
|
+
...resourceContext,
|
|
599
|
+
url: url2
|
|
600
|
+
} : void 0
|
|
560
601
|
});
|
|
561
602
|
if (!res) return;
|
|
562
603
|
if (res instanceof HTMLScriptElement) return res;
|
|
@@ -572,7 +613,7 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
572
613
|
}, originalMsg);
|
|
573
614
|
});
|
|
574
615
|
}
|
|
575
|
-
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl }) {
|
|
616
|
+
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
|
|
576
617
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
577
618
|
switch (type) {
|
|
578
619
|
case "esm":
|
|
@@ -593,11 +634,12 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEnt
|
|
|
593
634
|
name,
|
|
594
635
|
remoteInfo,
|
|
595
636
|
loaderHook,
|
|
596
|
-
getEntryUrl
|
|
637
|
+
getEntryUrl,
|
|
638
|
+
resourceContext
|
|
597
639
|
});
|
|
598
640
|
}
|
|
599
641
|
}
|
|
600
|
-
async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
642
|
+
async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
|
|
601
643
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
602
644
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
603
645
|
if (remoteEntryExports) return remoteEntryExports;
|
|
@@ -611,7 +653,11 @@ async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
|
611
653
|
const res = loaderHook.lifecycle.createScript.emit({
|
|
612
654
|
url,
|
|
613
655
|
attrs,
|
|
614
|
-
remoteInfo
|
|
656
|
+
remoteInfo,
|
|
657
|
+
resourceContext: resourceContext ? {
|
|
658
|
+
...resourceContext,
|
|
659
|
+
url
|
|
660
|
+
} : void 0
|
|
615
661
|
});
|
|
616
662
|
if (!res) return;
|
|
617
663
|
if ("url" in res) return res;
|
|
@@ -627,13 +673,14 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
627
673
|
return composeKeyWithSeparator(name, entry);
|
|
628
674
|
}
|
|
629
675
|
async function getRemoteEntry(params) {
|
|
630
|
-
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
|
|
676
|
+
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
|
|
631
677
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
632
678
|
if (remoteEntryExports) return remoteEntryExports;
|
|
633
679
|
if (!globalLoading[uniqueKey]) {
|
|
634
680
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
635
681
|
const loaderHook = origin.loaderHook;
|
|
636
682
|
globalLoading[uniqueKey] = loadEntryHook.emit({
|
|
683
|
+
origin,
|
|
637
684
|
loaderHook,
|
|
638
685
|
remoteInfo,
|
|
639
686
|
remoteEntryExports
|
|
@@ -643,11 +690,20 @@ async function getRemoteEntry(params) {
|
|
|
643
690
|
remoteInfo,
|
|
644
691
|
remoteEntryExports,
|
|
645
692
|
loaderHook,
|
|
646
|
-
getEntryUrl
|
|
693
|
+
getEntryUrl,
|
|
694
|
+
resourceContext
|
|
647
695
|
}) : loadEntryNode({
|
|
648
696
|
remoteInfo,
|
|
649
|
-
loaderHook
|
|
697
|
+
loaderHook,
|
|
698
|
+
resourceContext
|
|
650
699
|
});
|
|
700
|
+
}).then(async (res) => {
|
|
701
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
702
|
+
origin,
|
|
703
|
+
remoteInfo,
|
|
704
|
+
remoteEntryExports: res
|
|
705
|
+
});
|
|
706
|
+
return res;
|
|
651
707
|
}).catch(async (err) => {
|
|
652
708
|
const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
|
|
653
709
|
const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");
|
|
@@ -666,8 +722,21 @@ async function getRemoteEntry(params) {
|
|
|
666
722
|
globalLoading,
|
|
667
723
|
uniqueKey: uniqueKey2
|
|
668
724
|
});
|
|
669
|
-
if (RemoteEntryExports)
|
|
725
|
+
if (RemoteEntryExports) {
|
|
726
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
727
|
+
origin,
|
|
728
|
+
remoteInfo,
|
|
729
|
+
remoteEntryExports: RemoteEntryExports,
|
|
730
|
+
recovered: true
|
|
731
|
+
});
|
|
732
|
+
return RemoteEntryExports;
|
|
733
|
+
}
|
|
670
734
|
}
|
|
735
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
736
|
+
origin,
|
|
737
|
+
remoteInfo,
|
|
738
|
+
error: err
|
|
739
|
+
});
|
|
671
740
|
throw err;
|
|
672
741
|
});
|
|
673
742
|
}
|
|
@@ -682,22 +751,113 @@ function getRemoteInfo(remote) {
|
|
|
682
751
|
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
683
752
|
};
|
|
684
753
|
}
|
|
685
|
-
function
|
|
754
|
+
function isTimeoutError(error2) {
|
|
755
|
+
if (!(error2 instanceof Error)) return false;
|
|
756
|
+
return error2.message.includes("timed out") || error2.name.includes("Timeout");
|
|
757
|
+
}
|
|
758
|
+
function createAssetResult(context, url, status, error2) {
|
|
759
|
+
return {
|
|
760
|
+
url,
|
|
761
|
+
status,
|
|
762
|
+
resourceType: context.resourceType,
|
|
763
|
+
initiator: context.initiator,
|
|
764
|
+
id: context.id,
|
|
765
|
+
error: error2
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
async function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {
|
|
769
|
+
const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);
|
|
770
|
+
const url = entryRemoteInfo.entry;
|
|
771
|
+
if (cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports) return createAssetResult(context, url, "cached");
|
|
772
|
+
try {
|
|
773
|
+
if (!await getRemoteEntry({
|
|
774
|
+
origin: host,
|
|
775
|
+
remoteInfo: entryRemoteInfo,
|
|
776
|
+
remoteEntryExports: cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports,
|
|
777
|
+
resourceContext: {
|
|
778
|
+
...context,
|
|
779
|
+
url
|
|
780
|
+
}
|
|
781
|
+
})) throw new Error(`Failed to load remoteEntry "${url}".`);
|
|
782
|
+
return createAssetResult(context, url, "success");
|
|
783
|
+
} catch (error2) {
|
|
784
|
+
return createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2);
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
function waitForLinkPreload({ host, remoteInfo, url, attrs, context, needDeleteLink }) {
|
|
788
|
+
return new Promise((resolve) => {
|
|
789
|
+
const { link, needAttach } = createLink({
|
|
790
|
+
url,
|
|
791
|
+
cb: () => {
|
|
792
|
+
resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
|
|
793
|
+
},
|
|
794
|
+
onErrorCallback: (error2) => {
|
|
795
|
+
resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));
|
|
796
|
+
},
|
|
797
|
+
attrs,
|
|
798
|
+
createLinkHook: (hookUrl, hookAttrs) => {
|
|
799
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
800
|
+
url: hookUrl,
|
|
801
|
+
attrs: hookAttrs,
|
|
802
|
+
remoteInfo,
|
|
803
|
+
resourceContext: {
|
|
804
|
+
...context,
|
|
805
|
+
url: hookUrl
|
|
806
|
+
}
|
|
807
|
+
});
|
|
808
|
+
if (res instanceof HTMLLinkElement) return res;
|
|
809
|
+
return res;
|
|
810
|
+
},
|
|
811
|
+
needDeleteLink
|
|
812
|
+
});
|
|
813
|
+
needAttach && document.head.appendChild(link);
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
function waitForScriptPreload({ host, remoteInfo, url, attrs, context }) {
|
|
817
|
+
return new Promise((resolve) => {
|
|
818
|
+
const { script, needAttach } = createScript({
|
|
819
|
+
url,
|
|
820
|
+
cb: () => {
|
|
821
|
+
resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
|
|
822
|
+
},
|
|
823
|
+
onErrorCallback: (error2) => {
|
|
824
|
+
resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));
|
|
825
|
+
},
|
|
826
|
+
attrs,
|
|
827
|
+
createScriptHook: (hookUrl, hookAttrs) => {
|
|
828
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
829
|
+
url: hookUrl,
|
|
830
|
+
attrs: hookAttrs,
|
|
831
|
+
remoteInfo,
|
|
832
|
+
resourceContext: {
|
|
833
|
+
...context,
|
|
834
|
+
url: hookUrl
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
if (res instanceof HTMLScriptElement) return res;
|
|
838
|
+
return res;
|
|
839
|
+
},
|
|
840
|
+
needDeleteScript: true
|
|
841
|
+
});
|
|
842
|
+
needAttach && document.head.appendChild(script);
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
function createResourceContext(baseContext, resourceType) {
|
|
846
|
+
return {
|
|
847
|
+
...baseContext,
|
|
848
|
+
resourceType
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {
|
|
852
|
+
initiator: "preloadRemote",
|
|
853
|
+
id: remoteInfo.name
|
|
854
|
+
}) {
|
|
686
855
|
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
856
|
+
const results = [];
|
|
687
857
|
if (host.options.inBrowser) {
|
|
688
858
|
entryAssets.forEach((asset) => {
|
|
689
|
-
const { moduleInfo } = asset;
|
|
690
|
-
|
|
691
|
-
if (module) getRemoteEntry({
|
|
692
|
-
origin: host,
|
|
693
|
-
remoteInfo: moduleInfo,
|
|
694
|
-
remoteEntryExports: module.remoteEntryExports
|
|
695
|
-
});
|
|
696
|
-
else getRemoteEntry({
|
|
697
|
-
origin: host,
|
|
698
|
-
remoteInfo: moduleInfo,
|
|
699
|
-
remoteEntryExports: void 0
|
|
700
|
-
});
|
|
859
|
+
const { moduleInfo: entryRemoteInfo } = asset;
|
|
860
|
+
results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
|
|
701
861
|
});
|
|
702
862
|
if (useLinkPreload) {
|
|
703
863
|
const defaultAttrs = {
|
|
@@ -705,21 +865,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
705
865
|
as: "style"
|
|
706
866
|
};
|
|
707
867
|
cssAssets.forEach((cssUrl) => {
|
|
708
|
-
|
|
868
|
+
results.push(waitForLinkPreload({
|
|
869
|
+
host,
|
|
870
|
+
remoteInfo,
|
|
709
871
|
url: cssUrl,
|
|
710
|
-
cb: () => {
|
|
711
|
-
},
|
|
712
872
|
attrs: defaultAttrs,
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
url,
|
|
716
|
-
attrs,
|
|
717
|
-
remoteInfo
|
|
718
|
-
});
|
|
719
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
720
|
-
}
|
|
721
|
-
});
|
|
722
|
-
needAttach && document.head.appendChild(cssEl);
|
|
873
|
+
context: createResourceContext(baseContext, "css")
|
|
874
|
+
}));
|
|
723
875
|
});
|
|
724
876
|
} else {
|
|
725
877
|
const defaultAttrs = {
|
|
@@ -727,22 +879,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
727
879
|
type: "text/css"
|
|
728
880
|
};
|
|
729
881
|
cssAssets.forEach((cssUrl) => {
|
|
730
|
-
|
|
882
|
+
results.push(waitForLinkPreload({
|
|
883
|
+
host,
|
|
884
|
+
remoteInfo,
|
|
731
885
|
url: cssUrl,
|
|
732
|
-
cb: () => {
|
|
733
|
-
},
|
|
734
886
|
attrs: defaultAttrs,
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
attrs,
|
|
739
|
-
remoteInfo
|
|
740
|
-
});
|
|
741
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
742
|
-
},
|
|
743
|
-
needDeleteLink: false
|
|
744
|
-
});
|
|
745
|
-
needAttach && document.head.appendChild(cssEl);
|
|
887
|
+
needDeleteLink: false,
|
|
888
|
+
context: createResourceContext(baseContext, "css")
|
|
889
|
+
}));
|
|
746
890
|
});
|
|
747
891
|
}
|
|
748
892
|
if (useLinkPreload) {
|
|
@@ -751,21 +895,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
751
895
|
as: "script"
|
|
752
896
|
};
|
|
753
897
|
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
754
|
-
|
|
898
|
+
results.push(waitForLinkPreload({
|
|
899
|
+
host,
|
|
900
|
+
remoteInfo,
|
|
755
901
|
url: jsUrl,
|
|
756
|
-
cb: () => {
|
|
757
|
-
},
|
|
758
902
|
attrs: defaultAttrs,
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
url,
|
|
762
|
-
attrs,
|
|
763
|
-
remoteInfo
|
|
764
|
-
});
|
|
765
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
766
|
-
}
|
|
767
|
-
});
|
|
768
|
-
needAttach && document.head.appendChild(linkEl);
|
|
903
|
+
context: createResourceContext(baseContext, "js")
|
|
904
|
+
}));
|
|
769
905
|
});
|
|
770
906
|
} else {
|
|
771
907
|
const defaultAttrs = {
|
|
@@ -773,25 +909,17 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
773
909
|
type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
|
|
774
910
|
};
|
|
775
911
|
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
776
|
-
|
|
912
|
+
results.push(waitForScriptPreload({
|
|
913
|
+
host,
|
|
914
|
+
remoteInfo,
|
|
777
915
|
url: jsUrl,
|
|
778
|
-
cb: () => {
|
|
779
|
-
},
|
|
780
916
|
attrs: defaultAttrs,
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
url,
|
|
784
|
-
attrs,
|
|
785
|
-
remoteInfo
|
|
786
|
-
});
|
|
787
|
-
if (res instanceof HTMLScriptElement) return res;
|
|
788
|
-
},
|
|
789
|
-
needDeleteScript: true
|
|
790
|
-
});
|
|
791
|
-
needAttach && document.head.appendChild(scriptEl);
|
|
917
|
+
context: createResourceContext(baseContext, "js")
|
|
918
|
+
}));
|
|
792
919
|
});
|
|
793
920
|
}
|
|
794
921
|
}
|
|
922
|
+
return Promise.all(results);
|
|
795
923
|
}
|
|
796
924
|
var helpers_default = {
|
|
797
925
|
utils: {
|
|
@@ -1987,17 +1987,17 @@ function getLoadedRemoteInfos(id, instance) {
|
|
|
1987
1987
|
};
|
|
1988
1988
|
}
|
|
1989
1989
|
export {
|
|
1990
|
-
|
|
1991
|
-
|
|
1990
|
+
setDataFetchItemLoadedStatus as A,
|
|
1991
|
+
warn as B,
|
|
1992
1992
|
CacheSize as C,
|
|
1993
1993
|
DATA_FETCH_QUERY as D,
|
|
1994
1994
|
ERROR_TYPE as E,
|
|
1995
1995
|
FS_HREF as F,
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
1996
|
+
DOWNGRADE_KEY as G,
|
|
1997
|
+
callAllDowngrade as H,
|
|
1998
|
+
callDowngrade as I,
|
|
1999
|
+
getDowngradeTag as J,
|
|
2000
|
+
composeKeyWithSeparator as K,
|
|
2001
2001
|
LOAD_REMOTE_ERROR_PREFIX as L,
|
|
2002
2002
|
MF_DATA_FETCH_STATUS as M,
|
|
2003
2003
|
getDataFetchCache as N,
|
|
@@ -2006,25 +2006,25 @@ export {
|
|
|
2006
2006
|
cache as c,
|
|
2007
2007
|
configureCache as d,
|
|
2008
2008
|
getDataFetchMap as e,
|
|
2009
|
-
|
|
2009
|
+
flushDataFetch as f,
|
|
2010
2010
|
generateKey as g,
|
|
2011
|
-
|
|
2011
|
+
fetchData as h,
|
|
2012
2012
|
initDataFetchMap as i,
|
|
2013
|
-
|
|
2014
|
-
|
|
2013
|
+
loadDataFetchModule as j,
|
|
2014
|
+
isDataLoaderExpose as k,
|
|
2015
2015
|
logger as l,
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2016
|
+
getDataFetchInfo as m,
|
|
2017
|
+
getDataFetchMapKey as n,
|
|
2018
|
+
getDataFetchItem as o,
|
|
2019
|
+
DATA_FETCH_CLIENT_SUFFIX as p,
|
|
2020
|
+
MF_DATA_FETCH_TYPE as q,
|
|
2021
2021
|
revalidateTag as r,
|
|
2022
2022
|
setSSREnv as s,
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2023
|
+
isCSROnly as t,
|
|
2024
|
+
isServerEnv as u,
|
|
2025
|
+
getDataFetchIdWithErrorMsgs as v,
|
|
2026
|
+
DATA_FETCH_ERROR_PREFIX as w,
|
|
2027
|
+
wrapDataFetchId as x,
|
|
2028
|
+
DATA_FETCH_FUNCTION as y,
|
|
2029
|
+
getLoadedRemoteInfos as z
|
|
2030
2030
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -75,6 +75,11 @@
|
|
|
75
75
|
"import": "./dist/data-fetch-utils.es.js",
|
|
76
76
|
"require": "./dist/data-fetch-utils.cjs.js"
|
|
77
77
|
},
|
|
78
|
+
"./data-fetch": {
|
|
79
|
+
"types": "./dist/data-fetch.d.ts",
|
|
80
|
+
"import": "./dist/data-fetch.es.js",
|
|
81
|
+
"require": "./dist/data-fetch.cjs.js"
|
|
82
|
+
},
|
|
78
83
|
"./data-fetch-server-middleware": {
|
|
79
84
|
"types": "./dist/data-fetch-server-middleware.d.ts",
|
|
80
85
|
"import": "./dist/data-fetch-server-middleware.es.js",
|
|
@@ -125,6 +130,9 @@
|
|
|
125
130
|
"data-fetch-utils": [
|
|
126
131
|
"./dist/data-fetch-utils.d.ts"
|
|
127
132
|
],
|
|
133
|
+
"data-fetch": [
|
|
134
|
+
"./dist/data-fetch.d.ts"
|
|
135
|
+
],
|
|
128
136
|
"data-fetch-server-middleware": [
|
|
129
137
|
"./dist/data-fetch-server-middleware.d.ts"
|
|
130
138
|
]
|
|
@@ -132,14 +140,13 @@
|
|
|
132
140
|
},
|
|
133
141
|
"dependencies": {
|
|
134
142
|
"lru-cache": "10.4.3",
|
|
135
|
-
"@module-federation/sdk": "2.
|
|
143
|
+
"@module-federation/sdk": "2.5.0"
|
|
136
144
|
},
|
|
137
145
|
"peerDependencies": {
|
|
138
146
|
"react": ">=16.9.0",
|
|
139
147
|
"react-dom": ">=16.9.0",
|
|
140
148
|
"react-router-dom": "^4 || ^5 || ^6 || ^7",
|
|
141
|
-
"react-router": "^6 || ^7"
|
|
142
|
-
"hono": "^4.12.7"
|
|
149
|
+
"react-router": "^6 || ^7"
|
|
143
150
|
},
|
|
144
151
|
"peerDependenciesMeta": {
|
|
145
152
|
"react-router-dom": {
|
|
@@ -147,9 +154,6 @@
|
|
|
147
154
|
},
|
|
148
155
|
"react-router": {
|
|
149
156
|
"optional": true
|
|
150
|
-
},
|
|
151
|
-
"hono": {
|
|
152
|
-
"optional": true
|
|
153
157
|
}
|
|
154
158
|
},
|
|
155
159
|
"devDependencies": {
|
|
@@ -170,9 +174,9 @@
|
|
|
170
174
|
"vite-plugin-dts": "^4.3.0",
|
|
171
175
|
"hono": "4.12.7",
|
|
172
176
|
"vitest": "1.6.0",
|
|
173
|
-
"@module-federation/
|
|
174
|
-
"@module-federation/
|
|
175
|
-
"@module-federation/runtime
|
|
177
|
+
"@module-federation/runtime-core": "2.5.0",
|
|
178
|
+
"@module-federation/bridge-shared": "2.5.0",
|
|
179
|
+
"@module-federation/runtime": "2.5.0"
|
|
176
180
|
},
|
|
177
181
|
"scripts": {
|
|
178
182
|
"dev": "vite",
|