File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -421,7 +421,7 @@ class MiniCssExtractPlugin {
421
421
// This loop also gathers dependencies from the ordered lists
422
422
// Lists are in reverse order to allow to use Array.pop()
423
423
const modulesByChunkGroup = Array . from ( chunk . groupsIterable , ( cg ) => {
424
- const sortedModules = modules
424
+ let sortedModules = modules
425
425
. map ( ( m ) => {
426
426
return {
427
427
module : m ,
@@ -433,6 +433,18 @@ class MiniCssExtractPlugin {
433
433
. sort ( ( a , b ) => b . index - a . index )
434
434
. map ( ( item ) => item . module ) ;
435
435
436
+ // if no modules were found by getModuleIndex2, dive into each chunk
437
+ // in the group
438
+ if ( ! sortedModules || ! sortedModules . length ) {
439
+ sortedModules = cg . chunks
440
+ // reduce each chunk's modules into a flat array
441
+ . reduce ( ( arr , ch ) => [ ...arr , ...ch . modulesIterable ] , [ ] )
442
+ // filter only the modules that match
443
+ . filter ( ( m ) => modules . find ( ( mod ) => mod === m ) )
444
+ // sort in reverse order
445
+ . sort ( ( a , b ) => a . index2 - b . index2 ) ;
446
+ }
447
+
436
448
for ( let i = 0 ; i < sortedModules . length ; i ++ ) {
437
449
const set = moduleDependencies . get ( sortedModules [ i ] ) ;
438
450
You can’t perform that action at this time.
0 commit comments