@@ -47,7 +47,7 @@ class CommonsChunkPlugin {
4747 const minSize = this . minSize ;
4848 const ident = this . ident ;
4949 compiler . plugin ( "this-compilation" , ( compilation ) => {
50- compilation . plugin ( [ "optimize-chunks" , "optimize-extracted-chunks" ] , function ( chunks ) {
50+ compilation . plugin ( [ "optimize-chunks" , "optimize-extracted-chunks" ] , ( chunks ) => {
5151 // only optimize once
5252 if ( compilation [ ident ] ) return ;
5353 compilation [ ident ] = true ;
@@ -57,11 +57,11 @@ class CommonsChunkPlugin {
5757 commonChunks = chunks ;
5858 } else if ( Array . isArray ( chunkNames ) || typeof chunkNames === "string" ) {
5959 commonChunks = [ ] . concat ( chunkNames ) . map ( ( chunkName ) => {
60- let chunk = chunks . filter ( function ( chunk ) {
60+ let chunk = chunks . filter ( ( chunk ) => {
6161 return chunk . name === chunkName ;
6262 } ) [ 0 ] ;
6363 if ( ! chunk ) {
64- chunk = this . addChunk ( chunkName ) ;
64+ chunk = compilation . addChunk ( chunkName ) ;
6565 }
6666 return chunk ;
6767 } , this ) ;
@@ -91,8 +91,9 @@ class CommonsChunkPlugin {
9191 return chunk . hasRuntime ( ) ;
9292 } ) ;
9393 }
94+ let asyncChunk ;
9495 if ( asyncOption ) {
95- var asyncChunk = this . addChunk ( typeof asyncOption === "string" ? asyncOption : undefined ) ;
96+ asyncChunk = compilation . addChunk ( typeof asyncOption === "string" ? asyncOption : undefined ) ;
9697 asyncChunk . chunkReason = "async commons chunk" ;
9798 asyncChunk . extraAsync = true ;
9899 asyncChunk . addParent ( commonChunk ) ;
@@ -103,8 +104,8 @@ class CommonsChunkPlugin {
103104 if ( minChunks !== Infinity ) {
104105 const commonModulesCount = [ ] ;
105106 const commonModules = [ ] ;
106- usedChunks . forEach ( function ( chunk ) {
107- chunk . modules . forEach ( function ( module ) {
107+ usedChunks . forEach ( ( chunk ) => {
108+ chunk . modules . forEach ( ( module ) => {
108109 const idx = commonModules . indexOf ( module ) ;
109110 if ( idx < 0 ) {
110111 commonModules . push ( module ) ;
@@ -156,7 +157,7 @@ class CommonsChunkPlugin {
156157 } ) ;
157158 } ) ;
158159 asyncChunk . origins = reallyUsedChunks . map ( ( chunk ) => {
159- return chunk . origins . map ( function ( origin ) {
160+ return chunk . origins . map ( ( origin ) => {
160161 const newOrigin = Object . create ( origin ) ;
161162 newOrigin . reasons = ( origin . reasons || [ ] ) . slice ( ) ;
162163 newOrigin . reasons . push ( "async commons" ) ;
0 commit comments