@@ -134,12 +134,18 @@ module.exports = {
134
134
var minFile = file . replace ( / \. j s $ / , '.min.js' ) ;
135
135
var mapFile = minFile + '.map' ;
136
136
var mapFileName = mapFile . match ( / [ ^ \/ ] + $ / ) [ 0 ] ;
137
+ var errorFileName = file . replace ( / \. j s $ / , '-errors.json' ) ;
137
138
shell . exec (
138
139
'java ' +
139
140
this . java32flags ( ) + ' ' +
140
- '-jar components/closure-compiler/compiler.jar ' +
141
+ '-cp ./components/closure-compiler/compiler.jar' +
142
+ ':./components/ng-closure-runner/ngcompiler.jar ' +
143
+ 'org.angularjs.closurerunner.NgClosureRunner ' +
141
144
'--compilation_level SIMPLE_OPTIMIZATIONS ' +
142
145
'--language_in ECMASCRIPT5_STRICT ' +
146
+ '--minerr_pass ' +
147
+ '--minerr_errors ' + errorFileName + ' ' +
148
+ '--minerr_url \'http://docs.angularjs.org/minerr/\' ' +
143
149
'--source_map_format=V3 ' +
144
150
'--create_source_map ' + mapFile + ' ' +
145
151
'--js ' + file + ' ' +
@@ -167,6 +173,44 @@ module.exports = {
167
173
} ,
168
174
169
175
176
+ //collects and combines error messages stripped out in minify step
177
+ collectErrors : function ( ) {
178
+ var combined = {
179
+ id : 'ng' ,
180
+ generated : new Date ( ) . toString ( ) ,
181
+ errors : { }
182
+ } ;
183
+ grunt . file . expand ( 'build/*-errors.json' ) . forEach ( function ( file ) {
184
+ var errors = grunt . file . readJSON ( file ) ,
185
+ namespace ;
186
+ Object . keys ( errors ) . forEach ( function ( prop ) {
187
+ if ( typeof errors [ prop ] === 'object' ) {
188
+ namespace = errors [ prop ] ;
189
+ if ( combined . errors [ prop ] ) {
190
+ Object . keys ( namespace ) . forEach ( function ( code ) {
191
+ if ( combined . errors [ prop ] [ code ] && combined . errors [ prop ] [ code ] !== namespace [ code ] ) {
192
+ grunt . warn ( '[collect-errors] Duplicate minErr codes don\'t match!' ) ;
193
+ } else {
194
+ combined . errors [ prop ] [ code ] = namespace [ code ] ;
195
+ }
196
+ } ) ;
197
+ } else {
198
+ combined . errors [ prop ] = namespace ;
199
+ }
200
+ } else {
201
+ if ( combined . errors [ prop ] && combined . errors [ prop ] !== errors [ prop ] ) {
202
+ grunt . warn ( '[collect-errors] Duplicate minErr codes don\'t match!' ) ;
203
+ } else {
204
+ combined . errors [ prop ] = errors [ prop ] ;
205
+ }
206
+ }
207
+ } ) ;
208
+ } ) ;
209
+ grunt . file . write ( 'build/errors.json' , JSON . stringify ( combined ) ) ;
210
+ grunt . file . expand ( 'build/*-errors.json' ) . forEach ( grunt . file . delete ) ;
211
+ } ,
212
+
213
+
170
214
//csp connect middleware
171
215
csp : function ( ) {
172
216
return function ( req , res , next ) {
0 commit comments