@@ -90,12 +90,7 @@ class CssModule extends webpack.Module {
90
90
}
91
91
92
92
class CssModuleFactory {
93
- create (
94
- {
95
- dependencies : [ dependency ] ,
96
- } ,
97
- callback
98
- ) {
93
+ create ( { dependencies : [ dependency ] } , callback ) {
99
94
callback ( null , new CssModule ( dependency ) ) ;
100
95
}
101
96
}
@@ -416,6 +411,9 @@ class MiniCssExtractPlugin {
416
411
if ( typeof chunkGroup . getModuleIndex2 === 'function' ) {
417
412
// Store dependencies for modules
418
413
const moduleDependencies = new Map ( modules . map ( ( m ) => [ m , new Set ( ) ] ) ) ;
414
+ const moduleDependenciesReasons = new Map (
415
+ modules . map ( ( m ) => [ m , new Map ( ) ] )
416
+ ) ;
419
417
420
418
// Get ordered list of modules per chunk group
421
419
// This loop also gathers dependencies from the ordered lists
@@ -435,9 +433,14 @@ class MiniCssExtractPlugin {
435
433
436
434
for ( let i = 0 ; i < sortedModules . length ; i ++ ) {
437
435
const set = moduleDependencies . get ( sortedModules [ i ] ) ;
436
+ const reasons = moduleDependenciesReasons . get ( sortedModules [ i ] ) ;
438
437
439
438
for ( let j = i + 1 ; j < sortedModules . length ; j ++ ) {
440
- set . add ( sortedModules [ j ] ) ;
439
+ const module = sortedModules [ j ] ;
440
+ set . add ( module ) ;
441
+ const reason = reasons . get ( module ) || new Set ( ) ;
442
+ reason . add ( cg ) ;
443
+ reasons . set ( module , reason ) ;
441
444
}
442
445
}
443
446
@@ -489,16 +492,32 @@ class MiniCssExtractPlugin {
489
492
// and emit a warning
490
493
const fallbackModule = bestMatch . pop ( ) ;
491
494
if ( ! this . options . ignoreOrder ) {
495
+ const reasons = moduleDependenciesReasons . get ( fallbackModule ) ;
492
496
compilation . warnings . push (
493
497
new Error (
494
- `chunk ${ chunk . name || chunk . id } [${ pluginName } ]\n` +
495
- 'Conflicting order between:\n' +
496
- ` * ${ fallbackModule . readableIdentifier (
497
- requestShortener
498
- ) } \n` +
499
- `${ bestMatchDeps
500
- . map ( ( m ) => ` * ${ m . readableIdentifier ( requestShortener ) } ` )
501
- . join ( '\n' ) } `
498
+ [
499
+ `chunk ${ chunk . name || chunk . id } [${ pluginName } ]` ,
500
+ 'Conflicting order. Following module has been added:' ,
501
+ ` * ${ fallbackModule . readableIdentifier ( requestShortener ) } ` ,
502
+ 'despite it was not able to fulfill desired ordering with these modules:' ,
503
+ ...bestMatchDeps . map ( ( m ) => {
504
+ const goodReasonsMap = moduleDependenciesReasons . get ( m ) ;
505
+ const goodReasons =
506
+ goodReasonsMap && goodReasonsMap . get ( fallbackModule ) ;
507
+ const failedChunkGroups = Array . from (
508
+ reasons . get ( m ) ,
509
+ ( cg ) => cg . name
510
+ ) . join ( ', ' ) ;
511
+ const goodChunkGroups =
512
+ goodReasons &&
513
+ Array . from ( goodReasons , ( cg ) => cg . name ) . join ( ', ' ) ;
514
+ return [
515
+ ` * ${ m . readableIdentifier ( requestShortener ) } ` ,
516
+ ` - couldn't fulfill desired order of chunk group(s) ${ failedChunkGroups } ` ,
517
+ ` - while fulfilling desired order of chunk group(s) ${ goodChunkGroups } ` ,
518
+ ] . join ( '\n' ) ;
519
+ } ) ,
520
+ ] . join ( '\n' )
502
521
)
503
522
) ;
504
523
}
0 commit comments