@@ -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
@@ -453,6 +456,7 @@ class MiniCssExtractPlugin {
453
456
let success = false ;
454
457
let bestMatch ;
455
458
let bestMatchDeps ;
459
+ let bestMatchDepsReasons ;
456
460
457
461
// get first module where dependencies are fulfilled
458
462
for ( const list of modulesByChunkGroup ) {
@@ -472,6 +476,7 @@ class MiniCssExtractPlugin {
472
476
if ( ! bestMatchDeps || bestMatchDeps . length > failedDeps . length ) {
473
477
bestMatch = list ;
474
478
bestMatchDeps = failedDeps ;
479
+ bestMatchDepsReasons = moduleDependenciesReasons . get ( module ) ;
475
480
}
476
481
477
482
if ( failedDeps . length === 0 ) {
@@ -491,14 +496,21 @@ class MiniCssExtractPlugin {
491
496
if ( ! this . options . ignoreOrder ) {
492
497
compilation . warnings . push (
493
498
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' ) } `
499
+ [
500
+ `chunk ${ chunk . name || chunk . id } [${ pluginName } ]` ,
501
+ 'Following module has been added:' ,
502
+ ` * ${ fallbackModule . readableIdentifier ( requestShortener ) } ` ,
503
+ "while this module as dependencies that haven't been added before:" ,
504
+ ...bestMatchDeps . map ( ( m ) =>
505
+ [
506
+ ` * ${ m . readableIdentifier ( requestShortener ) } ` ,
507
+ `(used previous to added module in chunk ${ Array . from (
508
+ bestMatchDepsReasons . get ( m ) ,
509
+ ( cg ) => cg . name
510
+ ) . join ( ',' ) } )`,
511
+ ] . join ( ' ' )
512
+ ) ,
513
+ ] . join ( '\n' )
502
514
)
503
515
) ;
504
516
}
0 commit comments