@module-federation/bridge-react 2.3.3 → 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 +18 -10
- package/.turbo/turbo-build.log +0 -85
- package/CHANGELOG.md +0 -839
- package/__tests__/bridge.spec.tsx +0 -160
- package/__tests__/createLazyComponent.spec.tsx +0 -209
- package/__tests__/prefetch.spec.ts +0 -156
- package/__tests__/router.spec.tsx +0 -82
- package/__tests__/setupTests.ts +0 -8
- package/__tests__/util.ts +0 -36
- package/jest.config.ts +0 -21
- package/src/base.ts +0 -50
- package/src/index.ts +0 -50
- package/src/lazy/AwaitDataFetch.tsx +0 -217
- package/src/lazy/constant.ts +0 -30
- package/src/lazy/createLazyComponent.tsx +0 -411
- package/src/lazy/data-fetch/cache.ts +0 -291
- package/src/lazy/data-fetch/call-data-fetch.ts +0 -13
- package/src/lazy/data-fetch/data-fetch-server-middleware.ts +0 -196
- package/src/lazy/data-fetch/index.ts +0 -16
- package/src/lazy/data-fetch/inject-data-fetch.ts +0 -109
- package/src/lazy/data-fetch/prefetch.ts +0 -112
- package/src/lazy/data-fetch/runtime-plugin.ts +0 -115
- package/src/lazy/index.ts +0 -35
- package/src/lazy/logger.ts +0 -6
- package/src/lazy/types.ts +0 -75
- package/src/lazy/utils.ts +0 -375
- package/src/lazy/wrapNoSSR.tsx +0 -10
- package/src/modern-app-env.d.ts +0 -2
- package/src/plugins/lazy-load-component-plugin.spec.ts +0 -21
- package/src/plugins/lazy-load-component-plugin.ts +0 -57
- package/src/provider/context.tsx +0 -4
- package/src/provider/plugin.ts +0 -22
- package/src/provider/versions/bridge-base.tsx +0 -153
- package/src/provider/versions/legacy.ts +0 -87
- package/src/provider/versions/v18.ts +0 -47
- package/src/provider/versions/v19.ts +0 -48
- package/src/remote/RemoteAppWrapper.tsx +0 -108
- package/src/remote/base-component/component.tsx +0 -2
- package/src/remote/base-component/create.tsx +0 -23
- package/src/remote/base-component/index.tsx +0 -10
- package/src/remote/createHelpers.tsx +0 -132
- package/src/remote/router-component/component.tsx +0 -104
- package/src/remote/router-component/create.tsx +0 -23
- package/src/remote/router-component/index.tsx +0 -10
- package/src/router/default.tsx +0 -73
- package/src/router/v5.tsx +0 -43
- package/src/router/v6.tsx +0 -74
- package/src/router/v7.tsx +0 -75
- package/src/types.ts +0 -147
- package/src/utils/index.ts +0 -44
- package/src/v18.ts +0 -9
- package/src/v19.ts +0 -9
- package/tsconfig.json +0 -42
- package/tsconfig.node.json +0 -11
- package/tsconfig.spec.json +0 -26
- package/vite.config.ts +0 -112
- package/vitest.config.ts +0 -27
|
@@ -105,6 +105,8 @@ function createScript(info) {
|
|
|
105
105
|
function createLink(info) {
|
|
106
106
|
let link = null;
|
|
107
107
|
let needAttach = true;
|
|
108
|
+
let timeout = 2e4;
|
|
109
|
+
let timeoutId;
|
|
108
110
|
const links = document.getElementsByTagName("link");
|
|
109
111
|
for (let i = 0; i < links.length; i++) {
|
|
110
112
|
const l = links[i];
|
|
@@ -120,19 +122,42 @@ function createLink(info) {
|
|
|
120
122
|
link = document.createElement("link");
|
|
121
123
|
link.setAttribute("href", info.url);
|
|
122
124
|
let createLinkRes = void 0;
|
|
125
|
+
let shouldApplyAttrs = true;
|
|
123
126
|
const attrs = info.attrs;
|
|
124
127
|
if (info.createLinkHook) {
|
|
125
128
|
createLinkRes = info.createLinkHook(info.url, attrs);
|
|
126
|
-
if (createLinkRes instanceof HTMLLinkElement)
|
|
129
|
+
if (createLinkRes instanceof HTMLLinkElement) {
|
|
130
|
+
link = createLinkRes;
|
|
131
|
+
shouldApplyAttrs = false;
|
|
132
|
+
} else if (typeof createLinkRes === "object") {
|
|
133
|
+
if ("link" in createLinkRes && createLinkRes.link) {
|
|
134
|
+
link = createLinkRes.link;
|
|
135
|
+
shouldApplyAttrs = false;
|
|
136
|
+
}
|
|
137
|
+
if ("timeout" in createLinkRes && createLinkRes.timeout) timeout = createLinkRes.timeout;
|
|
138
|
+
}
|
|
127
139
|
}
|
|
128
|
-
if (attrs &&
|
|
140
|
+
if (attrs && shouldApplyAttrs) Object.keys(attrs).forEach((name) => {
|
|
129
141
|
if (link && !link.getAttribute(name)) link.setAttribute(name, attrs[name]);
|
|
130
142
|
});
|
|
131
143
|
}
|
|
144
|
+
if (!needAttach) {
|
|
145
|
+
Promise.resolve().then(() => {
|
|
146
|
+
(info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
link,
|
|
150
|
+
needAttach
|
|
151
|
+
};
|
|
152
|
+
}
|
|
132
153
|
const onLinkComplete = (prev, event) => {
|
|
154
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
133
155
|
const onLinkCompleteCallback = () => {
|
|
134
|
-
if ((event == null ? void 0 : event.type) === "error")
|
|
135
|
-
|
|
156
|
+
if ((event == null ? void 0 : event.type) === "error") {
|
|
157
|
+
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.`);
|
|
158
|
+
linkError.name = "LinkNetworkError";
|
|
159
|
+
(info == null ? void 0 : info.onErrorCallback) && (info == null ? void 0 : info.onErrorCallback(linkError));
|
|
160
|
+
} else (info == null ? void 0 : info.cb) && (info == null ? void 0 : info.cb());
|
|
136
161
|
};
|
|
137
162
|
if (link) {
|
|
138
163
|
link.onerror = null;
|
|
@@ -151,6 +176,12 @@ function createLink(info) {
|
|
|
151
176
|
};
|
|
152
177
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
153
178
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
179
|
+
timeoutId = setTimeout(() => {
|
|
180
|
+
onLinkComplete(null, {
|
|
181
|
+
type: "error",
|
|
182
|
+
isTimeout: true
|
|
183
|
+
});
|
|
184
|
+
}, timeout);
|
|
154
185
|
return {
|
|
155
186
|
link,
|
|
156
187
|
needAttach
|
|
@@ -494,6 +525,9 @@ const RUNTIME_009 = "RUNTIME-009";
|
|
|
494
525
|
const RUNTIME_010 = "RUNTIME-010";
|
|
495
526
|
const RUNTIME_011 = "RUNTIME-011";
|
|
496
527
|
const RUNTIME_012 = "RUNTIME-012";
|
|
528
|
+
const RUNTIME_013 = "RUNTIME-013";
|
|
529
|
+
const RUNTIME_014 = "RUNTIME-014";
|
|
530
|
+
const RUNTIME_015 = "RUNTIME-015";
|
|
497
531
|
const runtimeDescMap = {
|
|
498
532
|
[RUNTIME_001]: "Failed to get remoteEntry exports.",
|
|
499
533
|
[RUNTIME_002]: 'The remote entry interface does not contain "init"',
|
|
@@ -506,7 +540,10 @@ const runtimeDescMap = {
|
|
|
506
540
|
[RUNTIME_009]: "Please call createInstance first.",
|
|
507
541
|
[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.',
|
|
508
542
|
[RUNTIME_011]: "The remoteEntry URL is missing from the remote snapshot.",
|
|
509
|
-
[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_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.',
|
|
544
|
+
[RUNTIME_013]: "The manifest is not a valid Module Federation manifest.",
|
|
545
|
+
[RUNTIME_014]: "The remote does not expose the requested module.",
|
|
546
|
+
[RUNTIME_015]: "Remote container initialization failed."
|
|
510
547
|
};
|
|
511
548
|
({
|
|
512
549
|
...runtimeDescMap
|
|
@@ -547,7 +584,7 @@ function handleRemoteEntryLoaded(name, globalName, entry) {
|
|
|
547
584
|
});
|
|
548
585
|
return entryExports;
|
|
549
586
|
}
|
|
550
|
-
async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl }) {
|
|
587
|
+
async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook, getEntryUrl, resourceContext }) {
|
|
551
588
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
552
589
|
if (remoteEntryExports) return remoteEntryExports;
|
|
553
590
|
const url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
@@ -557,7 +594,11 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
557
594
|
const res = loaderHook.lifecycle.createScript.emit({
|
|
558
595
|
url: url2,
|
|
559
596
|
attrs,
|
|
560
|
-
remoteInfo
|
|
597
|
+
remoteInfo,
|
|
598
|
+
resourceContext: resourceContext ? {
|
|
599
|
+
...resourceContext,
|
|
600
|
+
url: url2
|
|
601
|
+
} : void 0
|
|
561
602
|
});
|
|
562
603
|
if (!res) return;
|
|
563
604
|
if (res instanceof HTMLScriptElement) return res;
|
|
@@ -573,7 +614,7 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
573
614
|
}, originalMsg);
|
|
574
615
|
});
|
|
575
616
|
}
|
|
576
|
-
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl }) {
|
|
617
|
+
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
|
|
577
618
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
578
619
|
switch (type) {
|
|
579
620
|
case "esm":
|
|
@@ -594,11 +635,12 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEnt
|
|
|
594
635
|
name,
|
|
595
636
|
remoteInfo,
|
|
596
637
|
loaderHook,
|
|
597
|
-
getEntryUrl
|
|
638
|
+
getEntryUrl,
|
|
639
|
+
resourceContext
|
|
598
640
|
});
|
|
599
641
|
}
|
|
600
642
|
}
|
|
601
|
-
async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
643
|
+
async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
|
|
602
644
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
603
645
|
const { entryExports: remoteEntryExports } = getRemoteEntryExports(name, globalName);
|
|
604
646
|
if (remoteEntryExports) return remoteEntryExports;
|
|
@@ -612,7 +654,11 @@ async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
|
612
654
|
const res = loaderHook.lifecycle.createScript.emit({
|
|
613
655
|
url,
|
|
614
656
|
attrs,
|
|
615
|
-
remoteInfo
|
|
657
|
+
remoteInfo,
|
|
658
|
+
resourceContext: resourceContext ? {
|
|
659
|
+
...resourceContext,
|
|
660
|
+
url
|
|
661
|
+
} : void 0
|
|
616
662
|
});
|
|
617
663
|
if (!res) return;
|
|
618
664
|
if ("url" in res) return res;
|
|
@@ -628,13 +674,14 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
628
674
|
return lazyUtils.composeKeyWithSeparator(name, entry);
|
|
629
675
|
}
|
|
630
676
|
async function getRemoteEntry(params) {
|
|
631
|
-
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
|
|
677
|
+
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, resourceContext, _inErrorHandling = false } = params;
|
|
632
678
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
633
679
|
if (remoteEntryExports) return remoteEntryExports;
|
|
634
680
|
if (!globalLoading[uniqueKey]) {
|
|
635
681
|
const loadEntryHook = origin.remoteHandler.hooks.lifecycle.loadEntry;
|
|
636
682
|
const loaderHook = origin.loaderHook;
|
|
637
683
|
globalLoading[uniqueKey] = loadEntryHook.emit({
|
|
684
|
+
origin,
|
|
638
685
|
loaderHook,
|
|
639
686
|
remoteInfo,
|
|
640
687
|
remoteEntryExports
|
|
@@ -644,11 +691,20 @@ async function getRemoteEntry(params) {
|
|
|
644
691
|
remoteInfo,
|
|
645
692
|
remoteEntryExports,
|
|
646
693
|
loaderHook,
|
|
647
|
-
getEntryUrl
|
|
694
|
+
getEntryUrl,
|
|
695
|
+
resourceContext
|
|
648
696
|
}) : loadEntryNode({
|
|
649
697
|
remoteInfo,
|
|
650
|
-
loaderHook
|
|
698
|
+
loaderHook,
|
|
699
|
+
resourceContext
|
|
651
700
|
});
|
|
701
|
+
}).then(async (res) => {
|
|
702
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
703
|
+
origin,
|
|
704
|
+
remoteInfo,
|
|
705
|
+
remoteEntryExports: res
|
|
706
|
+
});
|
|
707
|
+
return res;
|
|
652
708
|
}).catch(async (err) => {
|
|
653
709
|
const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
|
|
654
710
|
const isScriptExecutionError = err instanceof Error && err.message.includes("ScriptExecutionError");
|
|
@@ -667,8 +723,21 @@ async function getRemoteEntry(params) {
|
|
|
667
723
|
globalLoading,
|
|
668
724
|
uniqueKey: uniqueKey2
|
|
669
725
|
});
|
|
670
|
-
if (RemoteEntryExports)
|
|
726
|
+
if (RemoteEntryExports) {
|
|
727
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
728
|
+
origin,
|
|
729
|
+
remoteInfo,
|
|
730
|
+
remoteEntryExports: RemoteEntryExports,
|
|
731
|
+
recovered: true
|
|
732
|
+
});
|
|
733
|
+
return RemoteEntryExports;
|
|
734
|
+
}
|
|
671
735
|
}
|
|
736
|
+
await origin.loaderHook.lifecycle.afterLoadEntry.emit({
|
|
737
|
+
origin,
|
|
738
|
+
remoteInfo,
|
|
739
|
+
error: err
|
|
740
|
+
});
|
|
672
741
|
throw err;
|
|
673
742
|
});
|
|
674
743
|
}
|
|
@@ -683,22 +752,113 @@ function getRemoteInfo(remote) {
|
|
|
683
752
|
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
684
753
|
};
|
|
685
754
|
}
|
|
686
|
-
function
|
|
755
|
+
function isTimeoutError(error2) {
|
|
756
|
+
if (!(error2 instanceof Error)) return false;
|
|
757
|
+
return error2.message.includes("timed out") || error2.name.includes("Timeout");
|
|
758
|
+
}
|
|
759
|
+
function createAssetResult(context, url, status, error2) {
|
|
760
|
+
return {
|
|
761
|
+
url,
|
|
762
|
+
status,
|
|
763
|
+
resourceType: context.resourceType,
|
|
764
|
+
initiator: context.initiator,
|
|
765
|
+
id: context.id,
|
|
766
|
+
error: error2
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
async function waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, context) {
|
|
770
|
+
const cachedRemote = host.moduleCache.get(entryRemoteInfo.name);
|
|
771
|
+
const url = entryRemoteInfo.entry;
|
|
772
|
+
if (cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports) return createAssetResult(context, url, "cached");
|
|
773
|
+
try {
|
|
774
|
+
if (!await getRemoteEntry({
|
|
775
|
+
origin: host,
|
|
776
|
+
remoteInfo: entryRemoteInfo,
|
|
777
|
+
remoteEntryExports: cachedRemote == null ? void 0 : cachedRemote.remoteEntryExports,
|
|
778
|
+
resourceContext: {
|
|
779
|
+
...context,
|
|
780
|
+
url
|
|
781
|
+
}
|
|
782
|
+
})) throw new Error(`Failed to load remoteEntry "${url}".`);
|
|
783
|
+
return createAssetResult(context, url, "success");
|
|
784
|
+
} catch (error2) {
|
|
785
|
+
return createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function waitForLinkPreload({ host, remoteInfo, url, attrs, context, needDeleteLink }) {
|
|
789
|
+
return new Promise((resolve) => {
|
|
790
|
+
const { link, needAttach } = createLink({
|
|
791
|
+
url,
|
|
792
|
+
cb: () => {
|
|
793
|
+
resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
|
|
794
|
+
},
|
|
795
|
+
onErrorCallback: (error2) => {
|
|
796
|
+
resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));
|
|
797
|
+
},
|
|
798
|
+
attrs,
|
|
799
|
+
createLinkHook: (hookUrl, hookAttrs) => {
|
|
800
|
+
const res = host.loaderHook.lifecycle.createLink.emit({
|
|
801
|
+
url: hookUrl,
|
|
802
|
+
attrs: hookAttrs,
|
|
803
|
+
remoteInfo,
|
|
804
|
+
resourceContext: {
|
|
805
|
+
...context,
|
|
806
|
+
url: hookUrl
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
if (res instanceof HTMLLinkElement) return res;
|
|
810
|
+
return res;
|
|
811
|
+
},
|
|
812
|
+
needDeleteLink
|
|
813
|
+
});
|
|
814
|
+
needAttach && document.head.appendChild(link);
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
function waitForScriptPreload({ host, remoteInfo, url, attrs, context }) {
|
|
818
|
+
return new Promise((resolve) => {
|
|
819
|
+
const { script, needAttach } = createScript({
|
|
820
|
+
url,
|
|
821
|
+
cb: () => {
|
|
822
|
+
resolve(createAssetResult(context, url, needAttach ? "success" : "cached"));
|
|
823
|
+
},
|
|
824
|
+
onErrorCallback: (error2) => {
|
|
825
|
+
resolve(createAssetResult(context, url, isTimeoutError(error2) ? "timeout" : "error", error2));
|
|
826
|
+
},
|
|
827
|
+
attrs,
|
|
828
|
+
createScriptHook: (hookUrl, hookAttrs) => {
|
|
829
|
+
const res = host.loaderHook.lifecycle.createScript.emit({
|
|
830
|
+
url: hookUrl,
|
|
831
|
+
attrs: hookAttrs,
|
|
832
|
+
remoteInfo,
|
|
833
|
+
resourceContext: {
|
|
834
|
+
...context,
|
|
835
|
+
url: hookUrl
|
|
836
|
+
}
|
|
837
|
+
});
|
|
838
|
+
if (res instanceof HTMLScriptElement) return res;
|
|
839
|
+
return res;
|
|
840
|
+
},
|
|
841
|
+
needDeleteScript: true
|
|
842
|
+
});
|
|
843
|
+
needAttach && document.head.appendChild(script);
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
function createResourceContext(baseContext, resourceType) {
|
|
847
|
+
return {
|
|
848
|
+
...baseContext,
|
|
849
|
+
resourceType
|
|
850
|
+
};
|
|
851
|
+
}
|
|
852
|
+
function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseContext = {
|
|
853
|
+
initiator: "preloadRemote",
|
|
854
|
+
id: remoteInfo.name
|
|
855
|
+
}) {
|
|
687
856
|
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
857
|
+
const results = [];
|
|
688
858
|
if (host.options.inBrowser) {
|
|
689
859
|
entryAssets.forEach((asset) => {
|
|
690
|
-
const { moduleInfo } = asset;
|
|
691
|
-
|
|
692
|
-
if (module2) getRemoteEntry({
|
|
693
|
-
origin: host,
|
|
694
|
-
remoteInfo: moduleInfo,
|
|
695
|
-
remoteEntryExports: module2.remoteEntryExports
|
|
696
|
-
});
|
|
697
|
-
else getRemoteEntry({
|
|
698
|
-
origin: host,
|
|
699
|
-
remoteInfo: moduleInfo,
|
|
700
|
-
remoteEntryExports: void 0
|
|
701
|
-
});
|
|
860
|
+
const { moduleInfo: entryRemoteInfo } = asset;
|
|
861
|
+
results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
|
|
702
862
|
});
|
|
703
863
|
if (useLinkPreload) {
|
|
704
864
|
const defaultAttrs = {
|
|
@@ -706,21 +866,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
706
866
|
as: "style"
|
|
707
867
|
};
|
|
708
868
|
cssAssets.forEach((cssUrl) => {
|
|
709
|
-
|
|
869
|
+
results.push(waitForLinkPreload({
|
|
870
|
+
host,
|
|
871
|
+
remoteInfo,
|
|
710
872
|
url: cssUrl,
|
|
711
|
-
cb: () => {
|
|
712
|
-
},
|
|
713
873
|
attrs: defaultAttrs,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
url,
|
|
717
|
-
attrs,
|
|
718
|
-
remoteInfo
|
|
719
|
-
});
|
|
720
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
needAttach && document.head.appendChild(cssEl);
|
|
874
|
+
context: createResourceContext(baseContext, "css")
|
|
875
|
+
}));
|
|
724
876
|
});
|
|
725
877
|
} else {
|
|
726
878
|
const defaultAttrs = {
|
|
@@ -728,22 +880,14 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
728
880
|
type: "text/css"
|
|
729
881
|
};
|
|
730
882
|
cssAssets.forEach((cssUrl) => {
|
|
731
|
-
|
|
883
|
+
results.push(waitForLinkPreload({
|
|
884
|
+
host,
|
|
885
|
+
remoteInfo,
|
|
732
886
|
url: cssUrl,
|
|
733
|
-
cb: () => {
|
|
734
|
-
},
|
|
735
887
|
attrs: defaultAttrs,
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
attrs,
|
|
740
|
-
remoteInfo
|
|
741
|
-
});
|
|
742
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
743
|
-
},
|
|
744
|
-
needDeleteLink: false
|
|
745
|
-
});
|
|
746
|
-
needAttach && document.head.appendChild(cssEl);
|
|
888
|
+
needDeleteLink: false,
|
|
889
|
+
context: createResourceContext(baseContext, "css")
|
|
890
|
+
}));
|
|
747
891
|
});
|
|
748
892
|
}
|
|
749
893
|
if (useLinkPreload) {
|
|
@@ -752,21 +896,13 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
752
896
|
as: "script"
|
|
753
897
|
};
|
|
754
898
|
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
755
|
-
|
|
899
|
+
results.push(waitForLinkPreload({
|
|
900
|
+
host,
|
|
901
|
+
remoteInfo,
|
|
756
902
|
url: jsUrl,
|
|
757
|
-
cb: () => {
|
|
758
|
-
},
|
|
759
903
|
attrs: defaultAttrs,
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
url,
|
|
763
|
-
attrs,
|
|
764
|
-
remoteInfo
|
|
765
|
-
});
|
|
766
|
-
if (res instanceof HTMLLinkElement) return res;
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
needAttach && document.head.appendChild(linkEl);
|
|
904
|
+
context: createResourceContext(baseContext, "js")
|
|
905
|
+
}));
|
|
770
906
|
});
|
|
771
907
|
} else {
|
|
772
908
|
const defaultAttrs = {
|
|
@@ -774,25 +910,17 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
|
774
910
|
type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
|
|
775
911
|
};
|
|
776
912
|
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
777
|
-
|
|
913
|
+
results.push(waitForScriptPreload({
|
|
914
|
+
host,
|
|
915
|
+
remoteInfo,
|
|
778
916
|
url: jsUrl,
|
|
779
|
-
cb: () => {
|
|
780
|
-
},
|
|
781
917
|
attrs: defaultAttrs,
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
url,
|
|
785
|
-
attrs,
|
|
786
|
-
remoteInfo
|
|
787
|
-
});
|
|
788
|
-
if (res instanceof HTMLScriptElement) return res;
|
|
789
|
-
},
|
|
790
|
-
needDeleteScript: true
|
|
791
|
-
});
|
|
792
|
-
needAttach && document.head.appendChild(scriptEl);
|
|
918
|
+
context: createResourceContext(baseContext, "js")
|
|
919
|
+
}));
|
|
793
920
|
});
|
|
794
921
|
}
|
|
795
922
|
}
|
|
923
|
+
return Promise.all(results);
|
|
796
924
|
}
|
|
797
925
|
var helpers_default = {
|
|
798
926
|
utils: {
|