@@ -90,12 +90,7 @@ class CssModule extends webpack.Module {
9090}
9191
9292class CssModuleFactory {
93- create (
94- {
95- dependencies : [ dependency ] ,
96- } ,
97- callback
98- ) {
93+ create ( { dependencies : [ dependency ] } , callback ) {
9994 callback ( null , new CssModule ( dependency ) ) ;
10095 }
10196}
@@ -416,6 +411,9 @@ class MiniCssExtractPlugin {
416411 if ( typeof chunkGroup . getModuleIndex2 === 'function' ) {
417412 // Store dependencies for modules
418413 const moduleDependencies = new Map ( modules . map ( ( m ) => [ m , new Set ( ) ] ) ) ;
414+ const moduleDependenciesReasons = new Map (
415+ modules . map ( ( m ) => [ m , new Map ( ) ] )
416+ ) ;
419417
420418 // Get ordered list of modules per chunk group
421419 // This loop also gathers dependencies from the ordered lists
@@ -435,9 +433,14 @@ class MiniCssExtractPlugin {
435433
436434 for ( let i = 0 ; i < sortedModules . length ; i ++ ) {
437435 const set = moduleDependencies . get ( sortedModules [ i ] ) ;
436+ const reasons = moduleDependenciesReasons . get ( sortedModules [ i ] ) ;
438437
439438 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 ) ;
441444 }
442445 }
443446
@@ -489,16 +492,32 @@ class MiniCssExtractPlugin {
489492 // and emit a warning
490493 const fallbackModule = bestMatch . pop ( ) ;
491494 if ( ! this . options . ignoreOrder ) {
495+ const reasons = moduleDependenciesReasons . get ( fallbackModule ) ;
492496 compilation . warnings . push (
493497 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' )
502521 )
503522 ) ;
504523 }
0 commit comments