File tree 2 files changed +23
-1
lines changed
2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -80,9 +80,13 @@ class Validator {
80
80
81
81
_validateCacheGroupNames ( ) {
82
82
for ( const groupName of Object . keys ( this . webpackConfig . cacheGroups ) ) {
83
- if ( [ 'defaultVendors' , 'default' ] . includes ( groupName ) ) {
83
+ if ( [ 'vendors' , ' defaultVendors', 'default' ] . includes ( groupName ) ) {
84
84
logger . warning ( `Passing "${ groupName } " to addCacheGroup() is not recommended, as it will override the built-in cache group by this name.` ) ;
85
85
}
86
+
87
+ if ( groupName === this . webpackConfig . sharedCommonsEntryName ) {
88
+ logger . warning ( 'Using the same name when calling createSharedEntry() and addCacheGroup() is not recommended.' ) ;
89
+ }
86
90
}
87
91
}
88
92
}
Original file line number Diff line number Diff line change @@ -113,4 +113,22 @@ describe('The validator function', () => {
113
113
expect ( logger . getMessages ( ) . warning ) . to . have . lengthOf ( 1 ) ;
114
114
expect ( logger . getMessages ( ) . warning [ 0 ] ) . to . include ( 'Passing "defaultVendors" to addCacheGroup() is not recommended' ) ;
115
115
} ) ;
116
+
117
+ it ( 'warning with addCacheGroup() and a similar createSharedEntry() name' , ( ) => {
118
+ const config = createConfig ( ) ;
119
+ config . outputPath = '/tmp/public/build' ;
120
+ config . setPublicPath ( '/build' ) ;
121
+ config . addEntry ( 'main' , './main' ) ;
122
+ config . createSharedEntry ( 'foo' , './foo.js' ) ;
123
+ config . addCacheGroup ( 'foo' , {
124
+ test : / [ \\ / ] m a i n / ,
125
+ } ) ;
126
+
127
+ logger . reset ( ) ;
128
+ logger . quiet ( ) ;
129
+ validator ( config ) ;
130
+
131
+ expect ( logger . getMessages ( ) . warning ) . to . have . lengthOf ( 1 ) ;
132
+ expect ( logger . getMessages ( ) . warning [ 0 ] ) . to . include ( 'Using the same name when calling createSharedEntry() and addCacheGroup() is not recommended.' ) ;
133
+ } ) ;
116
134
} ) ;
You can’t perform that action at this time.
0 commit comments