@module-federation/bridge-react 0.19.1 → 0.21.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/CHANGELOG.md +22 -0
- package/__tests__/bridge.spec.tsx +37 -14
- package/dist/{bridge-base-Ds850AOx.js → bridge-base-B2malZDo.js} +6 -4
- package/dist/{bridge-base-BwHtOqw_.mjs → bridge-base-DRFFglgm.mjs} +6 -4
- package/dist/data-fetch-server-middleware.cjs.js +2 -2
- package/dist/data-fetch-server-middleware.es.js +2 -2
- package/dist/data-fetch-utils.cjs.js +2 -2
- package/dist/data-fetch-utils.es.js +4 -4
- package/dist/{index-eN2xRRXs.js → index-DRSBaSu3.js} +1 -1
- package/dist/{index-rAO0Wr0M.mjs → index-DyQNwY2M.mjs} +1 -1
- package/dist/index.cjs.js +6 -6
- package/dist/index.es.js +6 -6
- package/dist/{index.esm-Ju4RY-yW.js → index.esm-BWaKho-8.js} +108 -46
- package/dist/{index.esm-CtI0uQUR.mjs → index.esm-CPwSeCvw.mjs} +113 -51
- package/dist/{lazy-load-component-plugin-vtpWwn-P.js → lazy-load-component-plugin-B-nqmULm.js} +2 -2
- package/dist/{lazy-load-component-plugin-Dmzr-hGo.mjs → lazy-load-component-plugin-D_--Azke.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.cjs.js +2 -2
- package/dist/lazy-utils.es.js +2 -2
- package/dist/{prefetch-HjsWsmMr.js → prefetch-C8kORtvg.js} +63 -139
- package/dist/{prefetch-DtZwviM-.mjs → prefetch-Cxo6GKct.mjs} +63 -139
- package/dist/router-v5.cjs.js +1 -1
- package/dist/router-v5.es.js +1 -1
- package/dist/router-v6.cjs.js +1 -1
- package/dist/router-v6.es.js +1 -1
- package/dist/router-v7.cjs.js +83 -0
- package/dist/router-v7.d.ts +20 -0
- package/dist/router-v7.es.js +61 -0
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/dist/{utils-VSOJTX_o.mjs → utils-Bx_8GGd-.mjs} +1 -1
- package/dist/{utils-vIpCrZmn.js → utils-tM9yE73c.js} +1 -1
- package/dist/v18.cjs.js +1 -1
- package/dist/v18.es.js +1 -1
- package/dist/v19.cjs.js +1 -1
- package/dist/v19.es.js +1 -1
- package/package.json +22 -7
- package/src/provider/versions/bridge-base.tsx +7 -2
- package/src/provider/versions/legacy.ts +2 -1
- package/src/router/v7.tsx +75 -0
- package/vite.config.ts +24 -0
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
function _extends() {
|
|
2
|
-
_extends = Object.assign || function assign(target) {
|
|
3
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
4
|
-
var source = arguments[i];
|
|
5
|
-
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
6
|
-
}
|
|
7
|
-
return target;
|
|
8
|
-
};
|
|
9
|
-
return _extends.apply(this, arguments);
|
|
10
|
-
}
|
|
11
1
|
const MANIFEST_EXT = ".json";
|
|
12
2
|
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
13
3
|
const SEPARATOR = ":";
|
|
@@ -51,40 +41,120 @@ const composeKeyWithSeparator = function(...args) {
|
|
|
51
41
|
const warn = (msg) => {
|
|
52
42
|
console.warn(`${LOG_CATEGORY}: ${msg}`);
|
|
53
43
|
};
|
|
54
|
-
|
|
44
|
+
const PREFIX = "[ Module Federation ]";
|
|
45
|
+
const DEFAULT_DELEGATE = console;
|
|
46
|
+
const LOGGER_STACK_SKIP_TOKENS = [
|
|
47
|
+
"logger.ts",
|
|
48
|
+
"logger.js",
|
|
49
|
+
"captureStackTrace",
|
|
50
|
+
"Logger.emit",
|
|
51
|
+
"Logger.log",
|
|
52
|
+
"Logger.info",
|
|
53
|
+
"Logger.warn",
|
|
54
|
+
"Logger.error",
|
|
55
|
+
"Logger.debug"
|
|
56
|
+
];
|
|
57
|
+
function captureStackTrace() {
|
|
58
|
+
try {
|
|
59
|
+
const stack = new Error().stack;
|
|
60
|
+
if (!stack) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
const [, ...rawLines] = stack.split("\n");
|
|
64
|
+
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
|
|
65
|
+
if (!filtered.length) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
const stackPreview = filtered.slice(0, 5).join("\n");
|
|
69
|
+
return `Stack trace:
|
|
70
|
+
${stackPreview}`;
|
|
71
|
+
} catch {
|
|
72
|
+
return void 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
class Logger {
|
|
76
|
+
constructor(prefix, delegate = DEFAULT_DELEGATE) {
|
|
77
|
+
this.prefix = prefix;
|
|
78
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
79
|
+
}
|
|
55
80
|
setPrefix(prefix) {
|
|
56
81
|
this.prefix = prefix;
|
|
57
82
|
}
|
|
83
|
+
setDelegate(delegate) {
|
|
84
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
85
|
+
}
|
|
86
|
+
emit(method, args) {
|
|
87
|
+
const delegate = this.delegate;
|
|
88
|
+
const debugMode = isDebugMode();
|
|
89
|
+
const stackTrace = debugMode ? captureStackTrace() : void 0;
|
|
90
|
+
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
|
|
91
|
+
const order = (() => {
|
|
92
|
+
switch (method) {
|
|
93
|
+
case "log":
|
|
94
|
+
return ["log", "info"];
|
|
95
|
+
case "info":
|
|
96
|
+
return ["info", "log"];
|
|
97
|
+
case "warn":
|
|
98
|
+
return ["warn", "info", "log"];
|
|
99
|
+
case "error":
|
|
100
|
+
return ["error", "warn", "log"];
|
|
101
|
+
case "debug":
|
|
102
|
+
default:
|
|
103
|
+
return ["debug", "log"];
|
|
104
|
+
}
|
|
105
|
+
})();
|
|
106
|
+
for (const candidate of order) {
|
|
107
|
+
const handler = delegate[candidate];
|
|
108
|
+
if (typeof handler === "function") {
|
|
109
|
+
handler.call(delegate, this.prefix, ...enrichedArgs);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const candidate of order) {
|
|
114
|
+
const handler = DEFAULT_DELEGATE[candidate];
|
|
115
|
+
if (typeof handler === "function") {
|
|
116
|
+
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
58
121
|
log(...args) {
|
|
59
|
-
|
|
122
|
+
this.emit("log", args);
|
|
60
123
|
}
|
|
61
124
|
warn(...args) {
|
|
62
|
-
|
|
125
|
+
this.emit("warn", args);
|
|
63
126
|
}
|
|
64
127
|
error(...args) {
|
|
65
|
-
|
|
128
|
+
this.emit("error", args);
|
|
66
129
|
}
|
|
67
130
|
success(...args) {
|
|
68
|
-
|
|
131
|
+
this.emit("info", args);
|
|
69
132
|
}
|
|
70
133
|
info(...args) {
|
|
71
|
-
|
|
134
|
+
this.emit("info", args);
|
|
72
135
|
}
|
|
73
136
|
ready(...args) {
|
|
74
|
-
|
|
137
|
+
this.emit("info", args);
|
|
75
138
|
}
|
|
76
139
|
debug(...args) {
|
|
77
140
|
if (isDebugMode()) {
|
|
78
|
-
|
|
141
|
+
this.emit("debug", args);
|
|
79
142
|
}
|
|
80
143
|
}
|
|
81
|
-
|
|
82
|
-
this.prefix = prefix;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
144
|
+
}
|
|
85
145
|
function createLogger(prefix) {
|
|
86
146
|
return new Logger(prefix);
|
|
87
147
|
}
|
|
148
|
+
function createInfrastructureLogger(prefix) {
|
|
149
|
+
const infrastructureLogger = new Logger(prefix);
|
|
150
|
+
Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
|
|
151
|
+
value: true,
|
|
152
|
+
enumerable: false,
|
|
153
|
+
configurable: false
|
|
154
|
+
});
|
|
155
|
+
return infrastructureLogger;
|
|
156
|
+
}
|
|
157
|
+
createInfrastructureLogger(PREFIX);
|
|
88
158
|
async function safeWrapper(callback, disableWarn) {
|
|
89
159
|
try {
|
|
90
160
|
const res2 = await callback();
|
|
@@ -184,10 +254,7 @@ function createScript(info) {
|
|
|
184
254
|
timeoutId = setTimeout(() => {
|
|
185
255
|
onScriptComplete(null, new Error(`Remote script "${info.url}" time-outed.`));
|
|
186
256
|
}, timeout);
|
|
187
|
-
return {
|
|
188
|
-
script: script2,
|
|
189
|
-
needAttach
|
|
190
|
-
};
|
|
257
|
+
return { script: script2, needAttach };
|
|
191
258
|
}
|
|
192
259
|
function createLink(info) {
|
|
193
260
|
let link = null;
|
|
@@ -249,10 +316,7 @@ function createLink(info) {
|
|
|
249
316
|
};
|
|
250
317
|
link.onerror = onLinkComplete.bind(null, link.onerror);
|
|
251
318
|
link.onload = onLinkComplete.bind(null, link.onload);
|
|
252
|
-
return {
|
|
253
|
-
link,
|
|
254
|
-
needAttach
|
|
255
|
-
};
|
|
319
|
+
return { link, needAttach };
|
|
256
320
|
}
|
|
257
321
|
function loadScript(url2, info) {
|
|
258
322
|
const { attrs: attrs2 = {}, createScriptHook } = info;
|
|
@@ -261,9 +325,10 @@ function loadScript(url2, info) {
|
|
|
261
325
|
url: url2,
|
|
262
326
|
cb: resolve,
|
|
263
327
|
onErrorCallback: reject,
|
|
264
|
-
attrs:
|
|
265
|
-
fetchpriority: "high"
|
|
266
|
-
|
|
328
|
+
attrs: {
|
|
329
|
+
fetchpriority: "high",
|
|
330
|
+
...attrs2
|
|
331
|
+
},
|
|
267
332
|
createScriptHook,
|
|
268
333
|
needDeleteScript: true
|
|
269
334
|
});
|
|
@@ -324,27 +389,24 @@ const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "we
|
|
|
324
389
|
return typeof fetch === "undefined" ? loadNodeFetch() : fetch;
|
|
325
390
|
};
|
|
326
391
|
const handleScriptFetch = async (f, urlObj) => {
|
|
392
|
+
var _a;
|
|
327
393
|
try {
|
|
328
|
-
var _vm_constants;
|
|
329
394
|
const res = await f(urlObj.href);
|
|
330
395
|
const data = await res.text();
|
|
331
396
|
const [path, vm] = await Promise.all([
|
|
332
397
|
importNodeModule("path"),
|
|
333
398
|
importNodeModule("vm")
|
|
334
399
|
]);
|
|
335
|
-
const scriptContext = {
|
|
336
|
-
exports: {},
|
|
337
|
-
module: {
|
|
338
|
-
exports: {}
|
|
339
|
-
}
|
|
340
|
-
};
|
|
400
|
+
const scriptContext = { exports: {}, module: { exports: {} } };
|
|
341
401
|
const urlDirname = urlObj.pathname.split("/").slice(0, -1).join("/");
|
|
342
402
|
const filename = path.basename(urlObj.pathname);
|
|
343
|
-
var _vm_constants_USE_MAIN_CONTEXT_DEFAULT_LOADER;
|
|
344
403
|
const script = new vm.Script(`(function(exports, module, require, __dirname, __filename) {${data}
|
|
345
404
|
})`, {
|
|
346
405
|
filename,
|
|
347
|
-
importModuleDynamically: (
|
|
406
|
+
importModuleDynamically: (
|
|
407
|
+
//@ts-ignore
|
|
408
|
+
((_a = vm.constants) == null ? void 0 : _a.USE_MAIN_CONTEXT_DEFAULT_LOADER) ?? importNodeModule
|
|
409
|
+
)
|
|
348
410
|
});
|
|
349
411
|
script.runInThisContext()(scriptContext.exports, scriptContext.module, eval("require"), urlDirname, filename);
|
|
350
412
|
const exportedInterface = scriptContext.module.exports || scriptContext.exports;
|
|
@@ -380,11 +442,11 @@ const createScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "we
|
|
|
380
442
|
const loadScriptNode = typeof ENV_TARGET === "undefined" || ENV_TARGET !== "web" ? (url2, info) => {
|
|
381
443
|
return new Promise((resolve, reject) => {
|
|
382
444
|
createScriptNode(url2, (error, scriptContext2) => {
|
|
445
|
+
var _a, _b;
|
|
383
446
|
if (error) {
|
|
384
447
|
reject(error);
|
|
385
448
|
} else {
|
|
386
|
-
|
|
387
|
-
const remoteEntryKey = (info == null ? void 0 : (_info_attrs = info.attrs) == null ? void 0 : _info_attrs["globalName"]) || `__FEDERATION_${info == null ? void 0 : (_info_attrs1 = info.attrs) == null ? void 0 : _info_attrs1["name"]}:custom__`;
|
|
449
|
+
const remoteEntryKey = ((_a = info == null ? void 0 : info.attrs) == null ? void 0 : _a["globalName"]) || `__FEDERATION_${(_b = info == null ? void 0 : info.attrs) == null ? void 0 : _b["name"]}:custom__`;
|
|
388
450
|
const entryExports = globalThis[remoteEntryKey] = scriptContext2;
|
|
389
451
|
resolve(entryExports);
|
|
390
452
|
}
|
|
@@ -398,8 +460,8 @@ async function loadModule(url2, options) {
|
|
|
398
460
|
if (esmModuleCache.has(url2)) {
|
|
399
461
|
return esmModuleCache.get(url2);
|
|
400
462
|
}
|
|
401
|
-
const { fetch:
|
|
402
|
-
const response = await
|
|
463
|
+
const { fetch: fetch2, vm: vm2 } = options;
|
|
464
|
+
const response = await fetch2(url2);
|
|
403
465
|
const code = await response.text();
|
|
404
466
|
const module = new vm2.SourceTextModule(code, {
|
|
405
467
|
// @ts-ignore
|
|
@@ -419,12 +481,12 @@ async function loadModule(url2, options) {
|
|
|
419
481
|
export {
|
|
420
482
|
MANIFEST_EXT as M,
|
|
421
483
|
SEPARATOR as S,
|
|
422
|
-
|
|
423
|
-
|
|
484
|
+
createLink as a,
|
|
485
|
+
createScript as b,
|
|
424
486
|
createLogger as c,
|
|
425
|
-
|
|
426
|
-
|
|
487
|
+
isBrowserEnv as d,
|
|
488
|
+
composeKeyWithSeparator as e,
|
|
427
489
|
loadScript as f,
|
|
428
|
-
|
|
490
|
+
isDebugMode as i,
|
|
429
491
|
loadScriptNode as l
|
|
430
492
|
};
|
package/dist/{lazy-load-component-plugin-vtpWwn-P.js → lazy-load-component-plugin-B-nqmULm.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const prefetch = require("./prefetch-
|
|
3
|
-
const lazyUtils = require("./utils-
|
|
2
|
+
const prefetch = require("./prefetch-C8kORtvg.js");
|
|
3
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const autoFetchData = () => {
|
|
6
6
|
lazyUtils.initDataFetchMap();
|
package/dist/{lazy-load-component-plugin-Dmzr-hGo.mjs → lazy-load-component-plugin-D_--Azke.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as injectDataFetch, p as prefetch } from "./prefetch-
|
|
2
|
-
import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isCSROnly, a as loadDataFetchModule, M as MF_DATA_FETCH_STATUS, g as getDataFetchMap, t as isServerEnv, u as getDataFetchIdWithErrorMsgs, v as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, w as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, x as DATA_FETCH_FUNCTION, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-
|
|
1
|
+
import { i as injectDataFetch, p as prefetch } from "./prefetch-Cxo6GKct.mjs";
|
|
2
|
+
import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isCSROnly, a as loadDataFetchModule, M as MF_DATA_FETCH_STATUS, g as getDataFetchMap, t as isServerEnv, u as getDataFetchIdWithErrorMsgs, v as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, w as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, x as DATA_FETCH_FUNCTION, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-Bx_8GGd-.mjs";
|
|
3
3
|
import React__default, { useRef, useState, Suspense, useEffect } from "react";
|
|
4
4
|
const autoFetchData = () => {
|
|
5
5
|
initDataFetchMap();
|
|
@@ -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-B-nqmULm.js");
|
|
4
|
+
require("./prefetch-C8kORtvg.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-D_--Azke.mjs";
|
|
2
|
+
import "./prefetch-Cxo6GKct.mjs";
|
|
3
3
|
export {
|
|
4
4
|
l as default,
|
|
5
5
|
l2 as lazyLoadComponentPlugin
|
package/dist/lazy-utils.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./index.esm-
|
|
4
|
-
const lazyUtils = require("./utils-
|
|
3
|
+
require("./index.esm-BWaKho-8.js");
|
|
4
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
5
5
|
exports.callAllDowngrade = lazyUtils.callAllDowngrade;
|
|
6
6
|
exports.callDowngrade = lazyUtils.callDowngrade;
|
|
7
7
|
exports.fetchData = lazyUtils.fetchData;
|
package/dist/lazy-utils.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "./index.esm-
|
|
2
|
-
import { G, H, f, J, I, u, k, n, g, m, B, y, i, q, j, t, a, z, s, w } from "./utils-
|
|
1
|
+
import "./index.esm-CPwSeCvw.mjs";
|
|
2
|
+
import { G, H, f, J, I, u, k, n, g, m, B, y, i, q, j, t, a, z, s, w } from "./utils-Bx_8GGd-.mjs";
|
|
3
3
|
export {
|
|
4
4
|
G as callAllDowngrade,
|
|
5
5
|
H as callDowngrade,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const lazyUtils = require("./utils-
|
|
3
|
-
const index_esm = require("./index.esm-
|
|
2
|
+
const lazyUtils = require("./utils-tM9yE73c.js");
|
|
3
|
+
const index_esm = require("./index.esm-BWaKho-8.js");
|
|
4
4
|
const dataFetchFunction = async function(options) {
|
|
5
5
|
var _a, _b;
|
|
6
6
|
const [id, data, downgrade] = options;
|
|
@@ -76,38 +76,6 @@ function injectDataFetch() {
|
|
|
76
76
|
globalThis[lazyUtils.FS_HREF] = window.location.href;
|
|
77
77
|
dataFetch.push = dataFetchFunction;
|
|
78
78
|
}
|
|
79
|
-
function _extends$2() {
|
|
80
|
-
_extends$2 = Object.assign || function assign(target) {
|
|
81
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
82
|
-
var source = arguments[i];
|
|
83
|
-
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
84
|
-
}
|
|
85
|
-
return target;
|
|
86
|
-
};
|
|
87
|
-
return _extends$2.apply(this, arguments);
|
|
88
|
-
}
|
|
89
|
-
function _extends$1() {
|
|
90
|
-
_extends$1 = Object.assign || function assign(target) {
|
|
91
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
92
|
-
var source = arguments[i];
|
|
93
|
-
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
94
|
-
}
|
|
95
|
-
return target;
|
|
96
|
-
};
|
|
97
|
-
return _extends$1.apply(this, arguments);
|
|
98
|
-
}
|
|
99
|
-
function _object_without_properties_loose(source, excluded) {
|
|
100
|
-
if (source == null) return {};
|
|
101
|
-
var target = {};
|
|
102
|
-
var sourceKeys = Object.keys(source);
|
|
103
|
-
var key, i;
|
|
104
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
105
|
-
key = sourceKeys[i];
|
|
106
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
107
|
-
target[key] = source[key];
|
|
108
|
-
}
|
|
109
|
-
return target;
|
|
110
|
-
}
|
|
111
79
|
const RUNTIME_001 = "RUNTIME-001";
|
|
112
80
|
const RUNTIME_002 = "RUNTIME-002";
|
|
113
81
|
const RUNTIME_003 = "RUNTIME-003";
|
|
@@ -117,33 +85,16 @@ const RUNTIME_006 = "RUNTIME-006";
|
|
|
117
85
|
const RUNTIME_007 = "RUNTIME-007";
|
|
118
86
|
const RUNTIME_008 = "RUNTIME-008";
|
|
119
87
|
const RUNTIME_009 = "RUNTIME-009";
|
|
120
|
-
const TYPE_001 = "TYPE-001";
|
|
121
|
-
const BUILD_001 = "BUILD-001";
|
|
122
|
-
const BUILD_002 = "BUILD-002";
|
|
123
88
|
const getDocsUrl = (errorCode) => {
|
|
124
89
|
const type = errorCode.split("-")[0].toLowerCase();
|
|
125
90
|
return `View the docs to see how to solve: https://module-federation.io/guide/troubleshooting/${type}/${errorCode}`;
|
|
126
91
|
};
|
|
127
92
|
const getShortErrorMsg = (errorCode, errorDescMap, args, originalErrorMsg) => {
|
|
128
|
-
const msg = [
|
|
129
|
-
`${[
|
|
130
|
-
errorDescMap[errorCode]
|
|
131
|
-
]} #${errorCode}`
|
|
132
|
-
];
|
|
93
|
+
const msg = [`${[errorDescMap[errorCode]]} #${errorCode}`];
|
|
133
94
|
args && msg.push(`args: ${JSON.stringify(args)}`);
|
|
134
95
|
msg.push(getDocsUrl(errorCode));
|
|
135
96
|
return msg.join("\n");
|
|
136
97
|
};
|
|
137
|
-
function _extends() {
|
|
138
|
-
_extends = Object.assign || function assign(target) {
|
|
139
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
140
|
-
var source = arguments[i];
|
|
141
|
-
for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
|
|
142
|
-
}
|
|
143
|
-
return target;
|
|
144
|
-
};
|
|
145
|
-
return _extends.apply(this, arguments);
|
|
146
|
-
}
|
|
147
98
|
const runtimeDescMap = {
|
|
148
99
|
[RUNTIME_001]: "Failed to get remoteEntry exports.",
|
|
149
100
|
[RUNTIME_002]: 'The remote entry interface does not contain "init"',
|
|
@@ -155,14 +106,9 @@ const runtimeDescMap = {
|
|
|
155
106
|
[RUNTIME_008]: "Failed to load script resources.",
|
|
156
107
|
[RUNTIME_009]: "Please call createInstance first."
|
|
157
108
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
};
|
|
161
|
-
const buildDescMap = {
|
|
162
|
-
[BUILD_001]: "Failed to find expose module.",
|
|
163
|
-
[BUILD_002]: "PublicPath is required in prod mode."
|
|
164
|
-
};
|
|
165
|
-
_extends({}, runtimeDescMap, typeDescMap, buildDescMap);
|
|
109
|
+
({
|
|
110
|
+
...runtimeDescMap
|
|
111
|
+
});
|
|
166
112
|
const LOG_CATEGORY = "[ Federation Runtime ]";
|
|
167
113
|
const logger = index_esm.createLogger(LOG_CATEGORY);
|
|
168
114
|
function assert(condition, msg) {
|
|
@@ -202,7 +148,7 @@ const CurrentGlobal = typeof globalThis === "object" ? globalThis : window;
|
|
|
202
148
|
const nativeGlobal = (() => {
|
|
203
149
|
try {
|
|
204
150
|
return document.defaultView;
|
|
205
|
-
} catch
|
|
151
|
+
} catch {
|
|
206
152
|
return CurrentGlobal;
|
|
207
153
|
}
|
|
208
154
|
})();
|
|
@@ -222,7 +168,7 @@ if (!includeOwnProperty(CurrentGlobal, "__GLOBAL_LOADING_REMOTE_ENTRY__")) {
|
|
|
222
168
|
}
|
|
223
169
|
const globalLoading = CurrentGlobal.__GLOBAL_LOADING_REMOTE_ENTRY__;
|
|
224
170
|
function setGlobalDefaultVal(target) {
|
|
225
|
-
var
|
|
171
|
+
var _a, _b, _c, _d, _e, _f;
|
|
226
172
|
if (includeOwnProperty(target, "__VMOK__") && !includeOwnProperty(target, "__FEDERATION__")) {
|
|
227
173
|
definePropertyGlobalVal(target, "__FEDERATION__", target.__VMOK__);
|
|
228
174
|
}
|
|
@@ -237,18 +183,12 @@ function setGlobalDefaultVal(target) {
|
|
|
237
183
|
});
|
|
238
184
|
definePropertyGlobalVal(target, "__VMOK__", target.__FEDERATION__);
|
|
239
185
|
}
|
|
240
|
-
|
|
241
|
-
(
|
|
242
|
-
|
|
243
|
-
(
|
|
244
|
-
|
|
245
|
-
(
|
|
246
|
-
var ___SHARE__;
|
|
247
|
-
(___SHARE__ = (_target___FEDERATION__3 = target.__FEDERATION__).__SHARE__) != null ? ___SHARE__ : _target___FEDERATION__3.__SHARE__ = {};
|
|
248
|
-
var ___MANIFEST_LOADING__;
|
|
249
|
-
(___MANIFEST_LOADING__ = (_target___FEDERATION__4 = target.__FEDERATION__).__MANIFEST_LOADING__) != null ? ___MANIFEST_LOADING__ : _target___FEDERATION__4.__MANIFEST_LOADING__ = {};
|
|
250
|
-
var ___PRELOADED_MAP__;
|
|
251
|
-
(___PRELOADED_MAP__ = (_target___FEDERATION__5 = target.__FEDERATION__).__PRELOADED_MAP__) != null ? ___PRELOADED_MAP__ : _target___FEDERATION__5.__PRELOADED_MAP__ = /* @__PURE__ */ new Map();
|
|
186
|
+
(_a = target.__FEDERATION__).__GLOBAL_PLUGIN__ ?? (_a.__GLOBAL_PLUGIN__ = []);
|
|
187
|
+
(_b = target.__FEDERATION__).__INSTANCES__ ?? (_b.__INSTANCES__ = []);
|
|
188
|
+
(_c = target.__FEDERATION__).moduleInfo ?? (_c.moduleInfo = {});
|
|
189
|
+
(_d = target.__FEDERATION__).__SHARE__ ?? (_d.__SHARE__ = {});
|
|
190
|
+
(_e = target.__FEDERATION__).__MANIFEST_LOADING__ ?? (_e.__MANIFEST_LOADING__ = {});
|
|
191
|
+
(_f = target.__FEDERATION__).__PRELOADED_MAP__ ?? (_f.__PRELOADED_MAP__ = /* @__PURE__ */ new Map());
|
|
252
192
|
}
|
|
253
193
|
setGlobalDefaultVal(CurrentGlobal);
|
|
254
194
|
setGlobalDefaultVal(nativeGlobal);
|
|
@@ -271,7 +211,7 @@ function getGlobalFederationConstructor() {
|
|
|
271
211
|
function setGlobalFederationConstructor(FederationConstructor, isDebug = index_esm.isDebugMode()) {
|
|
272
212
|
if (isDebug) {
|
|
273
213
|
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR__ = FederationConstructor;
|
|
274
|
-
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.
|
|
214
|
+
CurrentGlobal.__FEDERATION__.__DEBUG_CONSTRUCTOR_VERSION__ = "0.21.0";
|
|
275
215
|
}
|
|
276
216
|
}
|
|
277
217
|
function getInfoWithoutType(target, key) {
|
|
@@ -315,9 +255,7 @@ const getTargetSnapshotInfoByModuleInfo = (moduleInfo, snapshot) => {
|
|
|
315
255
|
return getModuleInfo;
|
|
316
256
|
}
|
|
317
257
|
if ("version" in moduleInfo && moduleInfo["version"]) {
|
|
318
|
-
const { version
|
|
319
|
-
"version"
|
|
320
|
-
]);
|
|
258
|
+
const { version, ...resModuleInfo } = moduleInfo;
|
|
321
259
|
const moduleKeyWithoutVersion = getFMId(resModuleInfo);
|
|
322
260
|
const getModuleInfoWithoutVersion = getInfoWithoutType(nativeGlobal.__FEDERATION__.moduleInfo, moduleKeyWithoutVersion).value;
|
|
323
261
|
if ((getModuleInfoWithoutVersion == null ? void 0 : getModuleInfoWithoutVersion.version) === version) {
|
|
@@ -333,7 +271,10 @@ const setGlobalSnapshotInfoByModuleInfo = (remoteInfo, moduleDetailInfo) => {
|
|
|
333
271
|
return nativeGlobal.__FEDERATION__.moduleInfo;
|
|
334
272
|
};
|
|
335
273
|
const addGlobalSnapshot = (moduleInfos) => {
|
|
336
|
-
nativeGlobal.__FEDERATION__.moduleInfo =
|
|
274
|
+
nativeGlobal.__FEDERATION__.moduleInfo = {
|
|
275
|
+
...nativeGlobal.__FEDERATION__.moduleInfo,
|
|
276
|
+
...moduleInfos
|
|
277
|
+
};
|
|
337
278
|
return () => {
|
|
338
279
|
const keys = Object.keys(moduleInfos);
|
|
339
280
|
for (const key of keys) {
|
|
@@ -667,6 +608,7 @@ function satisfy(version, range) {
|
|
|
667
608
|
const versionAtom = {
|
|
668
609
|
operator: versionOperator,
|
|
669
610
|
version: combineVersion(versionMajor, versionMinor, versionPatch, versionPreRelease),
|
|
611
|
+
// exclude build atom
|
|
670
612
|
major: versionMajor,
|
|
671
613
|
minor: versionMinor,
|
|
672
614
|
patch: versionPatch,
|
|
@@ -805,9 +747,7 @@ function getRegisteredShare(localShareScopeMap, pkgName, shareInfo, resolveShare
|
|
|
805
747
|
return;
|
|
806
748
|
}
|
|
807
749
|
const { shareConfig, scope = DEFAULT_SCOPE, strategy } = shareInfo;
|
|
808
|
-
const scopes = Array.isArray(scope) ? scope : [
|
|
809
|
-
scope
|
|
810
|
-
];
|
|
750
|
+
const scopes = Array.isArray(scope) ? scope : [scope];
|
|
811
751
|
for (const sc of scopes) {
|
|
812
752
|
if (shareConfig && localShareScopeMap[sc] && localShareScopeMap[sc][pkgName]) {
|
|
813
753
|
const { requiredVersion } = shareConfig;
|
|
@@ -929,10 +869,7 @@ async function loadSystemJsEntry({ entry, remoteEntryExports }) {
|
|
|
929
869
|
if (typeof __system_context__ === "undefined") {
|
|
930
870
|
System.import(entry).then(resolve).catch(reject);
|
|
931
871
|
} else {
|
|
932
|
-
new Function("callbacks", `System.import("${entry}")${importCallback}`)([
|
|
933
|
-
resolve,
|
|
934
|
-
reject
|
|
935
|
-
]);
|
|
872
|
+
new Function("callbacks", `System.import("${entry}")${importCallback}`)([resolve, reject]);
|
|
936
873
|
}
|
|
937
874
|
} else {
|
|
938
875
|
resolve(remoteEntryExports);
|
|
@@ -960,11 +897,9 @@ async function loadEntryScript({ name, globalName, entry, loaderHook, getEntryUr
|
|
|
960
897
|
return index_esm.loadScript(url, {
|
|
961
898
|
attrs: {},
|
|
962
899
|
createScriptHook: (url2, attrs) => {
|
|
963
|
-
const res = loaderHook.lifecycle.createScript.emit({
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
});
|
|
967
|
-
if (!res) return;
|
|
900
|
+
const res = loaderHook.lifecycle.createScript.emit({ url: url2, attrs });
|
|
901
|
+
if (!res)
|
|
902
|
+
return;
|
|
968
903
|
if (res instanceof HTMLScriptElement) {
|
|
969
904
|
return res;
|
|
970
905
|
}
|
|
@@ -988,15 +923,9 @@ async function loadEntryDom({ remoteInfo, remoteEntryExports, loaderHook, getEnt
|
|
|
988
923
|
switch (type) {
|
|
989
924
|
case "esm":
|
|
990
925
|
case "module":
|
|
991
|
-
return loadEsmEntry({
|
|
992
|
-
entry,
|
|
993
|
-
remoteEntryExports
|
|
994
|
-
});
|
|
926
|
+
return loadEsmEntry({ entry, remoteEntryExports });
|
|
995
927
|
case "system":
|
|
996
|
-
return loadSystemJsEntry({
|
|
997
|
-
entry,
|
|
998
|
-
remoteEntryExports
|
|
999
|
-
});
|
|
928
|
+
return loadSystemJsEntry({ entry, remoteEntryExports });
|
|
1000
929
|
default:
|
|
1001
930
|
return loadEntryScript({
|
|
1002
931
|
entry,
|
|
@@ -1014,18 +943,12 @@ async function loadEntryNode({ remoteInfo, loaderHook }) {
|
|
|
1014
943
|
return remoteEntryExports;
|
|
1015
944
|
}
|
|
1016
945
|
return index_esm.loadScriptNode(entry, {
|
|
1017
|
-
attrs: {
|
|
1018
|
-
name,
|
|
1019
|
-
globalName,
|
|
1020
|
-
type
|
|
1021
|
-
},
|
|
946
|
+
attrs: { name, globalName, type },
|
|
1022
947
|
loaderHook: {
|
|
1023
948
|
createScriptHook: (url, attrs = {}) => {
|
|
1024
|
-
const res = loaderHook.lifecycle.createScript.emit({
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
});
|
|
1028
|
-
if (!res) return;
|
|
949
|
+
const res = loaderHook.lifecycle.createScript.emit({ url, attrs });
|
|
950
|
+
if (!res)
|
|
951
|
+
return;
|
|
1029
952
|
if ("url" in res) {
|
|
1030
953
|
return res;
|
|
1031
954
|
}
|
|
@@ -1043,7 +966,7 @@ function getRemoteEntryUniqueKey(remoteInfo) {
|
|
|
1043
966
|
return index_esm.composeKeyWithSeparator(name, entry);
|
|
1044
967
|
}
|
|
1045
968
|
async function getRemoteEntry(params) {
|
|
1046
|
-
const { origin, remoteEntryExports, remoteInfo, getEntryUrl } = params;
|
|
969
|
+
const { origin, remoteEntryExports, remoteInfo, getEntryUrl, _inErrorHandling = false } = params;
|
|
1047
970
|
const uniqueKey = getRemoteEntryUniqueKey(remoteInfo);
|
|
1048
971
|
if (remoteEntryExports) {
|
|
1049
972
|
return remoteEntryExports;
|
|
@@ -1065,21 +988,39 @@ async function getRemoteEntry(params) {
|
|
|
1065
988
|
remoteEntryExports,
|
|
1066
989
|
loaderHook,
|
|
1067
990
|
getEntryUrl
|
|
1068
|
-
}) : loadEntryNode({
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
991
|
+
}) : loadEntryNode({ remoteInfo, loaderHook });
|
|
992
|
+
}).catch(async (err) => {
|
|
993
|
+
const uniqueKey2 = getRemoteEntryUniqueKey(remoteInfo);
|
|
994
|
+
const isScriptLoadError = err instanceof Error && err.message.includes(RUNTIME_008);
|
|
995
|
+
if (isScriptLoadError && !_inErrorHandling) {
|
|
996
|
+
const wrappedGetRemoteEntry = (params2) => {
|
|
997
|
+
return getRemoteEntry({ ...params2, _inErrorHandling: true });
|
|
998
|
+
};
|
|
999
|
+
const RemoteEntryExports = await origin.loaderHook.lifecycle.loadEntryError.emit({
|
|
1000
|
+
getRemoteEntry: wrappedGetRemoteEntry,
|
|
1001
|
+
origin,
|
|
1002
|
+
remoteInfo,
|
|
1003
|
+
remoteEntryExports,
|
|
1004
|
+
globalLoading,
|
|
1005
|
+
uniqueKey: uniqueKey2
|
|
1006
|
+
});
|
|
1007
|
+
if (RemoteEntryExports) {
|
|
1008
|
+
return RemoteEntryExports;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
throw err;
|
|
1072
1012
|
});
|
|
1073
1013
|
}
|
|
1074
1014
|
return globalLoading[uniqueKey];
|
|
1075
1015
|
}
|
|
1076
1016
|
function getRemoteInfo(remote) {
|
|
1077
|
-
return
|
|
1017
|
+
return {
|
|
1018
|
+
...remote,
|
|
1078
1019
|
entry: "entry" in remote ? remote.entry : "",
|
|
1079
1020
|
type: remote.type || DEFAULT_REMOTE_TYPE,
|
|
1080
1021
|
entryGlobalName: remote.entryGlobalName || remote.name,
|
|
1081
1022
|
shareScope: remote.shareScope || DEFAULT_SCOPE
|
|
1082
|
-
}
|
|
1023
|
+
};
|
|
1083
1024
|
}
|
|
1084
1025
|
function preloadAssets(remoteInfo, host, assets, useLinkPreload = true) {
|
|
1085
1026
|
const { cssAssets, jsAssetsWithoutEntry, entryAssets } = assets;
|
|
@@ -1236,29 +1177,12 @@ var helpers$1 = {
|
|
|
1236
1177
|
}
|
|
1237
1178
|
};
|
|
1238
1179
|
typeof FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN === "boolean" ? !FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN : true;
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
if (buildId && GMInstance.options.id === buildId) {
|
|
1246
|
-
return true;
|
|
1247
|
-
}
|
|
1248
|
-
if (GMInstance.options.name === name && !GMInstance.options.version && !version) {
|
|
1249
|
-
return true;
|
|
1250
|
-
}
|
|
1251
|
-
if (GMInstance.options.name === name && version && GMInstance.options.version === version) {
|
|
1252
|
-
return true;
|
|
1253
|
-
}
|
|
1254
|
-
return false;
|
|
1255
|
-
});
|
|
1256
|
-
}
|
|
1257
|
-
var helpers = _extends$2({}, helpers$1, {
|
|
1258
|
-
global: _extends$2({}, helpers$1.global, {
|
|
1259
|
-
getGlobalFederationInstance
|
|
1260
|
-
})
|
|
1261
|
-
});
|
|
1180
|
+
var helpers = {
|
|
1181
|
+
...helpers$1,
|
|
1182
|
+
global: {
|
|
1183
|
+
...helpers$1.global
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1262
1186
|
async function prefetch(options) {
|
|
1263
1187
|
const { instance, id, dataFetchParams, preloadComponentResource } = options;
|
|
1264
1188
|
if (!id) {
|