File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ const RequestShortener = require("./RequestShortener");
8
8
const SizeFormatHelpers = require ( "./SizeFormatHelpers" ) ;
9
9
const formatLocation = require ( "./formatLocation" ) ;
10
10
const identifierUtils = require ( "./util/identifier" ) ;
11
+ const compareLocations = require ( "./compareLocations" ) ;
11
12
12
13
const optionsOrFallback = ( ...args ) => {
13
14
let optionValues = [ ] ;
@@ -523,6 +524,23 @@ class Stats {
523
524
}
524
525
if ( showReasons ) {
525
526
obj . reasons = module . reasons
527
+ . sort ( ( a , b ) => {
528
+ if ( a . module && ! b . module ) return - 1 ;
529
+ if ( ! a . module && b . module ) return 1 ;
530
+ if ( a . module && b . module ) {
531
+ const cmp = compareId ( a . module . id , b . module . id ) ;
532
+ if ( cmp ) return cmp ;
533
+ }
534
+ if ( a . dependency && ! b . dependency ) return - 1 ;
535
+ if ( ! a . dependency && b . dependency ) return 1 ;
536
+ if ( a . dependency && b . dependency ) {
537
+ const cmp = compareLocations ( a . dependency . loc , b . dependency . loc ) ;
538
+ if ( cmp ) return cmp ;
539
+ if ( a . dependency . type < b . dependency . type ) return - 1 ;
540
+ if ( a . dependency . type > b . dependency . type ) return 1 ;
541
+ }
542
+ return 0 ;
543
+ } )
526
544
. map ( reason => {
527
545
const obj = {
528
546
moduleId : reason . module ? reason . module . id : null ,
@@ -548,8 +566,7 @@ class Stats {
548
566
}
549
567
}
550
568
return obj ;
551
- } )
552
- . sort ( compareId ) ;
569
+ } ) ;
553
570
}
554
571
if ( showUsedExports ) {
555
572
if ( module . used === true ) {
Original file line number Diff line number Diff line change @@ -560,8 +560,8 @@ chunk {2} 2.bundle.js 60 bytes <{1}> [rendered]
560
560
chunk { main } bundle.js (main) 73 bytes >{ 0 } < > { 1 } < [entry] [rendered]
561
561
> ./index main
562
562
[./a.js] 22 bytes { main } [built]
563
- cjs require ./a [./index.js] 1:0-14
564
563
cjs require ./a [./e.js] 1:0-14
564
+ cjs require ./a [./index.js] 1:0-14
565
565
[./index.js] Xms -> factory:Xms building:Xms = Xms
566
566
[./index.js] 51 bytes { main } [built]
567
567
single entry ./index main
You can’t perform that action at this time.
0 commit comments