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 11import type {
22 Compiler ,
3+ Falsy ,
34 ModuleFederationPluginOptions ,
5+ RspackPluginFunction ,
46 RspackPluginInstance ,
57} from '@rspack/core' ;
68import {
@@ -49,16 +51,22 @@ export class ModuleFederationPlugin implements RspackPluginInstance {
4951
5052 private _checkSingleton ( compiler : Compiler ) : void {
5153 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 ;
5958 }
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+ ) ;
6270 }
6371
6472 apply ( compiler : Compiler ) : void {
You can’t perform that action at this time.
0 commit comments