File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -80,9 +80,13 @@ class Validator {
8080
8181 _validateCacheGroupNames ( ) {
8282 for ( const groupName of Object . keys ( this . webpackConfig . cacheGroups ) ) {
83- if ( [ 'defaultVendors' , 'default' ] . includes ( groupName ) ) {
83+ if ( [ 'vendors' , ' defaultVendors', 'default' ] . includes ( groupName ) ) {
8484 logger . warning ( `Passing "${ groupName } " to addCacheGroup() is not recommended, as it will override the built-in cache group by this name.` ) ;
8585 }
86+
87+ if ( groupName === this . webpackConfig . sharedCommonsEntryName ) {
88+ logger . warning ( 'Using the same name when calling createSharedEntry() and addCacheGroup() is not recommended.' ) ;
89+ }
8690 }
8791 }
8892}
Original file line number Diff line number Diff line change @@ -113,4 +113,22 @@ describe('The validator function', () => {
113113 expect ( logger . getMessages ( ) . warning ) . to . have . lengthOf ( 1 ) ;
114114 expect ( logger . getMessages ( ) . warning [ 0 ] ) . to . include ( 'Passing "defaultVendors" to addCacheGroup() is not recommended' ) ;
115115 } ) ;
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+ } ) ;
116134} ) ;
You can’t perform that action at this time.
0 commit comments