@@ -61,7 +61,7 @@ module.exports = function(module, options, toRealId, toRealChuckId) {
6161 if ( requireItem . id !== undefined && toRealId ( requireItem . id ) !== undefined ) {
6262 var prefix = "" ;
6363 if ( requireItem . name && options . includeFilenames )
64- prefix += "/* " + shortenFilename ( requireItem . name ) + " */" ;
64+ prefix += "/*! " + shortenFilename ( requireItem . name ) + " */" ;
6565 if ( requireItem . expressionRange ) {
6666 replaces . push ( {
6767 from : requireItem . expressionRange [ 0 ] ,
@@ -106,15 +106,15 @@ module.exports = function(module, options, toRealId, toRealChuckId) {
106106 replaces . push ( {
107107 from : requireItem . amdNameRange [ 0 ] ,
108108 to : requireItem . amdNameRange [ 1 ] ,
109- value : "/* " + requireItem . label . replace ( / \* \/ / g, "* nice try /" ) + " */0"
109+ value : options . includeFilenames ? "/*! " + requireItem . label . replace ( / \* \/ / g, "* nice try /" ) + " */0" : " 0"
110110 } ) ;
111111 }
112112 }
113113 function genContextReplaces ( contextItem ) {
114114 var postfix = "" ;
115115 var prefix = "" ;
116- if ( contextItem . name )
117- prefix += "/* " + contextItem . name + " */" ;
116+ if ( contextItem . name && options . includeFilenames )
117+ prefix += "/*! " + contextItem . name + " */" ;
118118 if ( contextItem . require ) {
119119 replaces . push ( {
120120 from : contextItem . calleeRange [ 0 ] ,
@@ -201,7 +201,7 @@ module.exports = function(module, options, toRealId, toRealChuckId) {
201201 replaces . push ( {
202202 from : asyncItem . nameRange [ 0 ] ,
203203 to : asyncItem . nameRange [ 1 ] ,
204- value : "/* " + asyncItem . name . replace ( / \* \/ / g, "* nice try /" ) + " */0"
204+ value : options . includeFilenames ? "/*! " + asyncItem . name . replace ( / \* \/ / g, "* nice try /" ) + " */0" : " 0"
205205 } ) ;
206206 }
207207 if ( asyncItem . propertyRange ) {
@@ -248,8 +248,8 @@ module.exports = function(module, options, toRealId, toRealChuckId) {
248248 values . forEach ( function ( requireItem , idx ) {
249249 if ( requireItem . id !== undefined && toRealId ( requireItem . id ) !== undefined ) {
250250 var prefix = "" ;
251- if ( requireItem . name )
252- prefix += "/* " + requireItem . name + " */" ;
251+ if ( requireItem . name && options . includeFilenames )
252+ prefix += "/*! " + requireItem . name + " */" ;
253253 values [ idx ] = "require(" + prefix + toRealId ( requireItem . id ) + ")" + ( requireItem . append || "" ) ;
254254 }
255255 } ) ;
@@ -290,7 +290,7 @@ module.exports = function(module, options, toRealId, toRealChuckId) {
290290 // minimize if in debug mode
291291 // else calculate the minimized size for stats
292292 if ( options . minimize ) {
293- var minimized = uglify ( result , module . filename ) ;
293+ var minimized = uglify ( result , module . request , options . minimize , options . debug ) ;
294294 module . size = minimized . length ;
295295 if ( options . debug ) {
296296 result = minimized ;
@@ -309,7 +309,7 @@ module.exports = function(module, options, toRealId, toRealChuckId) {
309309 "// module.id = " , module . id , "\n" ,
310310 "// module.realId = " , module . realId , "\n" ,
311311 "// module.chunks = " , module . chunks . join ( ", " ) , "\n" ,
312- "//@ sourceURL=webpack-module:///" , encodeURI ( shortenFilename ( module . request || module . dirname ) ) . replace ( / % 5 C | % 2 F / g, "/" ) . replace ( / ^ \/ / , "" )
312+ "//@ sourceURL=webpack-module:///" , encodeURI ( shortenFilename ( module . request || module . dirname ) ) . replace ( / % 5 C | % 2 F / g, "/" ) . replace ( / \? / , "%3F" ) . replace ( / ^ \/ / , "" )
313313 ] . join ( "" ) ) ,
314314 ");" ] . join ( "" ) ;
315315 }
@@ -320,15 +320,30 @@ module.exports = function(module, options, toRealId, toRealChuckId) {
320320 return finalResult . join ( "" ) ;
321321}
322322
323- function uglify ( input , filename ) {
324- var uglify = require ( "uglify-js" ) ;
323+ // minimize it the uglify
324+ function uglify ( input , filename , options , beautify ) {
325+ if ( typeof options != "object" ) options = {
326+ warnings : false
327+ } ;
328+ var uglify2 = require ( "uglify-js2" ) ;
325329 try {
326- source = uglify . parser . parse ( input ) ;
327- source = uglify . uglify . ast_mangle ( source ) ;
328- source = uglify . uglify . ast_squeeze ( source ) ;
329- source = uglify . uglify . gen_code ( source ) ;
330+ var ast = uglify2 . parse ( input , {
331+ filename : filename
332+ } ) ;
333+ ast . figure_out_scope ( )
334+ if ( options . compress !== false ) {
335+ var compressor = uglify2 . Compressor ( options ) ;
336+ ast = ast . transform ( compressor ) ;
337+ ast . figure_out_scope ( ) ;
338+ ast . compute_char_frequency ( options . mangle || { } ) ;
339+ ast . mangle_names ( options . mangle || { } ) ;
340+ }
341+ var source = ast . print_to_string ( {
342+ comments : options . comments || / ^ \* * ! | @ p r e s e r v e | @ l i c e n s e / ,
343+ beautify : beautify
344+ } ) ;
330345 } catch ( e ) {
331- throw new Error ( filename + " @ Line " + e . line + ", Col " + e . col + ", " + e . message ) ;
346+ throw new Error ( filename + " @ Line " + e . line + ", Col " + e . col + ", " + e ) ;
332347 return input ;
333348 }
334349 return source ;
0 commit comments