@module-federation/bridge-react 2.8.0 → 2.8.2
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 +2 -2
- package/dist/data-fetch-utils.cjs.js +1 -1
- package/dist/data-fetch-utils.es.js +2 -2
- package/dist/data-fetch.cjs.js +2 -2
- package/dist/data-fetch.es.js +2 -2
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +2 -2
- package/dist/lazy/HydratedStylesheetAssets.d.ts +4 -0
- package/dist/lazy/createLazyComponent.d.ts +1 -1
- package/dist/{lazy-load-component-plugin-DEu-DfZt.mjs → lazy-load-component-plugin-DQFjLSsW.mjs} +170 -44
- package/dist/{lazy-load-component-plugin-FKp6nQa-.js → lazy-load-component-plugin-DeTbkGlM.js} +169 -43
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/{prefetch-CTZuFBqh.mjs → prefetch-BJZbf9LF.mjs} +77 -55
- package/dist/{prefetch-D66kL1aM.js → prefetch-CfMDdqO-.js} +77 -55
- package/package.json +5 -5
package/dist/base.cjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const createHelpers = require("./createHelpers-19BP0xtB.js");
|
|
4
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
|
|
5
5
|
const lazyUtils = require("./utils-5dGErM3C.js");
|
|
6
6
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
7
|
-
const prefetch = require("./prefetch-
|
|
7
|
+
const prefetch = require("./prefetch-CfMDdqO-.js");
|
|
8
8
|
const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
|
|
9
9
|
const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
|
|
10
10
|
createRemoteAppComponent
|
package/dist/base.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } from "./createHelpers-BSHeKyd-.mjs";
|
|
2
2
|
import { b } from "./createHelpers-BSHeKyd-.mjs";
|
|
3
|
-
import { a, c, b as b2, l } from "./lazy-load-component-plugin-
|
|
3
|
+
import { a, c, b as b2, l } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
|
|
4
4
|
import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-BBP3hEeV.mjs";
|
|
5
5
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
6
|
-
import { p } from "./prefetch-
|
|
6
|
+
import { p } from "./prefetch-BJZbf9LF.mjs";
|
|
7
7
|
const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
|
|
8
8
|
const createRemoteComponent = createDeprecatedRemoteComponentFactory(
|
|
9
9
|
createRemoteAppComponent
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const lazyUtils = require("./utils-5dGErM3C.js");
|
|
4
|
-
const prefetch = require("./prefetch-
|
|
4
|
+
const prefetch = require("./prefetch-CfMDdqO-.js");
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { y as DATA_FETCH_FUNCTION } from "./utils-BBP3hEeV.mjs";
|
|
2
2
|
import { C, a, c, b, d, g, r } from "./utils-BBP3hEeV.mjs";
|
|
3
|
-
import { d as dataFetchFunction } from "./prefetch-
|
|
4
|
-
import { i, p } from "./prefetch-
|
|
3
|
+
import { d as dataFetchFunction } from "./prefetch-BJZbf9LF.mjs";
|
|
4
|
+
import { i, p } from "./prefetch-BJZbf9LF.mjs";
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
package/dist/data-fetch.cjs.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
3
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
|
|
4
4
|
const lazyUtils = require("./utils-5dGErM3C.js");
|
|
5
5
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
6
|
-
const prefetch = require("./prefetch-
|
|
6
|
+
const prefetch = require("./prefetch-CfMDdqO-.js");
|
|
7
7
|
exports.autoFetchDataPlugin = lazyLoadComponentPlugin.autoFetchData;
|
|
8
8
|
exports.collectSSRAssets = lazyLoadComponentPlugin.collectSSRAssets;
|
|
9
9
|
exports.createLazyComponent = lazyLoadComponentPlugin.createLazyComponent;
|
package/dist/data-fetch.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a, c, b, l } from "./lazy-load-component-plugin-
|
|
1
|
+
import { a, c, b, l } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
|
|
2
2
|
import { C, a as a2, E, c as c2, b as b2, d, f, g, r, s } from "./utils-BBP3hEeV.mjs";
|
|
3
3
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
4
|
-
import { p } from "./prefetch-
|
|
4
|
+
import { p } from "./prefetch-BJZbf9LF.mjs";
|
|
5
5
|
export {
|
|
6
6
|
C as CacheSize,
|
|
7
7
|
a2 as CacheTime,
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const createHelpers = require("./createHelpers-19BP0xtB.js");
|
|
4
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
|
|
5
5
|
const lazyUtils = require("./utils-5dGErM3C.js");
|
|
6
6
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
7
7
|
const React = require("react");
|
|
8
8
|
const ReactRouterDOM = require("react-router-dom");
|
|
9
9
|
const index = require("./index-DbjGCKOr.js");
|
|
10
|
-
const prefetch = require("./prefetch-
|
|
10
|
+
const prefetch = require("./prefetch-CfMDdqO-.js");
|
|
11
11
|
function _interopNamespaceDefault(e2) {
|
|
12
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
13
|
if (e2) {
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-BSHeKyd-.mjs";
|
|
2
2
|
import { b } from "./createHelpers-BSHeKyd-.mjs";
|
|
3
|
-
import { a, c, b as b2, l } from "./lazy-load-component-plugin-
|
|
3
|
+
import { a, c, b as b2, l } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
|
|
4
4
|
import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-BBP3hEeV.mjs";
|
|
5
5
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
6
6
|
import React__default, { forwardRef, useContext, useState, useEffect } from "react";
|
|
7
7
|
import * as ReactRouterDOM from "react-router-dom";
|
|
8
8
|
import { p as pathJoin, L as LoggerInstance } from "./index-Bs2NxD2z.mjs";
|
|
9
|
-
import { p } from "./prefetch-
|
|
9
|
+
import { p } from "./prefetch-BJZbf9LF.mjs";
|
|
10
10
|
function e() {
|
|
11
11
|
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
12
12
|
window.dispatchEvent(t);
|
|
@@ -23,6 +23,6 @@ export type CreateLazyComponentOptions<T, E extends keyof T> = {
|
|
|
23
23
|
type ReactKey = {
|
|
24
24
|
key?: React.Key | null;
|
|
25
25
|
};
|
|
26
|
-
export declare function collectSSRAssets(options: IProps): ReactNode[];
|
|
26
|
+
export declare function collectSSRAssets(options: IProps): React.ReactNode[];
|
|
27
27
|
export declare function createLazyComponent<T, E extends keyof T>(options: CreateLazyComponentOptions<T, E>): (props: T[E] extends (...args: any) => any ? Parameters<T[E]>[0] extends undefined ? ReactKey : Parameters<T[E]>[0] & ReactKey : ReactKey) => React.JSX.Element;
|
|
28
28
|
export {};
|
package/dist/{lazy-load-component-plugin-DEu-DfZt.mjs → lazy-load-component-plugin-DQFjLSsW.mjs}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as injectDataFetch, p as prefetch } from "./prefetch-
|
|
1
|
+
import { i as injectDataFetch, p as prefetch } from "./prefetch-BJZbf9LF.mjs";
|
|
2
2
|
import { i as initDataFetchMap, k as isDataLoaderExpose, m as getDataFetchInfo, n as getDataFetchMapKey, l as logger, o as getDataFetchItem, p as DATA_FETCH_CLIENT_SUFFIX, q as MF_DATA_FETCH_TYPE, t as isCSROnly, M as MF_DATA_FETCH_STATUS, j as loadDataFetchModule, e as getDataFetchMap, u as isServerEnv, v as getDataFetchIdWithErrorMsgs, w as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, x as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, y as DATA_FETCH_FUNCTION, z as getLoadedRemoteInfos, h as fetchData$1, A as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-BBP3hEeV.mjs";
|
|
3
|
-
import React__default, { useRef, useState,
|
|
3
|
+
import React__default, { useRef, useState, useEffect, Suspense } from "react";
|
|
4
4
|
const autoFetchData = () => {
|
|
5
5
|
initDataFetchMap();
|
|
6
6
|
injectDataFetch();
|
|
@@ -69,6 +69,142 @@ const autoFetchData = () => {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
+
const EMPTY_HREFS = /* @__PURE__ */ new Set();
|
|
73
|
+
const stylesheetStores = /* @__PURE__ */ new WeakMap();
|
|
74
|
+
function isActiveStylesheet(link) {
|
|
75
|
+
const rel = link.rel.toLowerCase().split(/\s+/u);
|
|
76
|
+
const media = link.media.trim().toLowerCase();
|
|
77
|
+
const type = link.type.trim().toLowerCase().split(";", 1)[0].trim();
|
|
78
|
+
return rel.includes("stylesheet") && !rel.includes("alternate") && !link.disabled && !link.hasAttribute("disabled") && (!media || media === "all") && (!type || type === "text/css");
|
|
79
|
+
}
|
|
80
|
+
function collectHeadStylesheetHrefs(document) {
|
|
81
|
+
var _a;
|
|
82
|
+
const hrefs = /* @__PURE__ */ new Set();
|
|
83
|
+
(_a = document.head) == null ? void 0 : _a.querySelectorAll("link[href]").forEach((link) => {
|
|
84
|
+
if (isActiveStylesheet(link)) {
|
|
85
|
+
hrefs.add(link.href);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
return hrefs;
|
|
89
|
+
}
|
|
90
|
+
function haveSameHrefs(current, next) {
|
|
91
|
+
if (current.size !== next.size) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
for (const href of current) {
|
|
95
|
+
if (!next.has(href)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
function observeHead(store) {
|
|
102
|
+
store.observer.disconnect();
|
|
103
|
+
const { document, head, observer } = store;
|
|
104
|
+
if (head) {
|
|
105
|
+
observer.observe(head, {
|
|
106
|
+
attributes: true,
|
|
107
|
+
attributeFilter: ["disabled", "href", "media", "rel", "type"],
|
|
108
|
+
childList: true,
|
|
109
|
+
subtree: true
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if (document.documentElement) {
|
|
113
|
+
observer.observe(document.documentElement, { childList: true });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function refreshHeadStylesheets(store) {
|
|
117
|
+
if (!store.subscribers.size) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const head = store.document.head;
|
|
121
|
+
if (head !== store.head) {
|
|
122
|
+
store.head = head;
|
|
123
|
+
observeHead(store);
|
|
124
|
+
}
|
|
125
|
+
const hrefs = collectHeadStylesheetHrefs(store.document);
|
|
126
|
+
if (haveSameHrefs(store.hrefs, hrefs)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
store.hrefs = hrefs;
|
|
130
|
+
store.subscribers.forEach((subscriber) => subscriber(hrefs));
|
|
131
|
+
}
|
|
132
|
+
function getStylesheetStore(document) {
|
|
133
|
+
var _a;
|
|
134
|
+
const current = stylesheetStores.get(document);
|
|
135
|
+
if (current) {
|
|
136
|
+
return current;
|
|
137
|
+
}
|
|
138
|
+
const MutationObserver = ((_a = document.defaultView) == null ? void 0 : _a.MutationObserver) ?? globalThis.MutationObserver;
|
|
139
|
+
let store;
|
|
140
|
+
const observer = new MutationObserver(() => refreshHeadStylesheets(store));
|
|
141
|
+
store = {
|
|
142
|
+
document,
|
|
143
|
+
head: document.head,
|
|
144
|
+
hrefs: collectHeadStylesheetHrefs(document),
|
|
145
|
+
observer,
|
|
146
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
147
|
+
};
|
|
148
|
+
observeHead(store);
|
|
149
|
+
stylesheetStores.set(document, store);
|
|
150
|
+
return store;
|
|
151
|
+
}
|
|
152
|
+
function subscribeToHeadStylesheets(document, subscriber) {
|
|
153
|
+
const store = getStylesheetStore(document);
|
|
154
|
+
let subscribed = true;
|
|
155
|
+
store.subscribers.add(subscriber);
|
|
156
|
+
subscriber(store.hrefs);
|
|
157
|
+
return () => {
|
|
158
|
+
if (!subscribed) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
subscribed = false;
|
|
162
|
+
store.subscribers.delete(subscriber);
|
|
163
|
+
if (!store.subscribers.size) {
|
|
164
|
+
store.observer.disconnect();
|
|
165
|
+
if (stylesheetStores.get(document) === store) {
|
|
166
|
+
stylesheetStores.delete(document);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
function resolveHref(href, document) {
|
|
172
|
+
try {
|
|
173
|
+
return new URL(href, document.baseURI).href;
|
|
174
|
+
} catch {
|
|
175
|
+
return href;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function HydratedStylesheetAssets({ hrefs }) {
|
|
179
|
+
const firstLinkRef = useRef(null);
|
|
180
|
+
const ownerDocumentRef = useRef(null);
|
|
181
|
+
const [headHrefs, setHeadHrefs] = useState(EMPTY_HREFS);
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
var _a;
|
|
184
|
+
const link = firstLinkRef.current;
|
|
185
|
+
if (!link) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const ownerDocument = link.ownerDocument;
|
|
189
|
+
ownerDocumentRef.current = ownerDocument;
|
|
190
|
+
if (link.getRootNode() !== ownerDocument || ((_a = ownerDocument.head) == null ? void 0 : _a.contains(link))) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
return subscribeToHeadStylesheets(ownerDocument, setHeadHrefs);
|
|
194
|
+
}, []);
|
|
195
|
+
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, hrefs.map(
|
|
196
|
+
(href, index) => ownerDocumentRef.current && headHrefs.has(resolveHref(href, ownerDocumentRef.current)) ? null : /* @__PURE__ */ React__default.createElement(
|
|
197
|
+
"link",
|
|
198
|
+
{
|
|
199
|
+
key: href,
|
|
200
|
+
ref: index === 0 ? firstLinkRef : void 0,
|
|
201
|
+
href,
|
|
202
|
+
rel: "stylesheet",
|
|
203
|
+
type: "text/css"
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
));
|
|
207
|
+
}
|
|
72
208
|
function isPromise(obj) {
|
|
73
209
|
return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
74
210
|
}
|
|
@@ -235,65 +371,51 @@ function getTargetModuleInfo(id, instance) {
|
|
|
235
371
|
remoteEntry
|
|
236
372
|
};
|
|
237
373
|
}
|
|
238
|
-
function
|
|
374
|
+
function collectSSRAssetDescriptors(options) {
|
|
239
375
|
const {
|
|
240
376
|
id,
|
|
241
377
|
injectLink = true,
|
|
242
378
|
injectScript = false
|
|
243
379
|
} = typeof options === "string" ? { id: options } : options;
|
|
244
|
-
const
|
|
245
|
-
const
|
|
380
|
+
const stylesheetHrefs = [];
|
|
381
|
+
const scriptSrcs = [];
|
|
246
382
|
const instance = options.instance;
|
|
247
383
|
if (!instance || !injectLink && !injectScript) {
|
|
248
|
-
return
|
|
384
|
+
return { scriptSrcs, stylesheetHrefs };
|
|
249
385
|
}
|
|
250
386
|
const moduleAndPublicPath = getTargetModuleInfo(id, instance);
|
|
251
387
|
if (!moduleAndPublicPath) {
|
|
252
|
-
return
|
|
388
|
+
return { scriptSrcs, stylesheetHrefs };
|
|
253
389
|
}
|
|
254
390
|
const { module: targetModule, publicPath, remoteEntry } = moduleAndPublicPath;
|
|
255
391
|
if (injectLink) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
type: "text/css"
|
|
265
|
-
}
|
|
266
|
-
)
|
|
267
|
-
);
|
|
392
|
+
const seenStylesheetHrefs = /* @__PURE__ */ new Set();
|
|
393
|
+
[...targetModule.assets.css.sync, ...targetModule.assets.css.async].sort().forEach((file) => {
|
|
394
|
+
const href = `${publicPath}${file}`;
|
|
395
|
+
if (seenStylesheetHrefs.has(href)) {
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
398
|
+
seenStylesheetHrefs.add(href);
|
|
399
|
+
stylesheetHrefs.push(href);
|
|
268
400
|
});
|
|
269
401
|
}
|
|
270
402
|
if (injectScript) {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
{
|
|
275
|
-
async: true,
|
|
276
|
-
key: remoteEntry.split(".")[0],
|
|
277
|
-
src: `${publicPath}${remoteEntry}`,
|
|
278
|
-
crossOrigin: "anonymous"
|
|
279
|
-
}
|
|
280
|
-
)
|
|
281
|
-
);
|
|
282
|
-
[...targetModule.assets.js.sync].sort().forEach((file, index) => {
|
|
283
|
-
scripts.push(
|
|
284
|
-
/* @__PURE__ */ React__default.createElement(
|
|
285
|
-
"script",
|
|
286
|
-
{
|
|
287
|
-
key: `${file.split(".")[0]}_${index}`,
|
|
288
|
-
async: true,
|
|
289
|
-
src: `${publicPath}${file}`,
|
|
290
|
-
crossOrigin: "anonymous"
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
);
|
|
403
|
+
scriptSrcs.push(`${publicPath}${remoteEntry}`);
|
|
404
|
+
[...targetModule.assets.js.sync].sort().forEach((file) => {
|
|
405
|
+
scriptSrcs.push(`${publicPath}${file}`);
|
|
294
406
|
});
|
|
295
407
|
}
|
|
296
|
-
return
|
|
408
|
+
return { scriptSrcs, stylesheetHrefs };
|
|
409
|
+
}
|
|
410
|
+
function renderScriptAssets(scriptSrcs) {
|
|
411
|
+
return scriptSrcs.map((src) => /* @__PURE__ */ React__default.createElement("script", { key: src, async: true, src, crossOrigin: "anonymous" }));
|
|
412
|
+
}
|
|
413
|
+
function collectSSRAssets(options) {
|
|
414
|
+
const { scriptSrcs, stylesheetHrefs } = collectSSRAssetDescriptors(options);
|
|
415
|
+
return [
|
|
416
|
+
...renderScriptAssets(scriptSrcs),
|
|
417
|
+
...stylesheetHrefs.map((href) => /* @__PURE__ */ React__default.createElement("link", { key: href, href, rel: "stylesheet", type: "text/css" }))
|
|
418
|
+
];
|
|
297
419
|
}
|
|
298
420
|
function getServerNeedRemoteInfo(loadedRemoteInfo, id, noSSR) {
|
|
299
421
|
var _a;
|
|
@@ -407,12 +529,16 @@ function createLazyComponent(options) {
|
|
|
407
529
|
{ name: instance.name, version: instance == null ? void 0 : instance.options.version }
|
|
408
530
|
) : void 0;
|
|
409
531
|
logger.debug("LazyComponent dataFetchMapKey: ", dataFetchMapKey);
|
|
410
|
-
const
|
|
532
|
+
const { scriptSrcs, stylesheetHrefs } = collectSSRAssetDescriptors({
|
|
411
533
|
id: moduleId,
|
|
412
534
|
instance,
|
|
413
535
|
injectLink,
|
|
414
536
|
injectScript
|
|
415
537
|
});
|
|
538
|
+
const assets = [
|
|
539
|
+
...renderScriptAssets(scriptSrcs),
|
|
540
|
+
/* @__PURE__ */ React__default.createElement(HydratedStylesheetAssets, { key: "stylesheets", hrefs: stylesheetHrefs })
|
|
541
|
+
];
|
|
416
542
|
const Com = m[exportName];
|
|
417
543
|
if (exportName in m && typeof Com === "function") {
|
|
418
544
|
return {
|
package/dist/{lazy-load-component-plugin-FKp6nQa-.js → lazy-load-component-plugin-DeTbkGlM.js}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const prefetch = require("./prefetch-
|
|
2
|
+
const prefetch = require("./prefetch-CfMDdqO-.js");
|
|
3
3
|
const lazyUtils = require("./utils-5dGErM3C.js");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const autoFetchData = () => {
|
|
@@ -70,6 +70,142 @@ const autoFetchData = () => {
|
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
+
const EMPTY_HREFS = /* @__PURE__ */ new Set();
|
|
74
|
+
const stylesheetStores = /* @__PURE__ */ new WeakMap();
|
|
75
|
+
function isActiveStylesheet(link) {
|
|
76
|
+
const rel = link.rel.toLowerCase().split(/\s+/u);
|
|
77
|
+
const media = link.media.trim().toLowerCase();
|
|
78
|
+
const type = link.type.trim().toLowerCase().split(";", 1)[0].trim();
|
|
79
|
+
return rel.includes("stylesheet") && !rel.includes("alternate") && !link.disabled && !link.hasAttribute("disabled") && (!media || media === "all") && (!type || type === "text/css");
|
|
80
|
+
}
|
|
81
|
+
function collectHeadStylesheetHrefs(document) {
|
|
82
|
+
var _a;
|
|
83
|
+
const hrefs = /* @__PURE__ */ new Set();
|
|
84
|
+
(_a = document.head) == null ? void 0 : _a.querySelectorAll("link[href]").forEach((link) => {
|
|
85
|
+
if (isActiveStylesheet(link)) {
|
|
86
|
+
hrefs.add(link.href);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return hrefs;
|
|
90
|
+
}
|
|
91
|
+
function haveSameHrefs(current, next) {
|
|
92
|
+
if (current.size !== next.size) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
for (const href of current) {
|
|
96
|
+
if (!next.has(href)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
function observeHead(store) {
|
|
103
|
+
store.observer.disconnect();
|
|
104
|
+
const { document, head, observer } = store;
|
|
105
|
+
if (head) {
|
|
106
|
+
observer.observe(head, {
|
|
107
|
+
attributes: true,
|
|
108
|
+
attributeFilter: ["disabled", "href", "media", "rel", "type"],
|
|
109
|
+
childList: true,
|
|
110
|
+
subtree: true
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if (document.documentElement) {
|
|
114
|
+
observer.observe(document.documentElement, { childList: true });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function refreshHeadStylesheets(store) {
|
|
118
|
+
if (!store.subscribers.size) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const head = store.document.head;
|
|
122
|
+
if (head !== store.head) {
|
|
123
|
+
store.head = head;
|
|
124
|
+
observeHead(store);
|
|
125
|
+
}
|
|
126
|
+
const hrefs = collectHeadStylesheetHrefs(store.document);
|
|
127
|
+
if (haveSameHrefs(store.hrefs, hrefs)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
store.hrefs = hrefs;
|
|
131
|
+
store.subscribers.forEach((subscriber) => subscriber(hrefs));
|
|
132
|
+
}
|
|
133
|
+
function getStylesheetStore(document) {
|
|
134
|
+
var _a;
|
|
135
|
+
const current = stylesheetStores.get(document);
|
|
136
|
+
if (current) {
|
|
137
|
+
return current;
|
|
138
|
+
}
|
|
139
|
+
const MutationObserver = ((_a = document.defaultView) == null ? void 0 : _a.MutationObserver) ?? globalThis.MutationObserver;
|
|
140
|
+
let store;
|
|
141
|
+
const observer = new MutationObserver(() => refreshHeadStylesheets(store));
|
|
142
|
+
store = {
|
|
143
|
+
document,
|
|
144
|
+
head: document.head,
|
|
145
|
+
hrefs: collectHeadStylesheetHrefs(document),
|
|
146
|
+
observer,
|
|
147
|
+
subscribers: /* @__PURE__ */ new Set()
|
|
148
|
+
};
|
|
149
|
+
observeHead(store);
|
|
150
|
+
stylesheetStores.set(document, store);
|
|
151
|
+
return store;
|
|
152
|
+
}
|
|
153
|
+
function subscribeToHeadStylesheets(document, subscriber) {
|
|
154
|
+
const store = getStylesheetStore(document);
|
|
155
|
+
let subscribed = true;
|
|
156
|
+
store.subscribers.add(subscriber);
|
|
157
|
+
subscriber(store.hrefs);
|
|
158
|
+
return () => {
|
|
159
|
+
if (!subscribed) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
subscribed = false;
|
|
163
|
+
store.subscribers.delete(subscriber);
|
|
164
|
+
if (!store.subscribers.size) {
|
|
165
|
+
store.observer.disconnect();
|
|
166
|
+
if (stylesheetStores.get(document) === store) {
|
|
167
|
+
stylesheetStores.delete(document);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function resolveHref(href, document) {
|
|
173
|
+
try {
|
|
174
|
+
return new URL(href, document.baseURI).href;
|
|
175
|
+
} catch {
|
|
176
|
+
return href;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function HydratedStylesheetAssets({ hrefs }) {
|
|
180
|
+
const firstLinkRef = React.useRef(null);
|
|
181
|
+
const ownerDocumentRef = React.useRef(null);
|
|
182
|
+
const [headHrefs, setHeadHrefs] = React.useState(EMPTY_HREFS);
|
|
183
|
+
React.useEffect(() => {
|
|
184
|
+
var _a;
|
|
185
|
+
const link = firstLinkRef.current;
|
|
186
|
+
if (!link) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const ownerDocument = link.ownerDocument;
|
|
190
|
+
ownerDocumentRef.current = ownerDocument;
|
|
191
|
+
if (link.getRootNode() !== ownerDocument || ((_a = ownerDocument.head) == null ? void 0 : _a.contains(link))) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
return subscribeToHeadStylesheets(ownerDocument, setHeadHrefs);
|
|
195
|
+
}, []);
|
|
196
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, hrefs.map(
|
|
197
|
+
(href, index) => ownerDocumentRef.current && headHrefs.has(resolveHref(href, ownerDocumentRef.current)) ? null : /* @__PURE__ */ React.createElement(
|
|
198
|
+
"link",
|
|
199
|
+
{
|
|
200
|
+
key: href,
|
|
201
|
+
ref: index === 0 ? firstLinkRef : void 0,
|
|
202
|
+
href,
|
|
203
|
+
rel: "stylesheet",
|
|
204
|
+
type: "text/css"
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
));
|
|
208
|
+
}
|
|
73
209
|
function isPromise(obj) {
|
|
74
210
|
return !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function";
|
|
75
211
|
}
|
|
@@ -236,65 +372,51 @@ function getTargetModuleInfo(id, instance) {
|
|
|
236
372
|
remoteEntry
|
|
237
373
|
};
|
|
238
374
|
}
|
|
239
|
-
function
|
|
375
|
+
function collectSSRAssetDescriptors(options) {
|
|
240
376
|
const {
|
|
241
377
|
id,
|
|
242
378
|
injectLink = true,
|
|
243
379
|
injectScript = false
|
|
244
380
|
} = typeof options === "string" ? { id: options } : options;
|
|
245
|
-
const
|
|
246
|
-
const
|
|
381
|
+
const stylesheetHrefs = [];
|
|
382
|
+
const scriptSrcs = [];
|
|
247
383
|
const instance = options.instance;
|
|
248
384
|
if (!instance || !injectLink && !injectScript) {
|
|
249
|
-
return
|
|
385
|
+
return { scriptSrcs, stylesheetHrefs };
|
|
250
386
|
}
|
|
251
387
|
const moduleAndPublicPath = getTargetModuleInfo(id, instance);
|
|
252
388
|
if (!moduleAndPublicPath) {
|
|
253
|
-
return
|
|
389
|
+
return { scriptSrcs, stylesheetHrefs };
|
|
254
390
|
}
|
|
255
391
|
const { module: targetModule, publicPath, remoteEntry } = moduleAndPublicPath;
|
|
256
392
|
if (injectLink) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
type: "text/css"
|
|
266
|
-
}
|
|
267
|
-
)
|
|
268
|
-
);
|
|
393
|
+
const seenStylesheetHrefs = /* @__PURE__ */ new Set();
|
|
394
|
+
[...targetModule.assets.css.sync, ...targetModule.assets.css.async].sort().forEach((file) => {
|
|
395
|
+
const href = `${publicPath}${file}`;
|
|
396
|
+
if (seenStylesheetHrefs.has(href)) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
seenStylesheetHrefs.add(href);
|
|
400
|
+
stylesheetHrefs.push(href);
|
|
269
401
|
});
|
|
270
402
|
}
|
|
271
403
|
if (injectScript) {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
{
|
|
276
|
-
async: true,
|
|
277
|
-
key: remoteEntry.split(".")[0],
|
|
278
|
-
src: `${publicPath}${remoteEntry}`,
|
|
279
|
-
crossOrigin: "anonymous"
|
|
280
|
-
}
|
|
281
|
-
)
|
|
282
|
-
);
|
|
283
|
-
[...targetModule.assets.js.sync].sort().forEach((file, index) => {
|
|
284
|
-
scripts.push(
|
|
285
|
-
/* @__PURE__ */ React.createElement(
|
|
286
|
-
"script",
|
|
287
|
-
{
|
|
288
|
-
key: `${file.split(".")[0]}_${index}`,
|
|
289
|
-
async: true,
|
|
290
|
-
src: `${publicPath}${file}`,
|
|
291
|
-
crossOrigin: "anonymous"
|
|
292
|
-
}
|
|
293
|
-
)
|
|
294
|
-
);
|
|
404
|
+
scriptSrcs.push(`${publicPath}${remoteEntry}`);
|
|
405
|
+
[...targetModule.assets.js.sync].sort().forEach((file) => {
|
|
406
|
+
scriptSrcs.push(`${publicPath}${file}`);
|
|
295
407
|
});
|
|
296
408
|
}
|
|
297
|
-
return
|
|
409
|
+
return { scriptSrcs, stylesheetHrefs };
|
|
410
|
+
}
|
|
411
|
+
function renderScriptAssets(scriptSrcs) {
|
|
412
|
+
return scriptSrcs.map((src) => /* @__PURE__ */ React.createElement("script", { key: src, async: true, src, crossOrigin: "anonymous" }));
|
|
413
|
+
}
|
|
414
|
+
function collectSSRAssets(options) {
|
|
415
|
+
const { scriptSrcs, stylesheetHrefs } = collectSSRAssetDescriptors(options);
|
|
416
|
+
return [
|
|
417
|
+
...renderScriptAssets(scriptSrcs),
|
|
418
|
+
...stylesheetHrefs.map((href) => /* @__PURE__ */ React.createElement("link", { key: href, href, rel: "stylesheet", type: "text/css" }))
|
|
419
|
+
];
|
|
298
420
|
}
|
|
299
421
|
function getServerNeedRemoteInfo(loadedRemoteInfo, id, noSSR) {
|
|
300
422
|
var _a;
|
|
@@ -408,12 +530,16 @@ function createLazyComponent(options) {
|
|
|
408
530
|
{ name: instance.name, version: instance == null ? void 0 : instance.options.version }
|
|
409
531
|
) : void 0;
|
|
410
532
|
lazyUtils.logger.debug("LazyComponent dataFetchMapKey: ", dataFetchMapKey);
|
|
411
|
-
const
|
|
533
|
+
const { scriptSrcs, stylesheetHrefs } = collectSSRAssetDescriptors({
|
|
412
534
|
id: moduleId,
|
|
413
535
|
instance,
|
|
414
536
|
injectLink,
|
|
415
537
|
injectScript
|
|
416
538
|
});
|
|
539
|
+
const assets = [
|
|
540
|
+
...renderScriptAssets(scriptSrcs),
|
|
541
|
+
/* @__PURE__ */ React.createElement(HydratedStylesheetAssets, { key: "stylesheets", hrefs: stylesheetHrefs })
|
|
542
|
+
];
|
|
417
543
|
const Com = m[exportName];
|
|
418
544
|
if (exportName in m && typeof Com === "function") {
|
|
419
545
|
return {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
4
|
-
require("./prefetch-
|
|
3
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-DeTbkGlM.js");
|
|
4
|
+
require("./prefetch-CfMDdqO-.js");
|
|
5
5
|
exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
6
6
|
exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l, l as l2 } from "./lazy-load-component-plugin-
|
|
2
|
-
import "./prefetch-
|
|
1
|
+
import { l, l as l2 } from "./lazy-load-component-plugin-DQFjLSsW.mjs";
|
|
2
|
+
import "./prefetch-BJZbf9LF.mjs";
|
|
3
3
|
export {
|
|
4
4
|
l as default,
|
|
5
5
|
l2 as lazyLoadComponentPlugin
|
|
@@ -621,18 +621,46 @@ const runtimeDescMap = {
|
|
|
621
621
|
...runtimeDescMap
|
|
622
622
|
});
|
|
623
623
|
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
624
|
-
|
|
624
|
+
const esmRemoteEntryLoadErrorMessages = [
|
|
625
|
+
"Failed to fetch dynamically imported module",
|
|
626
|
+
"Importing a module script failed",
|
|
627
|
+
"error loading dynamically imported module"
|
|
628
|
+
];
|
|
629
|
+
function isEsmRemoteEntryLoadError(err) {
|
|
630
|
+
if (!(err instanceof TypeError)) return false;
|
|
631
|
+
return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) => err.message.includes(loadErrorMessage));
|
|
632
|
+
}
|
|
633
|
+
function isEsmRemoteType(type) {
|
|
634
|
+
return type === "esm" || type === "module";
|
|
635
|
+
}
|
|
636
|
+
async function loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl }) {
|
|
625
637
|
return new Promise((resolve, reject) => {
|
|
638
|
+
const rejectEntry = (loadError) => {
|
|
639
|
+
if (isEsmRemoteEntryLoadError(loadError)) {
|
|
640
|
+
const originalMsg = loadError instanceof Error ? loadError.message : String(loadError);
|
|
641
|
+
try {
|
|
642
|
+
error(RUNTIME_008, runtimeDescMap, {
|
|
643
|
+
remoteName: name,
|
|
644
|
+
resourceUrl: url
|
|
645
|
+
}, originalMsg);
|
|
646
|
+
} catch (runtimeError) {
|
|
647
|
+
reject(runtimeError);
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
reject(loadError);
|
|
652
|
+
};
|
|
653
|
+
const url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
626
654
|
try {
|
|
627
|
-
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${
|
|
655
|
+
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${url}")${importCallback}`)([resolve, rejectEntry]);
|
|
628
656
|
else import(
|
|
629
657
|
/* webpackIgnore: true */
|
|
630
658
|
/* @vite-ignore */
|
|
631
|
-
|
|
632
|
-
).then(resolve).catch(
|
|
659
|
+
url
|
|
660
|
+
).then(resolve).catch(rejectEntry);
|
|
633
661
|
else resolve(remoteEntryExports);
|
|
634
662
|
} catch (e) {
|
|
635
|
-
error(`Failed to load ESM entry from "${
|
|
663
|
+
error(`Failed to load ESM entry from "${url}". ${e instanceof Error ? e.message : String(e)}`);
|
|
636
664
|
}
|
|
637
665
|
});
|
|
638
666
|
}
|
|
@@ -688,29 +716,25 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
688
716
|
}
|
|
689
717
|
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
|
|
690
718
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
getEntryUrl,
|
|
711
|
-
resourceContext
|
|
712
|
-
});
|
|
713
|
-
}
|
|
719
|
+
if (isEsmRemoteType(type)) return loadEsmEntry({
|
|
720
|
+
entry,
|
|
721
|
+
remoteEntryExports,
|
|
722
|
+
name,
|
|
723
|
+
getEntryUrl
|
|
724
|
+
});
|
|
725
|
+
if (type === "system") return loadSystemJsEntry({
|
|
726
|
+
entry,
|
|
727
|
+
remoteEntryExports
|
|
728
|
+
});
|
|
729
|
+
return loadEntryScript({
|
|
730
|
+
entry,
|
|
731
|
+
globalName,
|
|
732
|
+
name,
|
|
733
|
+
remoteInfo,
|
|
734
|
+
loaderHook,
|
|
735
|
+
getEntryUrl,
|
|
736
|
+
resourceContext
|
|
737
|
+
});
|
|
714
738
|
}
|
|
715
739
|
async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
|
|
716
740
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
@@ -969,7 +993,7 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
969
993
|
results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
|
|
970
994
|
});
|
|
971
995
|
if (useLinkPreload) {
|
|
972
|
-
const
|
|
996
|
+
const defaultAttrs2 = {
|
|
973
997
|
rel: "preload",
|
|
974
998
|
as: "style"
|
|
975
999
|
};
|
|
@@ -978,12 +1002,12 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
978
1002
|
host,
|
|
979
1003
|
remoteInfo,
|
|
980
1004
|
url: cssUrl,
|
|
981
|
-
attrs:
|
|
1005
|
+
attrs: defaultAttrs2,
|
|
982
1006
|
context: createResourceContext(baseContext, "css")
|
|
983
1007
|
}));
|
|
984
1008
|
});
|
|
985
1009
|
} else {
|
|
986
|
-
const
|
|
1010
|
+
const defaultAttrs2 = {
|
|
987
1011
|
rel: "stylesheet",
|
|
988
1012
|
type: "text/css"
|
|
989
1013
|
};
|
|
@@ -992,41 +1016,39 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
992
1016
|
host,
|
|
993
1017
|
remoteInfo,
|
|
994
1018
|
url: cssUrl,
|
|
995
|
-
attrs:
|
|
1019
|
+
attrs: defaultAttrs2,
|
|
996
1020
|
needDeleteLink: false,
|
|
997
1021
|
context: createResourceContext(baseContext, "css")
|
|
998
1022
|
}));
|
|
999
1023
|
});
|
|
1000
1024
|
}
|
|
1025
|
+
let preloadJsAsset = waitForScriptPreload;
|
|
1026
|
+
let defaultAttrs = {
|
|
1027
|
+
fetchpriority: "high",
|
|
1028
|
+
type: "text/javascript"
|
|
1029
|
+
};
|
|
1001
1030
|
if (useLinkPreload) {
|
|
1002
|
-
|
|
1031
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1032
|
+
defaultAttrs = {
|
|
1003
1033
|
rel: "preload",
|
|
1004
1034
|
as: "script"
|
|
1005
1035
|
};
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
attrs: defaultAttrs,
|
|
1012
|
-
context: createResourceContext(baseContext, "js")
|
|
1013
|
-
}));
|
|
1014
|
-
});
|
|
1015
|
-
} else {
|
|
1016
|
-
const defaultAttrs = {
|
|
1017
|
-
fetchpriority: "high",
|
|
1018
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
|
|
1036
|
+
} else if (isEsmRemoteType(remoteInfo.type)) {
|
|
1037
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1038
|
+
defaultAttrs = {
|
|
1039
|
+
rel: "modulepreload",
|
|
1040
|
+
fetchpriority: "high"
|
|
1019
1041
|
};
|
|
1020
|
-
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
1021
|
-
results.push(waitForScriptPreload({
|
|
1022
|
-
host,
|
|
1023
|
-
remoteInfo,
|
|
1024
|
-
url: jsUrl,
|
|
1025
|
-
attrs: defaultAttrs,
|
|
1026
|
-
context: createResourceContext(baseContext, "js")
|
|
1027
|
-
}));
|
|
1028
|
-
});
|
|
1029
1042
|
}
|
|
1043
|
+
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
1044
|
+
results.push(preloadJsAsset({
|
|
1045
|
+
host,
|
|
1046
|
+
remoteInfo,
|
|
1047
|
+
url: jsUrl,
|
|
1048
|
+
attrs: defaultAttrs,
|
|
1049
|
+
context: createResourceContext(baseContext, "js")
|
|
1050
|
+
}));
|
|
1051
|
+
});
|
|
1030
1052
|
}
|
|
1031
1053
|
return Promise.all(results);
|
|
1032
1054
|
}
|
|
@@ -622,18 +622,46 @@ const runtimeDescMap = {
|
|
|
622
622
|
...runtimeDescMap
|
|
623
623
|
});
|
|
624
624
|
const importCallback = ".then(callbacks[0]).catch(callbacks[1])";
|
|
625
|
-
|
|
625
|
+
const esmRemoteEntryLoadErrorMessages = [
|
|
626
|
+
"Failed to fetch dynamically imported module",
|
|
627
|
+
"Importing a module script failed",
|
|
628
|
+
"error loading dynamically imported module"
|
|
629
|
+
];
|
|
630
|
+
function isEsmRemoteEntryLoadError(err) {
|
|
631
|
+
if (!(err instanceof TypeError)) return false;
|
|
632
|
+
return esmRemoteEntryLoadErrorMessages.some((loadErrorMessage) => err.message.includes(loadErrorMessage));
|
|
633
|
+
}
|
|
634
|
+
function isEsmRemoteType(type) {
|
|
635
|
+
return type === "esm" || type === "module";
|
|
636
|
+
}
|
|
637
|
+
async function loadEsmEntry({ entry, remoteEntryExports, name, getEntryUrl }) {
|
|
626
638
|
return new Promise((resolve, reject) => {
|
|
639
|
+
const rejectEntry = (loadError) => {
|
|
640
|
+
if (isEsmRemoteEntryLoadError(loadError)) {
|
|
641
|
+
const originalMsg = loadError instanceof Error ? loadError.message : String(loadError);
|
|
642
|
+
try {
|
|
643
|
+
error(RUNTIME_008, runtimeDescMap, {
|
|
644
|
+
remoteName: name,
|
|
645
|
+
resourceUrl: url
|
|
646
|
+
}, originalMsg);
|
|
647
|
+
} catch (runtimeError) {
|
|
648
|
+
reject(runtimeError);
|
|
649
|
+
return;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
reject(loadError);
|
|
653
|
+
};
|
|
654
|
+
const url = getEntryUrl ? getEntryUrl(entry) : entry;
|
|
627
655
|
try {
|
|
628
|
-
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${
|
|
656
|
+
if (!remoteEntryExports) if (typeof FEDERATION_ALLOW_NEW_FUNCTION !== "undefined") new Function("callbacks", `import("${url}")${importCallback}`)([resolve, rejectEntry]);
|
|
629
657
|
else import(
|
|
630
658
|
/* webpackIgnore: true */
|
|
631
659
|
/* @vite-ignore */
|
|
632
|
-
|
|
633
|
-
).then(resolve).catch(
|
|
660
|
+
url
|
|
661
|
+
).then(resolve).catch(rejectEntry);
|
|
634
662
|
else resolve(remoteEntryExports);
|
|
635
663
|
} catch (e) {
|
|
636
|
-
error(`Failed to load ESM entry from "${
|
|
664
|
+
error(`Failed to load ESM entry from "${url}". ${e instanceof Error ? e.message : String(e)}`);
|
|
637
665
|
}
|
|
638
666
|
});
|
|
639
667
|
}
|
|
@@ -689,29 +717,25 @@ async function loadEntryScript({ name, globalName, entry, remoteInfo, loaderHook
|
|
|
689
717
|
}
|
|
690
718
|
async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEntryUrl, resourceContext }) {
|
|
691
719
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
getEntryUrl,
|
|
712
|
-
resourceContext
|
|
713
|
-
});
|
|
714
|
-
}
|
|
720
|
+
if (isEsmRemoteType(type)) return loadEsmEntry({
|
|
721
|
+
entry,
|
|
722
|
+
remoteEntryExports,
|
|
723
|
+
name,
|
|
724
|
+
getEntryUrl
|
|
725
|
+
});
|
|
726
|
+
if (type === "system") return loadSystemJsEntry({
|
|
727
|
+
entry,
|
|
728
|
+
remoteEntryExports
|
|
729
|
+
});
|
|
730
|
+
return loadEntryScript({
|
|
731
|
+
entry,
|
|
732
|
+
globalName,
|
|
733
|
+
name,
|
|
734
|
+
remoteInfo,
|
|
735
|
+
loaderHook,
|
|
736
|
+
getEntryUrl,
|
|
737
|
+
resourceContext
|
|
738
|
+
});
|
|
715
739
|
}
|
|
716
740
|
async function loadEntryNode({ remoteInfo, loaderHook, resourceContext }) {
|
|
717
741
|
const { entry, entryGlobalName: globalName, name, type } = remoteInfo;
|
|
@@ -970,7 +994,7 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
970
994
|
results.push(waitForRemoteEntryPreload(host, remoteInfo, entryRemoteInfo, createResourceContext(baseContext, "remoteEntry")));
|
|
971
995
|
});
|
|
972
996
|
if (useLinkPreload) {
|
|
973
|
-
const
|
|
997
|
+
const defaultAttrs2 = {
|
|
974
998
|
rel: "preload",
|
|
975
999
|
as: "style"
|
|
976
1000
|
};
|
|
@@ -979,12 +1003,12 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
979
1003
|
host,
|
|
980
1004
|
remoteInfo,
|
|
981
1005
|
url: cssUrl,
|
|
982
|
-
attrs:
|
|
1006
|
+
attrs: defaultAttrs2,
|
|
983
1007
|
context: createResourceContext(baseContext, "css")
|
|
984
1008
|
}));
|
|
985
1009
|
});
|
|
986
1010
|
} else {
|
|
987
|
-
const
|
|
1011
|
+
const defaultAttrs2 = {
|
|
988
1012
|
rel: "stylesheet",
|
|
989
1013
|
type: "text/css"
|
|
990
1014
|
};
|
|
@@ -993,41 +1017,39 @@ function preloadAssets(remoteInfo, host, assets, useLinkPreload = true, baseCont
|
|
|
993
1017
|
host,
|
|
994
1018
|
remoteInfo,
|
|
995
1019
|
url: cssUrl,
|
|
996
|
-
attrs:
|
|
1020
|
+
attrs: defaultAttrs2,
|
|
997
1021
|
needDeleteLink: false,
|
|
998
1022
|
context: createResourceContext(baseContext, "css")
|
|
999
1023
|
}));
|
|
1000
1024
|
});
|
|
1001
1025
|
}
|
|
1026
|
+
let preloadJsAsset = waitForScriptPreload;
|
|
1027
|
+
let defaultAttrs = {
|
|
1028
|
+
fetchpriority: "high",
|
|
1029
|
+
type: "text/javascript"
|
|
1030
|
+
};
|
|
1002
1031
|
if (useLinkPreload) {
|
|
1003
|
-
|
|
1032
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1033
|
+
defaultAttrs = {
|
|
1004
1034
|
rel: "preload",
|
|
1005
1035
|
as: "script"
|
|
1006
1036
|
};
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
attrs: defaultAttrs,
|
|
1013
|
-
context: createResourceContext(baseContext, "js")
|
|
1014
|
-
}));
|
|
1015
|
-
});
|
|
1016
|
-
} else {
|
|
1017
|
-
const defaultAttrs = {
|
|
1018
|
-
fetchpriority: "high",
|
|
1019
|
-
type: (remoteInfo == null ? void 0 : remoteInfo.type) === "module" ? "module" : "text/javascript"
|
|
1037
|
+
} else if (isEsmRemoteType(remoteInfo.type)) {
|
|
1038
|
+
preloadJsAsset = waitForLinkPreload;
|
|
1039
|
+
defaultAttrs = {
|
|
1040
|
+
rel: "modulepreload",
|
|
1041
|
+
fetchpriority: "high"
|
|
1020
1042
|
};
|
|
1021
|
-
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
1022
|
-
results.push(waitForScriptPreload({
|
|
1023
|
-
host,
|
|
1024
|
-
remoteInfo,
|
|
1025
|
-
url: jsUrl,
|
|
1026
|
-
attrs: defaultAttrs,
|
|
1027
|
-
context: createResourceContext(baseContext, "js")
|
|
1028
|
-
}));
|
|
1029
|
-
});
|
|
1030
1043
|
}
|
|
1044
|
+
jsAssetsWithoutEntry.forEach((jsUrl) => {
|
|
1045
|
+
results.push(preloadJsAsset({
|
|
1046
|
+
host,
|
|
1047
|
+
remoteInfo,
|
|
1048
|
+
url: jsUrl,
|
|
1049
|
+
attrs: defaultAttrs,
|
|
1050
|
+
context: createResourceContext(baseContext, "js")
|
|
1051
|
+
}));
|
|
1052
|
+
});
|
|
1031
1053
|
}
|
|
1032
1054
|
return Promise.all(results);
|
|
1033
1055
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.2",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
"dependencies": {
|
|
150
|
-
"@module-federation/sdk": "2.8.
|
|
150
|
+
"@module-federation/sdk": "2.8.2"
|
|
151
151
|
},
|
|
152
152
|
"peerDependencies": {
|
|
153
153
|
"react": ">=16.9.0",
|
|
@@ -179,9 +179,9 @@
|
|
|
179
179
|
"typescript": "7.0.2",
|
|
180
180
|
"vite": "^5.4.21",
|
|
181
181
|
"hono": "4.12.26",
|
|
182
|
-
"@module-federation/
|
|
183
|
-
"@module-federation/
|
|
184
|
-
"@module-federation/runtime-core": "2.8.
|
|
182
|
+
"@module-federation/runtime": "2.8.2",
|
|
183
|
+
"@module-federation/bridge-shared": "2.8.2",
|
|
184
|
+
"@module-federation/runtime-core": "2.8.2"
|
|
185
185
|
},
|
|
186
186
|
"scripts": {
|
|
187
187
|
"dev": "vite",
|