@@ -107,7 +107,7 @@ You can however specify the name of the async chunk by passing the desired strin
107107 /**
108108 * These chunks are subject to get "common" modules extracted and moved to the common chunk
109109 */
110- const affectedChunks = this . getAffectedChunks ( compilation , chunks , targetChunk , targetChunks , idx , this . selectedChunks , this . async , this . children ) ;
110+ const affectedChunks = this . getAffectedChunks ( compilation , chunks , targetChunk , targetChunks , idx , this . selectedChunks , this . async , this . children , this . deepChildren ) ;
111111
112112 // bail if no chunk is affected
113113 if ( ! affectedChunks ) {
@@ -214,7 +214,7 @@ You can however specify the name of the async chunk by passing the desired strin
214214Take a look at the "name"/"names" or async/children option.` ) ;
215215 }
216216
217- getAffectedUnnamedChunks ( affectedChunks , targetChunk , asyncOption ) {
217+ getAffectedUnnamedChunks ( affectedChunks , targetChunk , rootChunk , asyncOption , deepChildrenOption ) {
218218 let chunks = targetChunk . chunks ;
219219 chunks && chunks . forEach ( ( chunk ) => {
220220 if ( chunk . isInitial ( ) ) {
@@ -225,28 +225,28 @@ Take a look at the "name"/"names" or async/children option.`);
225225 // b) themselves affected chunks
226226 // we can assume that this chunk is an affected chunk too, as there is no way a chunk that
227227 // isn't only depending on the target chunk is a parent of the chunk tested
228- if ( asyncOption || chunk . parents . every ( ( parentChunk ) => parentChunk === targetChunk || affectedChunks . has ( parentChunk ) ) ) {
228+ if ( asyncOption || chunk . parents . every ( ( parentChunk ) => parentChunk === rootChunk || affectedChunks . has ( parentChunk ) ) ) {
229229 // This check not only dedupes the affectedChunks but also guarantees we avoid endless loops
230- if ( ! affectedChunks . has ( chunk ) || affectedChunks . values ( ) . next ( ) . value === chunk ) {
230+ if ( ! affectedChunks . has ( chunk ) ) {
231231 // We mutate the affected chunks before going deeper, so the deeper levels and other branches
232- // Have the information of this chunk being affected for their assertion if a chunk should
232+ // have the information of this chunk being affected for their assertion if a chunk should
233233 // not be affected
234234 affectedChunks . add ( chunk ) ;
235235
236236 // We recurse down to all the children of the chunk, applying the same assumption.
237237 // This guarantees that if a chunk should be an affected chunk,
238238 // at the latest the last connection to the same chunk meets the
239239 // condition to add it to the affected chunks.
240- if ( this . deepChildren === true ) {
241- this . getAffectedUnnamedChunks ( affectedChunks , chunk , asyncOption ) ;
240+ if ( deepChildrenOption === true ) {
241+ this . getAffectedUnnamedChunks ( affectedChunks , chunk , rootChunk , asyncOption , deepChildrenOption ) ;
242242 }
243243 }
244244 }
245245 } ) ;
246246 }
247247
248- getAffectedChunks ( compilation , allChunks , targetChunk , targetChunks , currentIndex , selectedChunks , asyncOption , children ) {
249- const asyncOrNoSelectedChunk = children || asyncOption ;
248+ getAffectedChunks ( compilation , allChunks , targetChunk , targetChunks , currentIndex , selectedChunks , asyncOption , childrenOption , deepChildrenOption ) {
249+ const asyncOrNoSelectedChunk = childrenOption || asyncOption ;
250250
251251 if ( Array . isArray ( selectedChunks ) ) {
252252 return allChunks . filter ( chunk => {
@@ -258,7 +258,7 @@ Take a look at the "name"/"names" or async/children option.`);
258258
259259 if ( asyncOrNoSelectedChunk ) {
260260 let affectedChunks = new Set ( ) ;
261- this . getAffectedUnnamedChunks ( affectedChunks , targetChunk , asyncOption ) ;
261+ this . getAffectedUnnamedChunks ( affectedChunks , targetChunk , targetChunk , asyncOption , deepChildrenOption ) ;
262262 return Array . from ( affectedChunks ) ;
263263 }
264264
0 commit comments