Skip to content

Commit 5fc6045

Browse files
authored
fix(rsbuild-plugin): remove duplicate logs for shared modules (#3187)
1 parent 47fdbc2 commit 5fc6045

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

.changeset/olive-meals-applaud.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/rsbuild-plugin': patch
3+
---
4+
5+
fix(rsbuild-plugin): remove duplicate logs for shared modules.

packages/rsbuild-plugin/src/cli/index.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ export const pluginModuleFederation = (
9292
// filter external with shared config,
9393
const externals = config.output.externals;
9494
if (Array.isArray(externals)) {
95+
const sharedModules = new Set<string>();
9596
config.output.externals = externals.filter((ext) => {
9697
let sharedModule;
9798
if (isRegExp(ext)) {
@@ -106,11 +107,7 @@ export const pluginModuleFederation = (
106107
return false;
107108
});
108109

109-
if (match) {
110-
logger.log(
111-
`${sharedModule} is removed from externals because it is a shared module.`,
112-
);
113-
}
110+
match && sharedModule && sharedModules.add(sharedModule);
114111
return !match;
115112
}
116113

@@ -126,15 +123,20 @@ export const pluginModuleFederation = (
126123
return dep === ext;
127124
});
128125
if (match) {
129-
logger.log(
130-
`${sharedModule} is removed from externals because it is a shared module.`,
131-
);
126+
sharedModule && sharedModules.add(sharedModule);
132127
return false;
133128
}
134129
return true;
135130
}
136131
return true;
137132
});
133+
if (sharedModules.size > 0) {
134+
for (const sharedModule of sharedModules) {
135+
logger.log(
136+
`${sharedModule} is removed from externals because it is a shared module.`,
137+
);
138+
}
139+
}
138140
}
139141

140142
const mfConfig: EnvironmentConfig = {

0 commit comments

Comments
 (0)