@module-federation/modern-js 0.14.2 → 0.15.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/LICENSE +21 -0
- package/dist/cjs/cli/configPlugin.js +381 -0
- package/dist/cjs/cli/configPlugin.spec.js +114 -0
- package/dist/cjs/cli/index.js +95 -0
- package/dist/cjs/cli/mfRuntimePlugins/auto-fetch-data.js +98 -0
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +44 -0
- package/dist/cjs/cli/mfRuntimePlugins/resolve-entry-ipv4.js +82 -0
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +43 -0
- package/dist/cjs/cli/server/data-fetch-server-plugin.js +189 -0
- package/dist/cjs/cli/ssrPlugin.js +236 -0
- package/dist/cjs/cli/utils.js +90 -0
- package/dist/cjs/constant.js +78 -0
- package/dist/cjs/interfaces/bundler.js +16 -0
- package/dist/cjs/interfaces/global.js +16 -0
- package/dist/cjs/logger.js +27 -0
- package/dist/cjs/runtime/AwaitDataFetch.js +144 -0
- package/dist/cjs/runtime/createRemoteComponent.js +327 -0
- package/dist/cjs/runtime/index.js +50 -0
- package/dist/cjs/runtime/wrapNoSSR.js +35 -0
- package/dist/cjs/server/fileCache.js +84 -0
- package/dist/cjs/server/fileCache.spec.js +28 -0
- package/dist/cjs/server/index.js +58 -0
- package/dist/cjs/server/staticMiddleware.js +77 -0
- package/dist/cjs/server/staticMiddleware.spec.js +185 -0
- package/dist/cjs/ssr-runtime/SSRLiveReload.js +43 -0
- package/dist/cjs/ssr-runtime/devPlugin.js +71 -0
- package/dist/cjs/ssr-runtime/downgrade.js +114 -0
- package/dist/cjs/ssr-runtime/injectDataFetchFunctionPlugin.js +136 -0
- package/dist/cjs/types/index.js +16 -0
- package/dist/cjs/utils/dataFetch.js +211 -0
- package/dist/cjs/utils/index.js +54 -0
- package/dist/esm/cli/configPlugin.js +388 -0
- package/dist/esm/cli/configPlugin.spec.js +110 -0
- package/dist/esm/cli/index.js +90 -0
- package/dist/esm/cli/mfRuntimePlugins/auto-fetch-data.js +74 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +16 -0
- package/dist/esm/cli/mfRuntimePlugins/resolve-entry-ipv4.js +74 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +25 -0
- package/dist/esm/cli/server/data-fetch-server-plugin.js +237 -0
- package/dist/esm/cli/ssrPlugin.js +219 -0
- package/dist/esm/cli/utils.js +53 -0
- package/dist/esm/constant.js +42 -0
- package/dist/esm/interfaces/bundler.js +0 -0
- package/dist/esm/interfaces/global.js +0 -0
- package/dist/esm/logger.js +7 -0
- package/dist/esm/runtime/AwaitDataFetch.js +131 -0
- package/dist/esm/runtime/createRemoteComponent.js +417 -0
- package/dist/esm/runtime/index.js +22 -0
- package/dist/esm/runtime/wrapNoSSR.js +12 -0
- package/dist/esm/server/fileCache.js +98 -0
- package/dist/esm/server/fileCache.spec.js +50 -0
- package/dist/esm/server/index.js +36 -0
- package/dist/esm/server/staticMiddleware.js +81 -0
- package/dist/esm/server/staticMiddleware.spec.js +328 -0
- package/dist/esm/ssr-runtime/SSRLiveReload.js +26 -0
- package/dist/esm/ssr-runtime/devPlugin.js +73 -0
- package/dist/esm/ssr-runtime/downgrade.js +150 -0
- package/dist/esm/ssr-runtime/injectDataFetchFunctionPlugin.js +177 -0
- package/dist/esm/types/index.js +0 -0
- package/dist/esm/utils/dataFetch.js +237 -0
- package/dist/esm/utils/index.js +28 -0
- package/dist/esm-node/cli/configPlugin.js +340 -0
- package/dist/esm-node/cli/configPlugin.spec.js +91 -0
- package/dist/esm-node/cli/index.js +70 -0
- package/dist/esm-node/cli/mfRuntimePlugins/auto-fetch-data.js +68 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +14 -0
- package/dist/esm-node/cli/mfRuntimePlugins/resolve-entry-ipv4.js +62 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +23 -0
- package/dist/esm-node/cli/server/data-fetch-server-plugin.js +159 -0
- package/dist/esm-node/cli/ssrPlugin.js +200 -0
- package/dist/esm-node/cli/utils.js +53 -0
- package/dist/esm-node/constant.js +42 -0
- package/dist/esm-node/interfaces/bundler.js +0 -0
- package/dist/esm-node/interfaces/global.js +0 -0
- package/dist/esm-node/logger.js +7 -0
- package/dist/esm-node/runtime/AwaitDataFetch.js +109 -0
- package/dist/esm-node/runtime/createRemoteComponent.js +291 -0
- package/dist/esm-node/runtime/index.js +22 -0
- package/dist/esm-node/runtime/wrapNoSSR.js +11 -0
- package/dist/esm-node/server/fileCache.js +49 -0
- package/dist/esm-node/server/fileCache.spec.js +27 -0
- package/dist/esm-node/server/index.js +34 -0
- package/dist/esm-node/server/staticMiddleware.js +43 -0
- package/dist/esm-node/server/staticMiddleware.spec.js +162 -0
- package/dist/esm-node/ssr-runtime/SSRLiveReload.js +19 -0
- package/dist/esm-node/ssr-runtime/devPlugin.js +37 -0
- package/dist/esm-node/ssr-runtime/downgrade.js +88 -0
- package/dist/esm-node/ssr-runtime/injectDataFetchFunctionPlugin.js +101 -0
- package/dist/esm-node/types/index.js +0 -0
- package/dist/esm-node/utils/dataFetch.js +166 -0
- package/dist/esm-node/utils/index.js +27 -0
- package/dist/types/cli/configPlugin.d.ts +21 -0
- package/dist/types/cli/configPlugin.spec.d.ts +1 -0
- package/dist/types/cli/index.d.ts +6 -0
- package/dist/types/cli/mfRuntimePlugins/auto-fetch-data.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/resolve-entry-ipv4.d.ts +3 -0
- package/dist/types/cli/mfRuntimePlugins/shared-strategy.d.ts +3 -0
- package/dist/types/cli/server/data-fetch-server-plugin.d.ts +3 -0
- package/dist/types/cli/ssrPlugin.d.ts +6 -0
- package/dist/types/cli/utils.d.ts +6 -0
- package/dist/types/constant.d.ts +25 -0
- package/dist/types/interfaces/bundler.d.ts +18 -0
- package/dist/types/interfaces/global.d.ts +27 -0
- package/dist/types/logger.d.ts +2 -0
- package/dist/types/runtime/AwaitDataFetch.d.ts +19 -0
- package/dist/types/runtime/createRemoteComponent.d.ts +26 -0
- package/dist/types/runtime/index.d.ts +10 -0
- package/dist/types/runtime/wrapNoSSR.d.ts +9 -0
- package/dist/types/server/fileCache.d.ts +14 -0
- package/dist/types/server/fileCache.spec.d.ts +1 -0
- package/dist/types/server/index.d.ts +4 -0
- package/dist/types/server/staticMiddleware.d.ts +6 -0
- package/dist/types/server/staticMiddleware.spec.d.ts +1 -0
- package/dist/types/ssr-runtime/SSRLiveReload.d.ts +1 -0
- package/dist/types/ssr-runtime/devPlugin.d.ts +2 -0
- package/dist/types/ssr-runtime/downgrade.d.ts +4 -0
- package/dist/types/ssr-runtime/injectDataFetchFunctionPlugin.d.ts +7 -0
- package/dist/types/types/index.d.ts +24 -0
- package/dist/types/utils/dataFetch.d.ts +26 -0
- package/dist/types/utils/index.d.ts +15 -0
- package/package.json +37 -12
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var dataFetch_exports = {};
|
|
30
|
+
__export(dataFetch_exports, {
|
|
31
|
+
fetchData: () => fetchData,
|
|
32
|
+
flushDataFetch: () => flushDataFetch,
|
|
33
|
+
getDataFetchIdWithErrorMsgs: () => getDataFetchIdWithErrorMsgs,
|
|
34
|
+
getDataFetchInfo: () => getDataFetchInfo,
|
|
35
|
+
getDataFetchItem: () => getDataFetchItem,
|
|
36
|
+
getDataFetchMap: () => getDataFetchMap,
|
|
37
|
+
getDataFetchMapKey: () => getDataFetchMapKey,
|
|
38
|
+
initDataFetchMap: () => initDataFetchMap,
|
|
39
|
+
isDataLoaderExpose: () => isDataLoaderExpose,
|
|
40
|
+
loadDataFetchModule: () => loadDataFetchModule,
|
|
41
|
+
setDataFetchItemLoadedStatus: () => setDataFetchItemLoadedStatus,
|
|
42
|
+
wrapDataFetchId: () => wrapDataFetchId
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(dataFetch_exports);
|
|
45
|
+
var import_sdk = require("@module-federation/sdk");
|
|
46
|
+
var import_utils = require("../utils");
|
|
47
|
+
var import_logger = __toESM(require("../logger"));
|
|
48
|
+
var import_downgrade = require("../ssr-runtime/downgrade");
|
|
49
|
+
var import_constant = require("../constant");
|
|
50
|
+
var import_constant2 = require("@module-federation/rsbuild-plugin/constant");
|
|
51
|
+
const getDataFetchInfo = ({ name, alias, id, remoteSnapshot }) => {
|
|
52
|
+
if (!remoteSnapshot) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!("modules" in remoteSnapshot)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const regex = new RegExp(`^${name}(/[^/].*|)$`);
|
|
59
|
+
const nameOrAlias = regex.test(id) ? name : alias || name;
|
|
60
|
+
const expose = id.replace(nameOrAlias, "");
|
|
61
|
+
let dataFetchName = "";
|
|
62
|
+
let dataFetchId = "";
|
|
63
|
+
if (expose.startsWith("/")) {
|
|
64
|
+
dataFetchName = `${expose.slice(1)}.${import_constant2.DATA_FETCH_IDENTIFIER}`;
|
|
65
|
+
dataFetchId = `${id}.${import_constant2.DATA_FETCH_IDENTIFIER}`;
|
|
66
|
+
} else if (expose === "") {
|
|
67
|
+
dataFetchName = import_constant2.DATA_FETCH_IDENTIFIER;
|
|
68
|
+
dataFetchId = `${id}/${import_constant2.DATA_FETCH_IDENTIFIER}`;
|
|
69
|
+
} else {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (!dataFetchName || !dataFetchId) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!remoteSnapshot.modules.find((module2) => module2.moduleName === dataFetchName)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
dataFetchName,
|
|
80
|
+
dataFetchId
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
function initDataFetchMap() {
|
|
84
|
+
var _globalThis;
|
|
85
|
+
(_globalThis = globalThis).__MF_DATA_FETCH_MAP__ || (_globalThis.__MF_DATA_FETCH_MAP__ = {});
|
|
86
|
+
}
|
|
87
|
+
function getDataFetchItem(id) {
|
|
88
|
+
var _globalThis___MF_DATA_FETCH_MAP__;
|
|
89
|
+
return (_globalThis___MF_DATA_FETCH_MAP__ = globalThis.__MF_DATA_FETCH_MAP__) === null || _globalThis___MF_DATA_FETCH_MAP__ === void 0 ? void 0 : _globalThis___MF_DATA_FETCH_MAP__[id];
|
|
90
|
+
}
|
|
91
|
+
function getDataFetchMap() {
|
|
92
|
+
return globalThis.__MF_DATA_FETCH_MAP__;
|
|
93
|
+
}
|
|
94
|
+
const flushDataFetch = () => {
|
|
95
|
+
globalThis.__MF_DATA_FETCH_MAP__ = {};
|
|
96
|
+
globalThis[import_constant.DOWNGRADE_KEY] = void 0;
|
|
97
|
+
};
|
|
98
|
+
function setDataFetchItemLoadedStatus(id) {
|
|
99
|
+
const dataFetchItem = getDataFetchItem(id);
|
|
100
|
+
if (!dataFetchItem) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
dataFetchItem[2] = import_constant.MF_DATA_FETCH_STATUS.LOADED;
|
|
104
|
+
}
|
|
105
|
+
const wrapDataFetchId = (id) => {
|
|
106
|
+
return `${import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER}${id}${import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER}`;
|
|
107
|
+
};
|
|
108
|
+
const getDataFetchIdWithErrorMsgs = (errMsgs) => {
|
|
109
|
+
const firstIdentifierIndex = errMsgs.indexOf(import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER);
|
|
110
|
+
if (firstIdentifierIndex === -1) {
|
|
111
|
+
return void 0;
|
|
112
|
+
}
|
|
113
|
+
const secondIdentifierIndex = errMsgs.indexOf(import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER, firstIdentifierIndex + import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER.length);
|
|
114
|
+
if (secondIdentifierIndex === -1) {
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
return errMsgs.substring(firstIdentifierIndex + import_constant.WRAP_DATA_FETCH_ID_IDENTIFIER.length, secondIdentifierIndex);
|
|
118
|
+
};
|
|
119
|
+
async function fetchData(id, params, remoteInfo) {
|
|
120
|
+
const callFetchData = async () => {
|
|
121
|
+
const item = getDataFetchItem(id);
|
|
122
|
+
if (!item) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const [fetchDataFnArr, ..._rest] = item;
|
|
126
|
+
const fetchDataFn = await fetchDataFnArr[2];
|
|
127
|
+
if (!fetchDataFn) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
return fetchDataFn(params);
|
|
131
|
+
};
|
|
132
|
+
if ((0, import_sdk.isBrowserEnv)()) {
|
|
133
|
+
var _dataFetchItem_;
|
|
134
|
+
const dataFetchItem = getDataFetchItem(id);
|
|
135
|
+
if (!dataFetchItem) {
|
|
136
|
+
throw new Error(`dataFetchItem not found, id: ${id}`);
|
|
137
|
+
}
|
|
138
|
+
if ((_dataFetchItem_ = dataFetchItem[1]) === null || _dataFetchItem_ === void 0 ? void 0 : _dataFetchItem_[0]) {
|
|
139
|
+
return dataFetchItem[1][0];
|
|
140
|
+
}
|
|
141
|
+
if ((0, import_utils.isCSROnly)()) {
|
|
142
|
+
import_logger.default.debug("==========csr only!");
|
|
143
|
+
return callFetchData();
|
|
144
|
+
}
|
|
145
|
+
if (remoteInfo) {
|
|
146
|
+
return (0, import_downgrade.callDowngrade)(id, params, remoteInfo);
|
|
147
|
+
}
|
|
148
|
+
const mfDowngrade = (0, import_downgrade.getDowngradeTag)();
|
|
149
|
+
if (mfDowngrade) {
|
|
150
|
+
if (typeof mfDowngrade === "boolean") {
|
|
151
|
+
return (0, import_downgrade.callDowngrade)(id, {
|
|
152
|
+
...params,
|
|
153
|
+
isDowngrade: true
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
if (mfDowngrade.includes(id)) {
|
|
157
|
+
return (0, import_downgrade.callDowngrade)(id, {
|
|
158
|
+
...params,
|
|
159
|
+
isDowngrade: true
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
let res;
|
|
164
|
+
let rej;
|
|
165
|
+
const p = new Promise((resolve, reject) => {
|
|
166
|
+
res = resolve;
|
|
167
|
+
rej = reject;
|
|
168
|
+
});
|
|
169
|
+
dataFetchItem[1] = [
|
|
170
|
+
p,
|
|
171
|
+
res,
|
|
172
|
+
rej
|
|
173
|
+
];
|
|
174
|
+
dataFetchItem[2] = import_constant.MF_DATA_FETCH_STATUS.AWAIT;
|
|
175
|
+
return dataFetchItem[1][0];
|
|
176
|
+
}
|
|
177
|
+
return callFetchData();
|
|
178
|
+
}
|
|
179
|
+
function getDataFetchMapKey(dataFetchInfo, hostInfo) {
|
|
180
|
+
if (!dataFetchInfo || !hostInfo) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
const { dataFetchId } = dataFetchInfo;
|
|
184
|
+
return (0, import_sdk.composeKeyWithSeparator)(dataFetchId, hostInfo.name, hostInfo.version);
|
|
185
|
+
}
|
|
186
|
+
async function loadDataFetchModule(instance, id) {
|
|
187
|
+
return instance.loadRemote(id).then((m) => {
|
|
188
|
+
if (m && typeof m === "object" && "fetchData" in m && typeof m.fetchData === "function") {
|
|
189
|
+
return m.fetchData;
|
|
190
|
+
}
|
|
191
|
+
throw new Error(`fetchData not found in remote ${id}, ${JSON.stringify(m)}`);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function isDataLoaderExpose(exposeKey) {
|
|
195
|
+
return exposeKey.endsWith(import_constant2.DATA_FETCH_IDENTIFIER) || exposeKey.endsWith(import_constant2.DATA_FETCH_CLIENT_SUFFIX);
|
|
196
|
+
}
|
|
197
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
198
|
+
0 && (module.exports = {
|
|
199
|
+
fetchData,
|
|
200
|
+
flushDataFetch,
|
|
201
|
+
getDataFetchIdWithErrorMsgs,
|
|
202
|
+
getDataFetchInfo,
|
|
203
|
+
getDataFetchItem,
|
|
204
|
+
getDataFetchMap,
|
|
205
|
+
getDataFetchMapKey,
|
|
206
|
+
initDataFetchMap,
|
|
207
|
+
isDataLoaderExpose,
|
|
208
|
+
loadDataFetchModule,
|
|
209
|
+
setDataFetchItemLoadedStatus,
|
|
210
|
+
wrapDataFetchId
|
|
211
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
getLoadedRemoteInfos: () => getLoadedRemoteInfos,
|
|
23
|
+
isCSROnly: () => isCSROnly
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
__reExport(utils_exports, require("./dataFetch"), module.exports);
|
|
27
|
+
function getLoadedRemoteInfos(id, instance) {
|
|
28
|
+
if (!instance) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const { name, expose } = instance.remoteHandler.idToRemoteMap[id] || {};
|
|
32
|
+
if (!name) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const module2 = instance.moduleCache.get(name);
|
|
36
|
+
if (!module2) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const { remoteSnapshot } = instance.snapshotHandler.getGlobalRemoteInfo(module2.remoteInfo);
|
|
40
|
+
return {
|
|
41
|
+
...module2.remoteInfo,
|
|
42
|
+
snapshot: remoteSnapshot,
|
|
43
|
+
expose
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function isCSROnly() {
|
|
47
|
+
return window._SSR_DATA === void 0;
|
|
48
|
+
}
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
getLoadedRemoteInfos,
|
|
52
|
+
isCSROnly,
|
|
53
|
+
...require("./dataFetch")
|
|
54
|
+
});
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
+
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
5
|
+
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
6
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { getIPV4, isWebTarget, skipByTarget } from "./utils";
|
|
9
|
+
import { encodeName } from "@module-federation/sdk";
|
|
10
|
+
import { bundle } from "@modern-js/node-bundle-require";
|
|
11
|
+
import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant";
|
|
12
|
+
import { autoDeleteSplitChunkCacheGroups, addDataFetchExposes } from "@module-federation/rsbuild-plugin/utils";
|
|
13
|
+
import logger from "../logger";
|
|
14
|
+
import { isDev } from "./utils";
|
|
15
|
+
var defaultPath = path.resolve(process.cwd(), "module-federation.config.ts");
|
|
16
|
+
function setEnv(enableSSR) {
|
|
17
|
+
if (enableSSR) {
|
|
18
|
+
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
19
|
+
process.env["MF_SSR_PRJ"] = "true";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
var getMFConfig = function() {
|
|
23
|
+
var _ref = _async_to_generator(function(userConfig) {
|
|
24
|
+
var config, configPath, mfConfigPath, preBundlePath, mfConfig;
|
|
25
|
+
return _ts_generator(this, function(_state) {
|
|
26
|
+
switch (_state.label) {
|
|
27
|
+
case 0:
|
|
28
|
+
config = userConfig.config, configPath = userConfig.configPath;
|
|
29
|
+
if (config) {
|
|
30
|
+
return [
|
|
31
|
+
2,
|
|
32
|
+
config
|
|
33
|
+
];
|
|
34
|
+
}
|
|
35
|
+
mfConfigPath = configPath ? configPath : defaultPath;
|
|
36
|
+
return [
|
|
37
|
+
4,
|
|
38
|
+
bundle(mfConfigPath)
|
|
39
|
+
];
|
|
40
|
+
case 1:
|
|
41
|
+
preBundlePath = _state.sent();
|
|
42
|
+
return [
|
|
43
|
+
4,
|
|
44
|
+
import(preBundlePath)
|
|
45
|
+
];
|
|
46
|
+
case 2:
|
|
47
|
+
mfConfig = _state.sent().default;
|
|
48
|
+
return [
|
|
49
|
+
2,
|
|
50
|
+
mfConfig
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
return function getMFConfig2(userConfig) {
|
|
56
|
+
return _ref.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
}();
|
|
59
|
+
var injectRuntimePlugins = function(runtimePlugin, runtimePlugins) {
|
|
60
|
+
if (!runtimePlugins.includes(runtimePlugin)) {
|
|
61
|
+
runtimePlugins.push(runtimePlugin);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var replaceRemoteUrl = function(mfConfig, remoteIpStrategy) {
|
|
65
|
+
if (remoteIpStrategy && remoteIpStrategy === "inherit") {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (!mfConfig.remotes) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
var ipv4 = getIPV4();
|
|
72
|
+
var handleRemoteObject = function(remoteObject) {
|
|
73
|
+
Object.keys(remoteObject).forEach(function(remoteKey) {
|
|
74
|
+
var remote = remoteObject[remoteKey];
|
|
75
|
+
if (Array.isArray(remote)) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
if (typeof remote === "string" && remote.includes(LOCALHOST)) {
|
|
79
|
+
remoteObject[remoteKey] = remote.replace(LOCALHOST, ipv4);
|
|
80
|
+
}
|
|
81
|
+
if ((typeof remote === "undefined" ? "undefined" : _type_of(remote)) === "object" && !Array.isArray(remote.external) && remote.external.includes(LOCALHOST)) {
|
|
82
|
+
remote.external = remote.external.replace(LOCALHOST, ipv4);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
};
|
|
86
|
+
if (Array.isArray(mfConfig.remotes)) {
|
|
87
|
+
mfConfig.remotes.forEach(function(remoteObject) {
|
|
88
|
+
if (typeof remoteObject === "string") {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
handleRemoteObject(remoteObject);
|
|
92
|
+
});
|
|
93
|
+
} else if (typeof mfConfig.remotes !== "string") {
|
|
94
|
+
handleRemoteObject(mfConfig.remotes);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var patchDTSConfig = function(mfConfig, isServer) {
|
|
98
|
+
if (isServer) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var ModernJSRuntime = "@module-federation/modern-js/runtime";
|
|
102
|
+
if (mfConfig.dts !== false) {
|
|
103
|
+
var _mfConfig_dts, _mfConfig_dts1;
|
|
104
|
+
if (typeof mfConfig.dts === "boolean" || mfConfig.dts === void 0) {
|
|
105
|
+
mfConfig.dts = {
|
|
106
|
+
consumeTypes: {
|
|
107
|
+
runtimePkgs: [
|
|
108
|
+
ModernJSRuntime
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
} else if (((_mfConfig_dts = mfConfig.dts) === null || _mfConfig_dts === void 0 ? void 0 : _mfConfig_dts.consumeTypes) || ((_mfConfig_dts1 = mfConfig.dts) === null || _mfConfig_dts1 === void 0 ? void 0 : _mfConfig_dts1.consumeTypes) === void 0) {
|
|
113
|
+
var _mfConfig_dts2;
|
|
114
|
+
if (typeof mfConfig.dts.consumeTypes === "boolean" || ((_mfConfig_dts2 = mfConfig.dts) === null || _mfConfig_dts2 === void 0 ? void 0 : _mfConfig_dts2.consumeTypes) === void 0) {
|
|
115
|
+
mfConfig.dts.consumeTypes = {
|
|
116
|
+
runtimePkgs: [
|
|
117
|
+
ModernJSRuntime
|
|
118
|
+
]
|
|
119
|
+
};
|
|
120
|
+
} else {
|
|
121
|
+
mfConfig.dts.consumeTypes.runtimePkgs = mfConfig.dts.consumeTypes.runtimePkgs || [];
|
|
122
|
+
if (!mfConfig.dts.consumeTypes.runtimePkgs.includes(ModernJSRuntime)) {
|
|
123
|
+
mfConfig.dts.consumeTypes.runtimePkgs.push(ModernJSRuntime);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
var patchMFConfig = function(mfConfig, isServer, remoteIpStrategy, enableSSR) {
|
|
130
|
+
replaceRemoteUrl(mfConfig, remoteIpStrategy);
|
|
131
|
+
addDataFetchExposes(mfConfig.exposes, isServer);
|
|
132
|
+
if (mfConfig.remoteType === void 0) {
|
|
133
|
+
mfConfig.remoteType = "script";
|
|
134
|
+
}
|
|
135
|
+
if (!mfConfig.name) {
|
|
136
|
+
throw new Error("".concat(PLUGIN_IDENTIFIER, " mfConfig.name can not be empty!"));
|
|
137
|
+
}
|
|
138
|
+
var runtimePlugins = _to_consumable_array(mfConfig.runtimePlugins || []);
|
|
139
|
+
patchDTSConfig(mfConfig, isServer);
|
|
140
|
+
injectRuntimePlugins(require.resolve("@module-federation/modern-js/shared-strategy"), runtimePlugins);
|
|
141
|
+
injectRuntimePlugins(require.resolve("@module-federation/modern-js/auto-fetch-data"), runtimePlugins);
|
|
142
|
+
if (enableSSR && isDev()) {
|
|
143
|
+
injectRuntimePlugins(require.resolve("@module-federation/modern-js/resolve-entry-ipv4"), runtimePlugins);
|
|
144
|
+
}
|
|
145
|
+
if (isServer) {
|
|
146
|
+
injectRuntimePlugins(require.resolve("@module-federation/node/runtimePlugin"), runtimePlugins);
|
|
147
|
+
if (isDev()) {
|
|
148
|
+
injectRuntimePlugins(require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin"), runtimePlugins);
|
|
149
|
+
}
|
|
150
|
+
injectRuntimePlugins(require.resolve("@module-federation/modern-js/inject-node-fetch"), runtimePlugins);
|
|
151
|
+
if (!mfConfig.library) {
|
|
152
|
+
mfConfig.library = {
|
|
153
|
+
type: "commonjs-module",
|
|
154
|
+
name: mfConfig.name
|
|
155
|
+
};
|
|
156
|
+
} else {
|
|
157
|
+
if (!mfConfig.library.type) {
|
|
158
|
+
mfConfig.library.type = "commonjs-module";
|
|
159
|
+
}
|
|
160
|
+
if (!mfConfig.library.name) {
|
|
161
|
+
mfConfig.library.name = mfConfig.name;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
mfConfig.runtimePlugins = runtimePlugins;
|
|
166
|
+
if (!isServer) {
|
|
167
|
+
var _mfConfig_library;
|
|
168
|
+
if (((_mfConfig_library = mfConfig.library) === null || _mfConfig_library === void 0 ? void 0 : _mfConfig_library.type) === "commonjs-module") {
|
|
169
|
+
mfConfig.library.type = "global";
|
|
170
|
+
}
|
|
171
|
+
return mfConfig;
|
|
172
|
+
}
|
|
173
|
+
mfConfig.dts = false;
|
|
174
|
+
mfConfig.dev = false;
|
|
175
|
+
return mfConfig;
|
|
176
|
+
};
|
|
177
|
+
function patchIgnoreWarning(chain) {
|
|
178
|
+
var ignoreWarnings = chain.get("ignoreWarnings") || [];
|
|
179
|
+
var ignoredMsgs = [
|
|
180
|
+
"external script",
|
|
181
|
+
"process.env.WS_NO_BUFFER_UTIL",
|
|
182
|
+
"Can't resolve 'utf-8-validate"
|
|
183
|
+
];
|
|
184
|
+
ignoreWarnings.push(function(warning) {
|
|
185
|
+
if (ignoredMsgs.some(function(msg) {
|
|
186
|
+
return warning.message.includes(msg);
|
|
187
|
+
})) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
return false;
|
|
191
|
+
});
|
|
192
|
+
chain.ignoreWarnings(ignoreWarnings);
|
|
193
|
+
}
|
|
194
|
+
function addMyTypes2Ignored(chain, mfConfig) {
|
|
195
|
+
var watchOptions = chain.get("watchOptions");
|
|
196
|
+
if (!watchOptions || !watchOptions.ignored) {
|
|
197
|
+
chain.watchOptions({
|
|
198
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
var ignored = watchOptions.ignored;
|
|
203
|
+
var DEFAULT_IGNORED_GLOB = "**/@mf-types/**";
|
|
204
|
+
if (Array.isArray(ignored)) {
|
|
205
|
+
if (mfConfig.dts !== false && _type_of(mfConfig.dts) === "object" && _type_of(mfConfig.dts.consumeTypes) === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
206
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
207
|
+
ignored: ignored.concat("**/".concat(mfConfig.dts.consumeTypes.remoteTypesFolder, "/**"))
|
|
208
|
+
}));
|
|
209
|
+
} else {
|
|
210
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
211
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
212
|
+
}));
|
|
213
|
+
}
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (typeof ignored !== "string") {
|
|
217
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
218
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
219
|
+
}));
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
223
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
function patchBundlerConfig(options) {
|
|
227
|
+
var _modernjsConfig_deploy;
|
|
228
|
+
var chain = options.chain, modernjsConfig = options.modernjsConfig, isServer = options.isServer, mfConfig = options.mfConfig, enableSSR = options.enableSSR;
|
|
229
|
+
chain.optimization.delete("runtimeChunk");
|
|
230
|
+
patchIgnoreWarning(chain);
|
|
231
|
+
if (!chain.output.get("chunkLoadingGlobal")) {
|
|
232
|
+
chain.output.chunkLoadingGlobal("chunk_".concat(mfConfig.name));
|
|
233
|
+
}
|
|
234
|
+
if (!chain.output.get("uniqueName")) {
|
|
235
|
+
chain.output.uniqueName(mfConfig.name);
|
|
236
|
+
}
|
|
237
|
+
var splitChunkConfig = chain.optimization.splitChunks.entries();
|
|
238
|
+
if (!isServer) {
|
|
239
|
+
autoDeleteSplitChunkCacheGroups(mfConfig, splitChunkConfig);
|
|
240
|
+
}
|
|
241
|
+
if (!isServer && enableSSR && splitChunkConfig && (typeof splitChunkConfig === "undefined" ? "undefined" : _type_of(splitChunkConfig)) === "object" && splitChunkConfig.cacheGroups) {
|
|
242
|
+
splitChunkConfig.chunks = "async";
|
|
243
|
+
logger.warn('splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
|
|
244
|
+
}
|
|
245
|
+
if (isDev() && chain.output.get("publicPath") === "auto") {
|
|
246
|
+
var _modernjsConfig_dev, _modernjsConfig_server;
|
|
247
|
+
var port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.port) || 8080;
|
|
248
|
+
var publicPath = "http://localhost:".concat(port, "/");
|
|
249
|
+
chain.output.publicPath(publicPath);
|
|
250
|
+
}
|
|
251
|
+
if (isServer && enableSSR) {
|
|
252
|
+
var uniqueName = mfConfig.name || chain.output.get("uniqueName");
|
|
253
|
+
var chunkFileName = chain.output.get("chunkFilename");
|
|
254
|
+
if (typeof chunkFileName === "string" && uniqueName && !chunkFileName.includes(uniqueName)) {
|
|
255
|
+
var suffix = "".concat(encodeName(uniqueName), "-[chunkhash].js");
|
|
256
|
+
chain.output.chunkFilename(chunkFileName.replace(".js", suffix));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (isDev() && enableSSR && !isServer) {
|
|
260
|
+
chain.resolve.fallback.set("crypto", false).set("stream", false).set("vm", false);
|
|
261
|
+
}
|
|
262
|
+
if (((_modernjsConfig_deploy = modernjsConfig.deploy) === null || _modernjsConfig_deploy === void 0 ? void 0 : _modernjsConfig_deploy.microFrontend) && Object.keys(mfConfig.exposes || {}).length) {
|
|
263
|
+
chain.optimization.usedExports(false);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
var moduleFederationConfigPlugin = function(userConfig) {
|
|
267
|
+
return {
|
|
268
|
+
name: "@modern-js/plugin-module-federation-config",
|
|
269
|
+
pre: [
|
|
270
|
+
"@modern-js/plugin-initialize"
|
|
271
|
+
],
|
|
272
|
+
post: [
|
|
273
|
+
"@modern-js/plugin-module-federation"
|
|
274
|
+
],
|
|
275
|
+
setup: function() {
|
|
276
|
+
var _ref = _async_to_generator(function(api) {
|
|
277
|
+
var _userConfig_userConfig, _modernjsConfig_server, modernjsConfig, mfConfig, csrConfig, ssrConfig, _userConfig_userConfig_ssr, enableSSR;
|
|
278
|
+
return _ts_generator(this, function(_state) {
|
|
279
|
+
switch (_state.label) {
|
|
280
|
+
case 0:
|
|
281
|
+
modernjsConfig = api.getConfig();
|
|
282
|
+
return [
|
|
283
|
+
4,
|
|
284
|
+
getMFConfig(userConfig.originPluginOptions)
|
|
285
|
+
];
|
|
286
|
+
case 1:
|
|
287
|
+
mfConfig = _state.sent();
|
|
288
|
+
csrConfig = userConfig.csrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
289
|
+
ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
290
|
+
userConfig.ssrConfig = ssrConfig;
|
|
291
|
+
userConfig.csrConfig = csrConfig;
|
|
292
|
+
enableSSR = Boolean((_userConfig_userConfig_ssr = (_userConfig_userConfig = userConfig.userConfig) === null || _userConfig_userConfig === void 0 ? void 0 : _userConfig_userConfig.ssr) !== null && _userConfig_userConfig_ssr !== void 0 ? _userConfig_userConfig_ssr : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr));
|
|
293
|
+
api.modifyBundlerChain(function(chain) {
|
|
294
|
+
var target = chain.get("target");
|
|
295
|
+
if (skipByTarget(target)) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
var isWeb = isWebTarget(target);
|
|
299
|
+
addMyTypes2Ignored(chain, !isWeb ? ssrConfig : csrConfig);
|
|
300
|
+
var targetMFConfig = !isWeb ? ssrConfig : csrConfig;
|
|
301
|
+
patchMFConfig(targetMFConfig, !isWeb, userConfig.remoteIpStrategy || "ipv4", enableSSR);
|
|
302
|
+
patchBundlerConfig({
|
|
303
|
+
chain,
|
|
304
|
+
isServer: !isWeb,
|
|
305
|
+
modernjsConfig,
|
|
306
|
+
mfConfig,
|
|
307
|
+
enableSSR
|
|
308
|
+
});
|
|
309
|
+
userConfig.distOutputDir = chain.output.get("path") || path.resolve(process.cwd(), "dist");
|
|
310
|
+
});
|
|
311
|
+
api.config(function() {
|
|
312
|
+
var _modernjsConfig_tools, _userConfig_csrConfig, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
313
|
+
var bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
314
|
+
var ipv4 = getIPV4();
|
|
315
|
+
if (userConfig.remoteIpStrategy === void 0) {
|
|
316
|
+
if (!enableSSR) {
|
|
317
|
+
userConfig.remoteIpStrategy = "inherit";
|
|
318
|
+
} else {
|
|
319
|
+
userConfig.remoteIpStrategy = "ipv4";
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
var devServerConfig = (_modernjsConfig_tools = modernjsConfig.tools) === null || _modernjsConfig_tools === void 0 ? void 0 : _modernjsConfig_tools.devServer;
|
|
323
|
+
var corsWarnMsgs = [
|
|
324
|
+
"View https://module-federation.io/guide/troubleshooting/other.html#cors-warn for more details."
|
|
325
|
+
];
|
|
326
|
+
if ((typeof devServerConfig === "undefined" ? "undefined" : _type_of(devServerConfig)) !== "object" || !("headers" in devServerConfig)) {
|
|
327
|
+
corsWarnMsgs.unshift('Detect devServer.headers is empty, mf modern plugin will add default cors header: devServer.headers["Access-Control-Allow-Headers"] = "*". It is recommended to specify an allowlist of trusted origins instead.');
|
|
328
|
+
}
|
|
329
|
+
var exposes = (_userConfig_csrConfig = userConfig.csrConfig) === null || _userConfig_csrConfig === void 0 ? void 0 : _userConfig_csrConfig.exposes;
|
|
330
|
+
var hasExposes = exposes && Array.isArray(exposes) ? exposes.length : Object.keys(exposes !== null && exposes !== void 0 ? exposes : {}).length;
|
|
331
|
+
if (corsWarnMsgs.length > 1 && hasExposes) {
|
|
332
|
+
logger.warn(corsWarnMsgs.join("\n"));
|
|
333
|
+
}
|
|
334
|
+
var corsHeaders = hasExposes ? {
|
|
335
|
+
"Access-Control-Allow-Origin": "*",
|
|
336
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
337
|
+
"Access-Control-Allow-Headers": "*"
|
|
338
|
+
} : void 0;
|
|
339
|
+
var defineConfig = {
|
|
340
|
+
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
341
|
+
};
|
|
342
|
+
if (enableSSR && isDev()) {
|
|
343
|
+
defineConfig["FEDERATION_IPV4"] = JSON.stringify(ipv4);
|
|
344
|
+
}
|
|
345
|
+
var _modernjsConfig_source_enableAsyncEntry;
|
|
346
|
+
return {
|
|
347
|
+
tools: {
|
|
348
|
+
devServer: {
|
|
349
|
+
headers: corsHeaders
|
|
350
|
+
}
|
|
351
|
+
},
|
|
352
|
+
source: {
|
|
353
|
+
alias: {
|
|
354
|
+
// TODO: deprecated
|
|
355
|
+
"@modern-js/runtime/mf": require.resolve("@module-federation/modern-js/runtime")
|
|
356
|
+
},
|
|
357
|
+
define: defineConfig,
|
|
358
|
+
enableAsyncEntry: bundlerType === "rspack" ? (_modernjsConfig_source_enableAsyncEntry = (_modernjsConfig_source = modernjsConfig.source) === null || _modernjsConfig_source === void 0 ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== null && _modernjsConfig_source_enableAsyncEntry !== void 0 ? _modernjsConfig_source_enableAsyncEntry : true : (_modernjsConfig_source1 = modernjsConfig.source) === null || _modernjsConfig_source1 === void 0 ? void 0 : _modernjsConfig_source1.enableAsyncEntry
|
|
359
|
+
},
|
|
360
|
+
dev: {
|
|
361
|
+
assetPrefix: (modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : true
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
});
|
|
365
|
+
return [
|
|
366
|
+
2
|
|
367
|
+
];
|
|
368
|
+
}
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
return function(api) {
|
|
372
|
+
return _ref.apply(this, arguments);
|
|
373
|
+
};
|
|
374
|
+
}()
|
|
375
|
+
};
|
|
376
|
+
};
|
|
377
|
+
var configPlugin_default = moduleFederationConfigPlugin;
|
|
378
|
+
export {
|
|
379
|
+
addMyTypes2Ignored,
|
|
380
|
+
configPlugin_default as default,
|
|
381
|
+
getMFConfig,
|
|
382
|
+
isWebTarget,
|
|
383
|
+
moduleFederationConfigPlugin,
|
|
384
|
+
patchBundlerConfig,
|
|
385
|
+
patchMFConfig,
|
|
386
|
+
setEnv,
|
|
387
|
+
skipByTarget
|
|
388
|
+
};
|