@@ -13,64 +13,109 @@ ProgressPlugin.prototype.apply = function(compiler) {
1313 var states = new Array ( compiler . compilers . length ) ;
1414 compiler . compilers . forEach ( function ( compiler , idx ) {
1515 compiler . apply ( new ProgressPlugin ( function ( p , msg ) {
16- states [ idx ] = [ p , msg ] ;
17- handler ( states . map ( function ( state ) {
16+ states [ idx ] = Array . prototype . slice . apply ( arguments ) ;
17+ handler . apply ( null , [ states . map ( function ( state ) {
1818 return state && state [ 0 ] || 0 ;
1919 } ) . reduce ( function ( a , b ) {
2020 return a + b ;
2121 } ) / states . length , states . map ( function ( state ) {
2222 return state && state [ 1 ] ;
23- } ) . filter ( Boolean ) . join ( " | " ) ) ;
23+ } ) . filter ( Boolean ) . join ( " | " ) ]
24+ . concat ( Array . prototype . slice . call ( arguments , 2 ) ) ) ;
2425 } ) ) ;
2526 } ) ;
2627 } else {
2728 var lastModulesCount = 0 ;
28- var moduleCount = 1 ;
29+ var moduleCount = 500 ;
2930 var doneModules = 0 ;
31+ var activeModules = [ ] ;
3032
31- function update ( ) {
32- handler ( 0.1 + ( doneModules / Math . max ( lastModulesCount , moduleCount ) ) * 0.6 , doneModules + "/" + moduleCount + " build modules" ) ;
33+ function update ( module ) {
34+ handler (
35+ 0.1 + ( doneModules / Math . max ( lastModulesCount , moduleCount ) ) * 0.6 ,
36+ "building modules" ,
37+ doneModules + "/" + moduleCount + " modules" ,
38+ activeModules . length + " active" ,
39+ activeModules [ activeModules . length - 1 ]
40+ ) ;
41+ }
42+
43+ function moduleDone ( module ) {
44+ doneModules ++ ;
45+ var ident = module . identifier ( ) ;
46+ if ( ident ) {
47+ var idx = activeModules . indexOf ( ident ) ;
48+ if ( idx >= 0 ) activeModules . splice ( idx , 1 ) ;
49+ }
50+ update ( ) ;
3351 }
3452 compiler . plugin ( "compilation" , function ( compilation ) {
3553 if ( compilation . compiler . isChild ( ) ) return ;
3654 lastModulesCount = moduleCount ;
3755 moduleCount = 0 ;
3856 doneModules = 0 ;
39- handler ( 0 , "compile " ) ;
40- compilation . plugin ( "build-module" , function ( ) {
57+ handler ( 0 , "compiling " ) ;
58+ compilation . plugin ( "build-module" , function ( module ) {
4159 moduleCount ++ ;
60+ var ident = module . identifier ( ) ;
61+ if ( ident ) {
62+ activeModules . push ( ident ) ;
63+ }
4264 update ( ) ;
4365 } ) ;
44- compilation . plugin ( "succeed-module" , function ( ) {
45- doneModules ++ ;
46- update ( ) ;
47- } ) ;
48- compilation . plugin ( "seal" , function ( ) {
49- handler ( 0.71 , "seal" ) ;
66+ compilation . plugin ( "failed-module" , moduleDone ) ;
67+ compilation . plugin ( "succeed-module" , moduleDone ) ;
68+ var syncHooks = {
69+ "seal" : [ 0.71 , "sealing" ] ,
70+ "optimize" : [ 0.72 , "optimizing" ] ,
71+ "optimize-modules-basic" : [ 0.73 , "basic module optimization" ] ,
72+ "optimize-modules" : [ 0.74 , "module optimization" ] ,
73+ "optimize-modules-advanced" : [ 0.75 , "advanced module optimization" ] ,
74+ "optimize-chunks-basic" : [ 0.76 , "basic chunk optimization" ] ,
75+ "optimize-chunks" : [ 0.77 , "chunk optimization" ] ,
76+ "optimize-chunks-advanced" : [ 0.78 , "advanced chunk optimization" ] ,
77+ // optimize-tree
78+ "revive-modules" : [ 0.80 , "module reviving" ] ,
79+ "optimize-module-order" : [ 0.81 , "module order optimization" ] ,
80+ "optimize-module-ids" : [ 0.82 , "module id optimization" ] ,
81+ "revive-chunks" : [ 0.83 , "chunk reviving" ] ,
82+ "optimize-chunk-order" : [ 0.84 , "chunk order optimization" ] ,
83+ "optimize-chunk-ids" : [ 0.85 , "chunk id optimization" ] ,
84+ "before-hash" : [ 0.86 , "hashing" ] ,
85+ "before-module-assets" : [ 0.87 , "module assets processing" ] ,
86+ "before-chunk-assets" : [ 0.88 , "chunk assets processing" ] ,
87+ "additional-chunk-assets" : [ 0.89 , "additional chunk assets processing" ] ,
88+ "record" : [ 0.90 , "recording" ]
89+ } ;
90+ Object . keys ( syncHooks ) . forEach ( function ( name ) {
91+ var pass = 0 ;
92+ var settings = syncHooks [ name ] ;
93+ compilation . plugin ( name , function ( ) {
94+ if ( pass ++ > 0 )
95+ handler ( settings [ 0 ] , settings [ 1 ] , "pass " + pass ) ;
96+ else
97+ handler ( settings [ 0 ] , settings [ 1 ] ) ;
98+ } ) ;
5099 } ) ;
51- compilation . plugin ( "optimize" , function ( ) {
52- handler ( 0.73 , "optimize" ) ;
53- } ) ;
54- compilation . plugin ( "before-hash" , function ( ) {
55- handler ( 0.75 , "hashing" ) ;
56- } ) ;
57- compilation . plugin ( "before-chunk-assets" , function ( ) {
58- handler ( 0.76 , "create chunk assets" ) ;
100+ compilation . plugin ( "optimize-tree" , function ( chunks , modules , callback ) {
101+ handler ( 0.79 , "module and chunk tree optimization" ) ;
102+ callback ( ) ;
59103 } ) ;
60- compilation . plugin ( "additional-chunk-assets" , function ( ) {
61- handler ( 0.78 , "additional chunk assets" ) ;
104+ compilation . plugin ( "additional-assets" , function ( callback ) {
105+ handler ( 0.91 , "additional asset processing" ) ;
106+ callback ( ) ;
62107 } ) ;
63108 compilation . plugin ( "optimize-chunk-assets" , function ( chunks , callback ) {
64- handler ( 0.8 , "optimize chunk assets " ) ;
109+ handler ( 0.92 , "chunk asset optimization " ) ;
65110 callback ( ) ;
66111 } ) ;
67112 compilation . plugin ( "optimize-assets" , function ( assets , callback ) {
68- handler ( 0.9 , "optimize assets " ) ;
113+ handler ( 0.94 , "asset optimization " ) ;
69114 callback ( ) ;
70115 } ) ;
71116 } ) ;
72117 compiler . plugin ( "emit" , function ( compilation , callback ) {
73- handler ( 0.95 , "emit " ) ;
118+ handler ( 0.95 , "emitting " ) ;
74119 callback ( ) ;
75120 } ) ;
76121 compiler . plugin ( "done" , function ( ) {
@@ -83,19 +128,7 @@ ProgressPlugin.prototype.apply = function(compiler) {
83128
84129 function defaultHandler ( percentage , msg ) {
85130 var state = msg ;
86-
87- function goToLineStart ( nextMessage ) {
88- var str = "" ;
89- for ( ; chars > nextMessage . length ; chars -- ) {
90- str += "\b \b" ;
91- }
92- chars = nextMessage . length ;
93- for ( var i = 0 ; i < chars ; i ++ ) {
94- str += "\b" ;
95- }
96- if ( str ) process . stderr . write ( str ) ;
97- }
98-
131+ var details = Array . prototype . slice . call ( arguments , 2 ) ;
99132 if ( percentage < 1 ) {
100133 percentage = Math . floor ( percentage * 100 ) ;
101134 msg = percentage + "% " + msg ;
@@ -105,6 +138,13 @@ ProgressPlugin.prototype.apply = function(compiler) {
105138 if ( percentage < 10 ) {
106139 msg = " " + msg ;
107140 }
141+ details . forEach ( function ( detail ) {
142+ if ( ! detail ) return ;
143+ if ( detail . length > 40 ) {
144+ detail = "..." + detail . substr ( detail . length - 37 ) ;
145+ }
146+ msg += " " + detail
147+ } ) ;
108148 }
109149 if ( compiler . options . profile ) {
110150 state = state . replace ( / ^ \d + \/ \d + \s + / , "" ) ;
@@ -126,4 +166,16 @@ ProgressPlugin.prototype.apply = function(compiler) {
126166 goToLineStart ( msg ) ;
127167 process . stderr . write ( msg ) ;
128168 }
169+
170+ function goToLineStart ( nextMessage ) {
171+ var str = "" ;
172+ for ( ; chars > nextMessage . length ; chars -- ) {
173+ str += "\b \b" ;
174+ }
175+ chars = nextMessage . length ;
176+ for ( var i = 0 ; i < chars ; i ++ ) {
177+ str += "\b" ;
178+ }
179+ if ( str ) process . stderr . write ( str ) ;
180+ }
129181} ;
0 commit comments