Skip to content

Commit d5c783b

Browse files
authored
fix: print warn if user set watchOptions.ignored value as regexp type (#3286)
1 parent a60f117 commit d5c783b

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

.changeset/beige-terms-check.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/modern-js': patch
3+
---
4+
5+
fix: print warn if user set watchOptions.ignored value as regexp type

packages/modernjs/src/cli/utils.ts

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -241,29 +241,39 @@ export function patchBundlerConfig<T extends Bundler>(options: {
241241
bundlerConfig.watchOptions = bundlerConfig.watchOptions || {};
242242
if (!Array.isArray(bundlerConfig.watchOptions.ignored)) {
243243
if (bundlerConfig.watchOptions.ignored) {
244-
bundlerConfig.watchOptions.ignored = [
245-
bundlerConfig.watchOptions.ignored as string,
246-
];
244+
if (typeof bundlerConfig.watchOptions.ignored !== 'string') {
245+
logger.warn(
246+
`Detect you have set watchOptions.ignore as regexp, please transform it to glob string array and add "**/@mf-types/**" to the array.`,
247+
);
248+
} else {
249+
bundlerConfig.watchOptions.ignored = [
250+
bundlerConfig.watchOptions.ignored,
251+
];
252+
}
247253
} else {
248254
bundlerConfig.watchOptions.ignored = [];
249255
}
250256
}
251-
if (mfConfig.dts !== false) {
252-
if (
253-
typeof mfConfig.dts === 'object' &&
254-
typeof mfConfig.dts.consumeTypes === 'object' &&
255-
mfConfig.dts.consumeTypes.remoteTypesFolder
256-
) {
257-
bundlerConfig.watchOptions.ignored.push(
258-
`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`,
259-
);
257+
258+
if (Array.isArray(bundlerConfig.watchOptions.ignored)) {
259+
if (mfConfig.dts !== false) {
260+
if (
261+
typeof mfConfig.dts === 'object' &&
262+
typeof mfConfig.dts.consumeTypes === 'object' &&
263+
mfConfig.dts.consumeTypes.remoteTypesFolder
264+
) {
265+
bundlerConfig.watchOptions.ignored.push(
266+
`**/${mfConfig.dts.consumeTypes.remoteTypesFolder}/**`,
267+
);
268+
} else {
269+
bundlerConfig.watchOptions.ignored.push('**/@mf-types/**');
270+
}
260271
} else {
261272
bundlerConfig.watchOptions.ignored.push('**/@mf-types/**');
262273
}
263-
} else {
264-
bundlerConfig.watchOptions.ignored.push('**/@mf-types/**');
265274
}
266275
}
276+
267277
if (bundlerConfig.output) {
268278
if (!bundlerConfig.output?.chunkLoadingGlobal) {
269279
bundlerConfig.output.chunkLoadingGlobal = `chunk_${mfConfig.name}`;

0 commit comments

Comments
 (0)