Skip to content

Commit efadc07

Browse files
authored
fix: rspack splitChunk.chunks should use function to prevent wrong be… (#2575)
1 parent 6f0ef7d commit efadc07

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

.changeset/shy-pears-raise.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@module-federation/rspack': patch
3+
---
4+
5+
fix: rspack splitChunk.chunks should use function to prevent wrong behavior

packages/rspack/src/ModuleFederationPlugin.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,15 @@ export class ModuleFederationPlugin implements RspackPluginInstance {
142142
}
143143

144144
if (cacheGroup.chunks === 'all') {
145-
cacheGroup.chunks = new RegExp(
146-
`^(?!.*(${name}|${name}_partial)).*$`,
147-
'g',
148-
);
145+
cacheGroup.chunks = (chunk) => {
146+
if (
147+
chunk.name &&
148+
(chunk.name === name || chunk.name === name + '_partial')
149+
) {
150+
return false;
151+
}
152+
return true;
153+
};
149154
break;
150155
}
151156
if (cacheGroup.chunks === 'initial') {

0 commit comments

Comments
 (0)