File tree Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Expand file tree Collapse file tree 2 files changed +22
-9
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @module-federation/rspack ' : patch
3
+ ---
4
+
5
+ Check for falsy values when looking for duplicate ModuleFederationPlugin entries
Original file line number Diff line number Diff line change 1
1
import type {
2
2
Compiler ,
3
+ Falsy ,
3
4
ModuleFederationPluginOptions ,
5
+ RspackPluginFunction ,
4
6
RspackPluginInstance ,
5
7
} from '@rspack/core' ;
6
8
import {
@@ -49,16 +51,22 @@ export class ModuleFederationPlugin implements RspackPluginInstance {
49
51
50
52
private _checkSingleton ( compiler : Compiler ) : void {
51
53
let count = 0 ;
52
- compiler . options . plugins . forEach ( ( p : any ) => {
53
- if ( p . name === this . name ) {
54
- count ++ ;
55
- if ( count > 1 ) {
56
- throw new Error (
57
- `Detect duplicate register ${ this . name } ,please ensure ${ this . name } is singleton!` ,
58
- ) ;
54
+ compiler . options . plugins . forEach (
55
+ ( p : Falsy | RspackPluginInstance | RspackPluginFunction ) => {
56
+ if ( typeof p !== 'object' || ! p ) {
57
+ return ;
59
58
}
60
- }
61
- } ) ;
59
+
60
+ if ( p [ 'name' ] === this . name ) {
61
+ count ++ ;
62
+ if ( count > 1 ) {
63
+ throw new Error (
64
+ `Detect duplicate register ${ this . name } ,please ensure ${ this . name } is singleton!` ,
65
+ ) ;
66
+ }
67
+ }
68
+ } ,
69
+ ) ;
62
70
}
63
71
64
72
apply ( compiler : Compiler ) : void {
You can’t perform that action at this time.
0 commit comments