File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,21 +41,19 @@ CommonsChunkPlugin.prototype.apply = function(compiler) {
4141 var commonChunks ;
4242 if ( ! chunkNames && ( selectedChunks === false || async ) ) {
4343 commonChunks = chunks ;
44- } else if ( Array . isArray ( chunkNames ) ) {
45- commonChunks = chunkNames . map ( function ( chunkName ) {
46- return chunks . filter ( function ( chunk ) {
44+ } else if ( Array . isArray ( chunkNames ) || typeof chunkNames === "string" ) {
45+ commonChunks = [ ] . concat ( chunkNames ) . map ( function ( chunkName ) {
46+ var chunk = chunks . filter ( function ( chunk ) {
4747 return chunk . name === chunkName ;
4848 } ) [ 0 ] ;
49- } ) ;
49+ if ( ! chunk ) {
50+ chunk = this . addChunk ( chunkName ) ;
51+ chunk . initial = chunk . entry = true ;
52+ }
53+ return chunk ;
54+ } , this ) ;
5055 } else {
51- commonChunks = chunks . filter ( function ( chunk ) {
52- return chunk . name === chunkNames ;
53- } ) ;
54- }
55- if ( commonChunks . length === 0 ) {
56- var chunk = this . addChunk ( chunkNames ) ;
57- chunk . initial = chunk . entry = true ;
58- commonChunks = [ chunk ] ;
56+ throw new Error ( "Invalid chunkNames argument" ) ;
5957 }
6058 commonChunks . forEach ( function processCommonChunk ( commonChunk , idx ) {
6159 var commonModulesCount = [ ] ;
You can’t perform that action at this time.
0 commit comments