@module-federation/modern-js 0.0.0-next-20241127081350 → 0.0.0-next-20241205062623
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/cjs/cli/configPlugin.js +3 -0
- package/dist/cjs/cli/utils.js +40 -29
- package/dist/cjs/cli/utils.spec.js +0 -10
- package/dist/esm/cli/configPlugin.js +5 -1
- package/dist/esm/cli/utils.js +35 -29
- package/dist/esm/cli/utils.spec.js +0 -10
- package/dist/esm-node/cli/configPlugin.js +4 -1
- package/dist/esm-node/cli/utils.js +39 -29
- package/dist/esm-node/cli/utils.spec.js +0 -10
- package/dist/types/cli/utils.d.ts +3 -2
- package/dist/types/interfaces/bundler.d.ts +4 -1
- package/package.json +5 -5
|
@@ -84,6 +84,9 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
84
84
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
85
85
|
return {
|
|
86
86
|
tools: {
|
|
87
|
+
bundlerChain(chain, { isServer }) {
|
|
88
|
+
(0, import_utils.addMyTypes2Ignored)(chain, isServer ? ssrConfig : csrConfig);
|
|
89
|
+
},
|
|
87
90
|
rspack(config, { isServer }) {
|
|
88
91
|
var _config_output;
|
|
89
92
|
modifyBundlerConfig({
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var utils_exports = {};
|
|
30
30
|
__export(utils_exports, {
|
|
31
|
+
addMyTypes2Ignored: () => addMyTypes2Ignored,
|
|
31
32
|
getIPV4: () => getIPV4,
|
|
32
33
|
getMFConfig: () => getMFConfig,
|
|
33
34
|
patchBundlerConfig: () => patchBundlerConfig,
|
|
@@ -35,9 +36,9 @@ __export(utils_exports, {
|
|
|
35
36
|
patchMFConfig: () => patchMFConfig
|
|
36
37
|
});
|
|
37
38
|
module.exports = __toCommonJS(utils_exports);
|
|
38
|
-
var import_sdk = require("@module-federation/sdk");
|
|
39
|
-
var import_path = __toESM(require("path"));
|
|
40
39
|
var import_os = __toESM(require("os"));
|
|
40
|
+
var import_path = __toESM(require("path"));
|
|
41
|
+
var import_sdk = require("@module-federation/sdk");
|
|
41
42
|
var import_node_bundle_require = require("@modern-js/node-bundle-require");
|
|
42
43
|
var import_constant = require("../constant");
|
|
43
44
|
var import_logger = __toESM(require("./logger"));
|
|
@@ -185,39 +186,48 @@ function patchIgnoreWarning(bundlerConfig) {
|
|
|
185
186
|
return false;
|
|
186
187
|
});
|
|
187
188
|
}
|
|
189
|
+
function addMyTypes2Ignored(chain, mfConfig) {
|
|
190
|
+
const watchOptions = chain.get("watchOptions");
|
|
191
|
+
if (!watchOptions || !watchOptions.ignored) {
|
|
192
|
+
chain.watchOptions({
|
|
193
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
194
|
+
});
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const ignored = watchOptions.ignored;
|
|
198
|
+
const DEFAULT_IGNORED_GLOB = "**/@mf-types/**";
|
|
199
|
+
if (Array.isArray(ignored)) {
|
|
200
|
+
if (mfConfig.dts !== false && typeof mfConfig.dts === "object" && typeof mfConfig.dts.consumeTypes === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
201
|
+
chain.watchOptions({
|
|
202
|
+
...watchOptions,
|
|
203
|
+
ignored: ignored.concat(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`)
|
|
204
|
+
});
|
|
205
|
+
} else {
|
|
206
|
+
chain.watchOptions({
|
|
207
|
+
...watchOptions,
|
|
208
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (typeof ignored !== "string") {
|
|
214
|
+
chain.watchOptions({
|
|
215
|
+
...watchOptions,
|
|
216
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
217
|
+
});
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
chain.watchOptions({
|
|
221
|
+
...watchOptions,
|
|
222
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
223
|
+
});
|
|
224
|
+
}
|
|
188
225
|
function patchBundlerConfig(options) {
|
|
189
226
|
var _modernjsConfig_server, _bundlerConfig_optimization, _bundlerConfig_optimization1, _bundlerConfig_output, _modernjsConfig_deploy;
|
|
190
227
|
const { bundlerConfig, modernjsConfig, isServer, mfConfig, bundlerType } = options;
|
|
191
228
|
const enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
192
229
|
(_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? true : delete _bundlerConfig_optimization.runtimeChunk;
|
|
193
230
|
patchIgnoreWarning(bundlerConfig);
|
|
194
|
-
if (bundlerType === "webpack") {
|
|
195
|
-
bundlerConfig.watchOptions = bundlerConfig.watchOptions || {};
|
|
196
|
-
if (!Array.isArray(bundlerConfig.watchOptions.ignored)) {
|
|
197
|
-
if (bundlerConfig.watchOptions.ignored) {
|
|
198
|
-
if (typeof bundlerConfig.watchOptions.ignored !== "string") {
|
|
199
|
-
import_logger.default.warn(`Detect you have set watchOptions.ignore as regexp, please transform it to glob string array and add "**/@mf-types/**" to the array.`);
|
|
200
|
-
} else {
|
|
201
|
-
bundlerConfig.watchOptions.ignored = [
|
|
202
|
-
bundlerConfig.watchOptions.ignored
|
|
203
|
-
];
|
|
204
|
-
}
|
|
205
|
-
} else {
|
|
206
|
-
bundlerConfig.watchOptions.ignored = [];
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (Array.isArray(bundlerConfig.watchOptions.ignored)) {
|
|
210
|
-
if (mfConfig.dts !== false) {
|
|
211
|
-
if (typeof mfConfig.dts === "object" && typeof mfConfig.dts.consumeTypes === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
212
|
-
bundlerConfig.watchOptions.ignored.push(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`);
|
|
213
|
-
} else {
|
|
214
|
-
bundlerConfig.watchOptions.ignored.push("**/@mf-types/**");
|
|
215
|
-
}
|
|
216
|
-
} else {
|
|
217
|
-
bundlerConfig.watchOptions.ignored.push("**/@mf-types/**");
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
231
|
if (bundlerConfig.output) {
|
|
222
232
|
var _bundlerConfig_output1, _bundlerConfig_output2;
|
|
223
233
|
if (!((_bundlerConfig_output1 = bundlerConfig.output) === null || _bundlerConfig_output1 === void 0 ? void 0 : _bundlerConfig_output1.chunkLoadingGlobal)) {
|
|
@@ -332,6 +342,7 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
|
|
|
332
342
|
}
|
|
333
343
|
// Annotate the CommonJS export names for ESM import in node:
|
|
334
344
|
0 && (module.exports = {
|
|
345
|
+
addMyTypes2Ignored,
|
|
335
346
|
getIPV4,
|
|
336
347
|
getMFConfig,
|
|
337
348
|
patchBundlerConfig,
|
|
@@ -134,11 +134,6 @@ const mfConfig = {
|
|
|
134
134
|
chunkLoadingGlobal: "chunk_host",
|
|
135
135
|
publicPath: "auto",
|
|
136
136
|
uniqueName: "host"
|
|
137
|
-
},
|
|
138
|
-
watchOptions: {
|
|
139
|
-
ignored: [
|
|
140
|
-
"**/@mf-types/**"
|
|
141
|
-
]
|
|
142
137
|
}
|
|
143
138
|
};
|
|
144
139
|
bundlerConfig === null || bundlerConfig === void 0 ? true : delete bundlerConfig.ignoreWarnings;
|
|
@@ -168,11 +163,6 @@ const mfConfig = {
|
|
|
168
163
|
chunkLoadingGlobal: "chunk_host",
|
|
169
164
|
publicPath: "auto",
|
|
170
165
|
uniqueName: "host"
|
|
171
|
-
},
|
|
172
|
-
watchOptions: {
|
|
173
|
-
ignored: [
|
|
174
|
-
"**/@mf-types/**"
|
|
175
|
-
]
|
|
176
166
|
}
|
|
177
167
|
};
|
|
178
168
|
bundlerConfig === null || bundlerConfig === void 0 ? true : delete bundlerConfig.ignoreWarnings;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
3
|
import path from "path";
|
|
4
|
-
import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig } from "./utils";
|
|
4
|
+
import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored } from "./utils";
|
|
5
5
|
function setEnv(enableSSR) {
|
|
6
6
|
if (enableSSR) {
|
|
7
7
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
@@ -66,6 +66,10 @@ var moduleFederationConfigPlugin = function(userConfig) {
|
|
|
66
66
|
2,
|
|
67
67
|
{
|
|
68
68
|
tools: {
|
|
69
|
+
bundlerChain: function bundlerChain(chain, param2) {
|
|
70
|
+
var isServer = param2.isServer;
|
|
71
|
+
addMyTypes2Ignored(chain, isServer ? ssrConfig : csrConfig);
|
|
72
|
+
},
|
|
69
73
|
rspack: function rspack(config, param2) {
|
|
70
74
|
var isServer = param2.isServer;
|
|
71
75
|
var _config_output;
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -4,9 +4,9 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
4
4
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
5
5
|
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
6
6
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
7
|
-
import { encodeName } from "@module-federation/sdk";
|
|
8
|
-
import path from "path";
|
|
9
7
|
import os from "os";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { encodeName } from "@module-federation/sdk";
|
|
10
10
|
import { bundle } from "@modern-js/node-bundle-require";
|
|
11
11
|
import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant";
|
|
12
12
|
import logger from "./logger";
|
|
@@ -181,39 +181,44 @@ function patchIgnoreWarning(bundlerConfig) {
|
|
|
181
181
|
return false;
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
+
function addMyTypes2Ignored(chain, mfConfig) {
|
|
185
|
+
var watchOptions = chain.get("watchOptions");
|
|
186
|
+
if (!watchOptions || !watchOptions.ignored) {
|
|
187
|
+
chain.watchOptions({
|
|
188
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
189
|
+
});
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
var ignored = watchOptions.ignored;
|
|
193
|
+
var DEFAULT_IGNORED_GLOB = "**/@mf-types/**";
|
|
194
|
+
if (Array.isArray(ignored)) {
|
|
195
|
+
if (mfConfig.dts !== false && _type_of(mfConfig.dts) === "object" && _type_of(mfConfig.dts.consumeTypes) === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
196
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
197
|
+
ignored: ignored.concat("**/".concat(mfConfig.dts.consumeTypes.remoteTypesFolder, "/**"))
|
|
198
|
+
}));
|
|
199
|
+
} else {
|
|
200
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
201
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
202
|
+
}));
|
|
203
|
+
}
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (typeof ignored !== "string") {
|
|
207
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
208
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
209
|
+
}));
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
chain.watchOptions(_object_spread_props(_object_spread({}, watchOptions), {
|
|
213
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
214
|
+
}));
|
|
215
|
+
}
|
|
184
216
|
function patchBundlerConfig(options) {
|
|
185
217
|
var _modernjsConfig_server, _bundlerConfig_optimization, _bundlerConfig_optimization1, _bundlerConfig_output, _modernjsConfig_deploy;
|
|
186
218
|
var bundlerConfig = options.bundlerConfig, modernjsConfig = options.modernjsConfig, isServer = options.isServer, mfConfig = options.mfConfig, bundlerType = options.bundlerType;
|
|
187
219
|
var enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
188
220
|
(_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? true : delete _bundlerConfig_optimization.runtimeChunk;
|
|
189
221
|
patchIgnoreWarning(bundlerConfig);
|
|
190
|
-
if (bundlerType === "webpack") {
|
|
191
|
-
bundlerConfig.watchOptions = bundlerConfig.watchOptions || {};
|
|
192
|
-
if (!Array.isArray(bundlerConfig.watchOptions.ignored)) {
|
|
193
|
-
if (bundlerConfig.watchOptions.ignored) {
|
|
194
|
-
if (typeof bundlerConfig.watchOptions.ignored !== "string") {
|
|
195
|
-
logger.warn('Detect you have set watchOptions.ignore as regexp, please transform it to glob string array and add "**/@mf-types/**" to the array.');
|
|
196
|
-
} else {
|
|
197
|
-
bundlerConfig.watchOptions.ignored = [
|
|
198
|
-
bundlerConfig.watchOptions.ignored
|
|
199
|
-
];
|
|
200
|
-
}
|
|
201
|
-
} else {
|
|
202
|
-
bundlerConfig.watchOptions.ignored = [];
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
if (Array.isArray(bundlerConfig.watchOptions.ignored)) {
|
|
206
|
-
if (mfConfig.dts !== false) {
|
|
207
|
-
if (_type_of(mfConfig.dts) === "object" && _type_of(mfConfig.dts.consumeTypes) === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
208
|
-
bundlerConfig.watchOptions.ignored.push("**/".concat(mfConfig.dts.consumeTypes.remoteTypesFolder, "/**"));
|
|
209
|
-
} else {
|
|
210
|
-
bundlerConfig.watchOptions.ignored.push("**/@mf-types/**");
|
|
211
|
-
}
|
|
212
|
-
} else {
|
|
213
|
-
bundlerConfig.watchOptions.ignored.push("**/@mf-types/**");
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
222
|
if (bundlerConfig.output) {
|
|
218
223
|
var _bundlerConfig_output1, _bundlerConfig_output2;
|
|
219
224
|
if (!((_bundlerConfig_output1 = bundlerConfig.output) === null || _bundlerConfig_output1 === void 0 ? void 0 : _bundlerConfig_output1.chunkLoadingGlobal)) {
|
|
@@ -343,6 +348,7 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
|
|
|
343
348
|
}
|
|
344
349
|
}
|
|
345
350
|
export {
|
|
351
|
+
addMyTypes2Ignored,
|
|
346
352
|
getIPV4,
|
|
347
353
|
getMFConfig,
|
|
348
354
|
patchBundlerConfig,
|
|
@@ -133,11 +133,6 @@ describe("patchBundlerConfig", /* @__PURE__ */ _async_to_generator(function() {
|
|
|
133
133
|
chunkLoadingGlobal: "chunk_host",
|
|
134
134
|
publicPath: "auto",
|
|
135
135
|
uniqueName: "host"
|
|
136
|
-
},
|
|
137
|
-
watchOptions: {
|
|
138
|
-
ignored: [
|
|
139
|
-
"**/@mf-types/**"
|
|
140
|
-
]
|
|
141
136
|
}
|
|
142
137
|
};
|
|
143
138
|
bundlerConfig === null || bundlerConfig === void 0 ? true : delete bundlerConfig.ignoreWarnings;
|
|
@@ -173,11 +168,6 @@ describe("patchBundlerConfig", /* @__PURE__ */ _async_to_generator(function() {
|
|
|
173
168
|
chunkLoadingGlobal: "chunk_host",
|
|
174
169
|
publicPath: "auto",
|
|
175
170
|
uniqueName: "host"
|
|
176
|
-
},
|
|
177
|
-
watchOptions: {
|
|
178
|
-
ignored: [
|
|
179
|
-
"**/@mf-types/**"
|
|
180
|
-
]
|
|
181
171
|
}
|
|
182
172
|
};
|
|
183
173
|
bundlerConfig === null || bundlerConfig === void 0 ? true : delete bundlerConfig.ignoreWarnings;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "path";
|
|
2
|
-
import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig } from "./utils";
|
|
2
|
+
import { patchBundlerConfig, getIPV4, getMFConfig, patchMFConfig, addMyTypes2Ignored } from "./utils";
|
|
3
3
|
function setEnv(enableSSR) {
|
|
4
4
|
if (enableSSR) {
|
|
5
5
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
@@ -48,6 +48,9 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
48
48
|
var _modernjsConfig_source_enableAsyncEntry;
|
|
49
49
|
return {
|
|
50
50
|
tools: {
|
|
51
|
+
bundlerChain(chain, { isServer }) {
|
|
52
|
+
addMyTypes2Ignored(chain, isServer ? ssrConfig : csrConfig);
|
|
53
|
+
},
|
|
51
54
|
rspack(config, { isServer }) {
|
|
52
55
|
var _config_output;
|
|
53
56
|
modifyBundlerConfig({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { encodeName } from "@module-federation/sdk";
|
|
2
|
-
import path from "path";
|
|
3
1
|
import os from "os";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { encodeName } from "@module-federation/sdk";
|
|
4
4
|
import { bundle } from "@modern-js/node-bundle-require";
|
|
5
5
|
import { LOCALHOST, PLUGIN_IDENTIFIER } from "../constant";
|
|
6
6
|
import logger from "./logger";
|
|
@@ -148,39 +148,48 @@ function patchIgnoreWarning(bundlerConfig) {
|
|
|
148
148
|
return false;
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
|
+
function addMyTypes2Ignored(chain, mfConfig) {
|
|
152
|
+
const watchOptions = chain.get("watchOptions");
|
|
153
|
+
if (!watchOptions || !watchOptions.ignored) {
|
|
154
|
+
chain.watchOptions({
|
|
155
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
156
|
+
});
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const ignored = watchOptions.ignored;
|
|
160
|
+
const DEFAULT_IGNORED_GLOB = "**/@mf-types/**";
|
|
161
|
+
if (Array.isArray(ignored)) {
|
|
162
|
+
if (mfConfig.dts !== false && typeof mfConfig.dts === "object" && typeof mfConfig.dts.consumeTypes === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
163
|
+
chain.watchOptions({
|
|
164
|
+
...watchOptions,
|
|
165
|
+
ignored: ignored.concat(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`)
|
|
166
|
+
});
|
|
167
|
+
} else {
|
|
168
|
+
chain.watchOptions({
|
|
169
|
+
...watchOptions,
|
|
170
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (typeof ignored !== "string") {
|
|
176
|
+
chain.watchOptions({
|
|
177
|
+
...watchOptions,
|
|
178
|
+
ignored: /[\\/](?:\.git|node_modules|@mf-types)[\\/]/
|
|
179
|
+
});
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
chain.watchOptions({
|
|
183
|
+
...watchOptions,
|
|
184
|
+
ignored: ignored.concat(DEFAULT_IGNORED_GLOB)
|
|
185
|
+
});
|
|
186
|
+
}
|
|
151
187
|
function patchBundlerConfig(options) {
|
|
152
188
|
var _modernjsConfig_server, _bundlerConfig_optimization, _bundlerConfig_optimization1, _bundlerConfig_output, _modernjsConfig_deploy;
|
|
153
189
|
const { bundlerConfig, modernjsConfig, isServer, mfConfig, bundlerType } = options;
|
|
154
190
|
const enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
155
191
|
(_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? true : delete _bundlerConfig_optimization.runtimeChunk;
|
|
156
192
|
patchIgnoreWarning(bundlerConfig);
|
|
157
|
-
if (bundlerType === "webpack") {
|
|
158
|
-
bundlerConfig.watchOptions = bundlerConfig.watchOptions || {};
|
|
159
|
-
if (!Array.isArray(bundlerConfig.watchOptions.ignored)) {
|
|
160
|
-
if (bundlerConfig.watchOptions.ignored) {
|
|
161
|
-
if (typeof bundlerConfig.watchOptions.ignored !== "string") {
|
|
162
|
-
logger.warn(`Detect you have set watchOptions.ignore as regexp, please transform it to glob string array and add "**/@mf-types/**" to the array.`);
|
|
163
|
-
} else {
|
|
164
|
-
bundlerConfig.watchOptions.ignored = [
|
|
165
|
-
bundlerConfig.watchOptions.ignored
|
|
166
|
-
];
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
bundlerConfig.watchOptions.ignored = [];
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (Array.isArray(bundlerConfig.watchOptions.ignored)) {
|
|
173
|
-
if (mfConfig.dts !== false) {
|
|
174
|
-
if (typeof mfConfig.dts === "object" && typeof mfConfig.dts.consumeTypes === "object" && mfConfig.dts.consumeTypes.remoteTypesFolder) {
|
|
175
|
-
bundlerConfig.watchOptions.ignored.push(`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`);
|
|
176
|
-
} else {
|
|
177
|
-
bundlerConfig.watchOptions.ignored.push("**/@mf-types/**");
|
|
178
|
-
}
|
|
179
|
-
} else {
|
|
180
|
-
bundlerConfig.watchOptions.ignored.push("**/@mf-types/**");
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
193
|
if (bundlerConfig.output) {
|
|
185
194
|
var _bundlerConfig_output1, _bundlerConfig_output2;
|
|
186
195
|
if (!((_bundlerConfig_output1 = bundlerConfig.output) === null || _bundlerConfig_output1 === void 0 ? void 0 : _bundlerConfig_output1.chunkLoadingGlobal)) {
|
|
@@ -294,6 +303,7 @@ function autoDeleteSplitChunkCacheGroups(mfConfig, bundlerConfig) {
|
|
|
294
303
|
}
|
|
295
304
|
}
|
|
296
305
|
export {
|
|
306
|
+
addMyTypes2Ignored,
|
|
297
307
|
getIPV4,
|
|
298
308
|
getMFConfig,
|
|
299
309
|
patchBundlerConfig,
|
|
@@ -111,11 +111,6 @@ describe("patchBundlerConfig", async () => {
|
|
|
111
111
|
chunkLoadingGlobal: "chunk_host",
|
|
112
112
|
publicPath: "auto",
|
|
113
113
|
uniqueName: "host"
|
|
114
|
-
},
|
|
115
|
-
watchOptions: {
|
|
116
|
-
ignored: [
|
|
117
|
-
"**/@mf-types/**"
|
|
118
|
-
]
|
|
119
114
|
}
|
|
120
115
|
};
|
|
121
116
|
bundlerConfig === null || bundlerConfig === void 0 ? true : delete bundlerConfig.ignoreWarnings;
|
|
@@ -145,11 +140,6 @@ describe("patchBundlerConfig", async () => {
|
|
|
145
140
|
chunkLoadingGlobal: "chunk_host",
|
|
146
141
|
publicPath: "auto",
|
|
147
142
|
uniqueName: "host"
|
|
148
|
-
},
|
|
149
|
-
watchOptions: {
|
|
150
|
-
ignored: [
|
|
151
|
-
"**/@mf-types/**"
|
|
152
|
-
]
|
|
153
143
|
}
|
|
154
144
|
};
|
|
155
145
|
bundlerConfig === null || bundlerConfig === void 0 ? true : delete bundlerConfig.ignoreWarnings;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import type { webpack, UserConfig, AppTools, Rspack, Bundler } from '@modern-js/app-tools';
|
|
2
1
|
import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
2
|
import { PluginOptions } from '../types';
|
|
4
|
-
import { BundlerConfig } from '../interfaces/bundler';
|
|
3
|
+
import type { BundlerConfig, BundlerChainConfig } from '../interfaces/bundler';
|
|
4
|
+
import type { webpack, UserConfig, AppTools, Rspack, Bundler } from '@modern-js/app-tools';
|
|
5
5
|
export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T extends 'rspack' ? Rspack.Configuration : never;
|
|
6
6
|
export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
|
|
7
7
|
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean, remoteIpStrategy?: "ipv4" | "inherit") => moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
8
8
|
export declare function patchIgnoreWarning<T extends Bundler>(bundlerConfig: BundlerConfig<T>): void;
|
|
9
|
+
export declare function addMyTypes2Ignored(chain: BundlerChainConfig, mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions): void;
|
|
9
10
|
export declare function patchBundlerConfig<T extends Bundler>(options: {
|
|
10
11
|
bundlerConfig: BundlerConfig<T>;
|
|
11
12
|
isServer: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AppTools, Bundler } from '@modern-js/app-tools';
|
|
1
|
+
import type { AppTools, Bundler, UserConfig } from '@modern-js/app-tools';
|
|
2
2
|
type AppToolsUserConfig<T extends Bundler> = AppTools<T>['userConfig']['tools'];
|
|
3
3
|
type ExcludeUndefined<T> = T extends undefined ? never : T;
|
|
4
4
|
type ExtractObjectType<T> = T extends (...args: any[]) => any ? never : T;
|
|
@@ -11,5 +11,8 @@ type RspackConfigs = ExcludeUndefined<AppToolsUserConfig<'rspack'>> extends {
|
|
|
11
11
|
rspack?: infer U;
|
|
12
12
|
} ? U : never;
|
|
13
13
|
type ObjectRspack = ExtractObjectType<OmitArrayConfiguration<RspackConfigs>>;
|
|
14
|
+
type BundlerChain = ExcludeUndefined<ExcludeUndefined<UserConfig<AppTools>['tools']>['bundlerChain']>;
|
|
15
|
+
type BundlerChainFunc = Extract<BundlerChain, (chain: any, utils: any) => any>;
|
|
16
|
+
export type BundlerChainConfig = Parameters<BundlerChainFunc>[0];
|
|
14
17
|
export type BundlerConfig<T extends Bundler> = T extends 'rspack' ? ObjectRspack : ObjectWebpack;
|
|
15
18
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20241205062623",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"hoist-non-react-statics": "3.3.2",
|
|
86
86
|
"node-fetch": "~3.3.0",
|
|
87
87
|
"react-error-boundary": "4.0.13",
|
|
88
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
89
|
-
"@module-federation/node": "0.0.0-next-
|
|
90
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
88
|
+
"@module-federation/enhanced": "0.0.0-next-20241205062623",
|
|
89
|
+
"@module-federation/node": "0.0.0-next-20241205062623",
|
|
90
|
+
"@module-federation/sdk": "0.0.0-next-20241205062623"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@modern-js/app-tools": "2.60.6",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@modern-js/runtime": "2.60.6",
|
|
97
97
|
"@modern-js/tsconfig": "2.60.6",
|
|
98
98
|
"@types/hoist-non-react-statics": "3.3.5",
|
|
99
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
99
|
+
"@module-federation/manifest": "0.0.0-next-20241205062623"
|
|
100
100
|
},
|
|
101
101
|
"peerDependencies": {
|
|
102
102
|
"react": ">=17",
|