From 2d04f24e347cd6429856516385d61673a94d57ae Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Tue, 19 Jul 2016 17:11:18 +0300 Subject: [PATCH] Update uglify to v2.7.0. (#416) * bump uglify-js to 2.7 * Update files for `screw_ie8` being true in uglify 2.7.0. * Minor lint tweaks. * v2.0.0. --- .travis.yml | 1 + CHANGELOG | 6 +- Gruntfile.js | 70 +++++++++---------- README.md | 15 ++-- appveyor.yml | 2 + docs/uglify-options.md | 4 +- package.json | 6 +- tasks/lib/uglify.js | 36 ++++++---- tasks/uglify.js | 4 +- test/fixtures/expected/quotes_double.js | 2 +- test/fixtures/expected/quotes_original.js | 2 +- test/fixtures/expected/quotes_single.js | 2 +- test/fixtures/expected/screwIE8.js | 2 +- test/fixtures/expected/sourcemapin.js.map | 2 +- .../expected/sourcemapin_sources.js.map | 2 +- test/fixtures/src/screwIE8.js | 2 +- 16 files changed, 88 insertions(+), 70 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7e7f4766..2eac80c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ node_js: - "0.12" - "4" - "5" + - "6" - "iojs" matrix: diff --git a/CHANGELOG b/CHANGELOG index 9b86072a..b7bb15e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ +v2.0.0: + date: 2016-07-19 + changes: + - Update uglify-js to v2.7.0. `screwIE8` is enabled by default. v1.0.2: - date: 2016-03-19 + date: 2016-07-19 changes: - Update grunt to ^1.0.0. - Fix `beautify` when passed as an object. diff --git a/Gruntfile.js b/Gruntfile.js index cca33d75..5003c2ad 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -55,8 +55,8 @@ module.exports = function(grunt) { files: { 'tmp/compress_mangle_banner.js': ['test/fixtures/src/simple.js'] }, - options : { - banner : '// banner without sourcemap\n' + options: { + banner: '// banner without sourcemap\n' } }, no_src: { @@ -99,7 +99,7 @@ module.exports = function(grunt) { }, multifile: { files: { - 'tmp/multifile.js': ['test/fixtures/src/simple.js','test/fixtures/src/comments.js'] + 'tmp/multifile.js': ['test/fixtures/src/simple.js', 'test/fixtures/src/comments.js'] }, options: { mangle: false @@ -141,7 +141,7 @@ module.exports = function(grunt) { src: 'test/fixtures/src/screwIE8.js', dest: 'tmp/screwIE8.js', options: { - screwIE8: true + screwIE8: false } }, exportAll: { @@ -197,8 +197,8 @@ module.exports = function(grunt) { dest: 'tmp/sourcemap_functionName.js', options: { sourceMap: true, - sourceMapName: function( dest ) { - return dest + ".fn.map"; + sourceMapName: function(dest) { + return dest + '.fn.map'; } } }, @@ -218,7 +218,7 @@ module.exports = function(grunt) { }, options: { sourceMap: true, - sourceMapName: function( dest ) { + sourceMapName: function(dest) { return dest+'.fn.map'; } } @@ -238,13 +238,13 @@ module.exports = function(grunt) { } }, sourcemap_sources: { - files: { - 'tmp/sourcemap_sources.js': ['test/fixtures/src/simple.js'] - }, - options: { - sourceMap: true, - sourceMapIncludeSources: true - } + files: { + 'tmp/sourcemap_sources.js': ['test/fixtures/src/simple.js'] + }, + options: { + sourceMap: true, + sourceMapIncludeSources: true + } }, sourcemapin_sources: { files: { @@ -259,24 +259,24 @@ module.exports = function(grunt) { } }, expression_json: { - files: { - 'tmp/expression.json': ['test/fixtures/src/simple.json'] - }, - options: { - expression: true, - mangle: false, - compress: false - } + files: { + 'tmp/expression.json': ['test/fixtures/src/simple.json'] + }, + options: { + expression: true, + mangle: false, + compress: false + } }, expression_js: { - files: { - 'tmp/expression.js': ['test/fixtures/src/expression.js'] - }, - options: { - expression: true, - mangle: false, - compress: false - } + files: { + 'tmp/expression.js': ['test/fixtures/src/expression.js'] + }, + options: { + expression: true, + mangle: false, + compress: false + } }, mangleprops: { files: { @@ -396,20 +396,20 @@ module.exports = function(grunt) { }); // task that expects its argument (another task) to fail - grunt.registerTask('expectFail', function(){ + grunt.registerTask('expectFail', function() { var task = this.args.join(':'); var done = this.async(); function onComplete(error, result) { - grunt.log.write("\n > " + result.stdout.split("\n").join("\n > ") + "\n"); - var rv = error ? true : new Error("Task " + task + " unexpectedly passed."); + grunt.log.write('\n > ' + result.stdout.split('\n').join('\n > ') + '\n'); + var rv = error ? true : new Error('Task ' + task + ' unexpectedly passed.'); done(rv); } grunt.util.spawn({ - grunt : true, - args : task + grunt: true, + args: task }, onComplete); }); diff --git a/README.md b/README.md index f64cf98c..20aeea44 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# grunt-contrib-uglify v1.0.2 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-uglify.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-uglify) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/ybtf5vbvtenii561/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-contrib-uglify/branch/master) +# grunt-contrib-uglify v2.0.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-uglify.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-uglify) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/ybtf5vbvtenii561/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-contrib-uglify/branch/master) -> Minify javascript files with UglifyJS +> Minify JavaScript files with UglifyJS @@ -186,9 +186,9 @@ This string will be appended to the minified output. Template strings (e.g. `<%= #### screwIE8 Type: `Boolean` -Default: `false` +Default: `true` -Pass this flag if you don't care about full compliance with Internet Explorer 6-8 quirks. +Set this to `false` if you still care about full compliance with Internet Explorer 6-8 quirks. #### mangleProperties Type: `Boolean` `Object` @@ -513,13 +513,12 @@ grunt.initConfig({ } }); ``` -#### Quiet Mode -By default the task supresses the logging, use _--verbose_ to show the full output. ## Release History - * 2016-03-19   v1.0.2   Update grunt to ^1.0.0. Fix `beautify` when passed as an object. Fix docs about `report` values. + * 2016-07-19   v2.0.0   Update uglify-js to v2.7.0. `screwIE8` is enabled by default. + * 2016-07-19   v1.0.2   Update grunt to ^1.0.0. Fix `beautify` when passed as an object. Fix docs about `report` values. * 2016-03-16   v1.0.1   Downgrade maxmin for Node.js 0.10. * 2016-03-04   v1.0.0   Use uglify-js ~2.6.2 to fix sourcemap issue. Improve docs for `global-defs` and `--define` options. Add `sourceMapUrl` option. Add `bare_returns` option. Optionally set report verbosity level using report option. * 2016-01-29   v0.11.1   Update lodash to ^4.0.1. Update grunt-contrib-clean to ^0.7.0. Update grunt-contrib-jshint to ^0.12.0. @@ -557,4 +556,4 @@ By default the task supresses the logging, use _--verbose_ to show the full outp Task submitted by ["Cowboy" Ben Alman](http://benalman.com) -*This file was generated on Tue Jul 19 2016 16:34:56.* +*This file was generated on Tue Jul 19 2016 16:46:21.* diff --git a/appveyor.yml b/appveyor.yml index 5792ee4d..62725fbc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,6 +15,8 @@ environment: platform: x86 - nodejs_version: "5" platform: x86 + - nodejs_version: "6" + platform: x86 install: - ps: Install-Product node $env:nodejs_version $env:platform diff --git a/docs/uglify-options.md b/docs/uglify-options.md index c4725c64..6ef4f0ed 100644 --- a/docs/uglify-options.md +++ b/docs/uglify-options.md @@ -137,9 +137,9 @@ This string will be appended to the minified output. Template strings (e.g. `<%= ## screwIE8 Type: `Boolean` -Default: `false` +Default: `true` -Pass this flag if you don't care about full compliance with Internet Explorer 6-8 quirks. +Set this to `false` if you still care about full compliance with Internet Explorer 6-8 quirks. ## mangleProperties Type: `Boolean` `Object` diff --git a/package.json b/package.json index b9f252b1..aff25b4a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "grunt-contrib-uglify", - "description": "Minify javascript files with UglifyJS", - "version": "1.0.2", + "description": "Minify JavaScript files with UglifyJS", + "version": "2.0.0", "author": { "name": "Grunt Team", "url": "http://gruntjs.com/" @@ -19,7 +19,7 @@ "chalk": "^1.0.0", "lodash.assign": "^4.0.9", "maxmin": "^1.1.0", - "uglify-js": "~2.6.2", + "uglify-js": "~2.7.0", "uri-path": "^1.0.0" }, "devDependencies": { diff --git a/tasks/lib/uglify.js b/tasks/lib/uglify.js index 11cea8f5..4b67bcaf 100644 --- a/tasks/lib/uglify.js +++ b/tasks/lib/uglify.js @@ -81,7 +81,10 @@ exports.init = function(grunt) { // Need to call this before we mangle or compress, // and call after any compression or ast altering if (options.expression === false) { - topLevel.figure_out_scope({ screw_ie8: options.screwIE8, cache: topLevelCache }); + topLevel.figure_out_scope({ + screw_ie8: options.screwIE8, + cache: topLevelCache + }); } if (options.compress !== false) { @@ -91,19 +94,25 @@ exports.init = function(grunt) { if (options.compress.warnings !== true) { options.compress.warnings = false; } - if (options.screwIE8) { - options.compress.screw_ie8 = true; + if (options.screwIE8 === false) { + options.compress.screw_ie8 = false; } var compressor = UglifyJS.Compressor(options.compress); topLevel = topLevel.transform(compressor); // Need to figure out scope again after source being altered if (options.expression === false) { - topLevel.figure_out_scope({screw_ie8: options.screwIE8, cache: topLevelCache}); + topLevel.figure_out_scope({ + screw_ie8: options.screwIE8, + cache: topLevelCache + }); } } - var mangleExclusions = { vars: [], props: [] }; + var mangleExclusions = { + vars: [], + props: [] + }; if (options.reserveDOMProperties) { mangleExclusions = UglifyJS.readDefaultReservedFile(); } @@ -123,7 +132,7 @@ exports.init = function(grunt) { cache = UglifyJS.readNameCache(options.nameCache, 'props'); } - if (typeof(options.mangleProperties) !== 'undefined' && options.mangleProperties !== false) { + if (typeof options.mangleProperties !== 'undefined' && options.mangleProperties !== false) { // if options.mangleProperties is a boolean (true) convert it into an object if (typeof options.mangleProperties !== 'object') { options.mangleProperties = {}; @@ -140,7 +149,10 @@ exports.init = function(grunt) { // Need to figure out scope again since topLevel has been altered if (options.expression === false) { - topLevel.figure_out_scope({screw_ie8: options.screwIE8, cache: topLevelCache}); + topLevel.figure_out_scope({ + screw_ie8: options.screwIE8, + cache: topLevelCache + }); } } @@ -148,8 +160,8 @@ exports.init = function(grunt) { if (options.mangle === true) { options.mangle = {}; } - if (options.screwIE8) { - options.mangle.screw_ie8 = true; + if (options.screwIE8 === false) { + options.mangle.screw_ie8 = false; } // disabled due to: // 1) preserve stable name mangling @@ -195,7 +207,7 @@ exports.init = function(grunt) { if (options.sourceMap) { // Set all paths to forward slashes for use in the browser var sourceMappingURL; - sourceMappingURL = options.destToSourceMap.match(/^http[s]?\:\/\//) === null ? uriPath(options.destToSourceMap) : options.destToSourceMap; + sourceMappingURL = options.destToSourceMap.match(/^http[s]?:\/\//) === null ? uriPath(options.destToSourceMap) : options.destToSourceMap; min += '\n//# sourceMappingURL=' + sourceMappingURL; } @@ -220,8 +232,8 @@ exports.init = function(grunt) { outputOptions.preamble = options.banner; } - if (options.screwIE8) { - outputOptions.screw_ie8 = true; + if (options.screwIE8 === false) { + outputOptions.screw_ie8 = false; } if (options.sourceMap) { diff --git a/tasks/uglify.js b/tasks/uglify.js index 6a306776..d1e1fbed 100644 --- a/tasks/uglify.js +++ b/tasks/uglify.js @@ -47,7 +47,7 @@ module.exports = function(grunt) { expression: false, maxLineLen: 32000, ASCIIOnly: false, - screwIE8: false, + screwIE8: true, quoteStyle: 0 }); @@ -124,7 +124,7 @@ module.exports = function(grunt) { // Calculate the path from the dest file to the sourcemap for the // sourceMappingURL reference // If sourceMapUrl is defined, use this instead - if(options.sourceMap) { + if (options.sourceMap) { var destToSourceMapPath, sourceMapBasename; if (!options.sourceMapUrl) { destToSourceMapPath = relativePath(f.dest, options.generatedSourceMapName); diff --git a/test/fixtures/expected/quotes_double.js b/test/fixtures/expected/quotes_double.js index 4e3a5e20..29a920cd 100644 --- a/test/fixtures/expected/quotes_double.js +++ b/test/fixtures/expected/quotes_double.js @@ -1 +1 @@ -function llama(){var a="This is a single quote string",b="This is a double quote string",c={"this":"is part of an Object",and:"so is this",but:"this one has \"mixed\" quotes: '"};return[a,b,c]} \ No newline at end of file +function llama(){var a="This is a single quote string",b="This is a double quote string",c={this:"is part of an Object",and:"so is this",but:"this one has \"mixed\" quotes: '"};return[a,b,c]} \ No newline at end of file diff --git a/test/fixtures/expected/quotes_original.js b/test/fixtures/expected/quotes_original.js index 78ea27f7..296ab5cd 100644 --- a/test/fixtures/expected/quotes_original.js +++ b/test/fixtures/expected/quotes_original.js @@ -1 +1 @@ -function llama(){var a='This is a single quote string',b="This is a double quote string",c={"this":"is part of an Object",and:'so is this',but:'this one has "mixed" quotes: \''};return[a,b,c]} \ No newline at end of file +function llama(){var a='This is a single quote string',b="This is a double quote string",c={this:"is part of an Object",and:'so is this',but:'this one has "mixed" quotes: \''};return[a,b,c]} \ No newline at end of file diff --git a/test/fixtures/expected/quotes_single.js b/test/fixtures/expected/quotes_single.js index 7dfd7cd1..b7628d32 100644 --- a/test/fixtures/expected/quotes_single.js +++ b/test/fixtures/expected/quotes_single.js @@ -1 +1 @@ -function llama(){var a='This is a single quote string',b='This is a double quote string',c={'this':'is part of an Object',and:'so is this',but:'this one has "mixed" quotes: \''};return[a,b,c]} \ No newline at end of file +function llama(){var a='This is a single quote string',b='This is a double quote string',c={this:'is part of an Object',and:'so is this',but:'this one has "mixed" quotes: \''};return[a,b,c]} \ No newline at end of file diff --git a/test/fixtures/expected/screwIE8.js b/test/fixtures/expected/screwIE8.js index 25f8a893..a8ae2a31 100644 --- a/test/fixtures/expected/screwIE8.js +++ b/test/fixtures/expected/screwIE8.js @@ -1 +1 @@ -var reserved_words={class:!0}; \ No newline at end of file +var reserved_words={"class":!0}; \ No newline at end of file diff --git a/test/fixtures/expected/sourcemapin.js.map b/test/fixtures/expected/sourcemapin.js.map index a61fad6a..918379de 100644 --- a/test/fixtures/expected/sourcemapin.js.map +++ b/test/fixtures/expected/sourcemapin.js.map @@ -1 +1 @@ -{"version":3,"sources":["../test/fixtures/src/simple2.coffee"],"names":["number","opposite","square","x","list","math","root","Math","sqrt","cube","race","winner","runners","arguments","length","slice","call","print","elvis","alert","cubes","accum$","i$","length$","num"],"mappings":";;+DACCA,QAAW,GACXC,UAAW,EAGKA,WAAhBD,YAGAE,OAAS,SAAAC,SAAOA,GAAIA,GAGpBC,MAAQ,EAAG,EAAG,EAAG,EAAG,GAGpBC,MACGC,KAAQC,KAAIC,KACbN,OAAQA,OACRO,KAAQ,SAAAN,SAAOA,GAAID,OAAOC,KAG1BO,KAAO,SAAAC,OAAAC,eAASA,SAAA,GAAAC,UAAAC,UAAAC,MAAAC,KAAAH,UAAA,MACfI,MAAMN,OAAQC,UAGf,mBAAsBM,QAAA,MAAAA,OAAtBC,MAAM,cAGRC,MAAA,SAAAC,QAAS,IAAA,QAAAC,GAAA,EAAAC,QAAyBnB,KAAAU,OAAzBQ,GAAAC,UAAAD,GAAkBE,IAAOpB,KAAAkB,gBAAzBjB,KAAII,KAAMe","file":"sourcemapin.js"} \ No newline at end of file +{"version":3,"sources":["../test/fixtures/src/simple2.coffee"],"names":["number","opposite","square","x","list","math","root","Math","sqrt","cube","race","winner","runners","arguments","length","slice","call","print","elvis","alert","cubes","accum$","i$","length$","num"],"mappings":";;+DACCA,QAAW,GACXC,UAAW,EAGKA,WAAhBD,QAAS,IAGTE,OAAS,SAAAC,SAAOA,GAAIA,GAGpBC,MAAQ,EAAG,EAAG,EAAG,EAAG,GAGpBC,MACGC,KAAQC,KAAIC,KACbN,OAAQA,OACRO,KAAQ,SAAAN,SAAOA,GAAID,OAAOC,KAG1BO,KAAO,SAAAC,OAAAC,eAASA,SAAA,GAAAC,UAAAC,UAAAC,MAAAC,KAAAH,UAAA,MACfI,MAAMN,OAAQC,UAGf,mBAAsBM,QAAA,MAAAA,OAAtBC,MAAM,cAGRC,MAAA,SAAAC,QAAS,IAAA,QAAAC,GAAA,EAAAC,QAAyBnB,KAAAU,OAAzBQ,GAAAC,UAAAD,GAAkBE,IAAOpB,KAAAkB,gBAAzBjB,KAAII,KAAMe","file":"sourcemapin.js"} \ No newline at end of file diff --git a/test/fixtures/expected/sourcemapin_sources.js.map b/test/fixtures/expected/sourcemapin_sources.js.map index d7aa3505..113a5968 100644 --- a/test/fixtures/expected/sourcemapin_sources.js.map +++ b/test/fixtures/expected/sourcemapin_sources.js.map @@ -1 +1 @@ -{"version":3,"sources":["../test/fixtures/src/simple2.coffee"],"names":["number","opposite","square","x","list","math","root","Math","sqrt","cube","race","winner","runners","arguments","length","slice","call","print","elvis","alert","cubes","accum$","i$","length$","num"],"mappings":"iCACCA,GAAW,GACXC,GAAW,EAGKA,IAAhBD,OAGAE,EAAS,SAAAC,SAAOA,GAAIA,GAGpBC,GAAQ,EAAG,EAAG,EAAG,EAAG,GAGpBC,GACGC,KAAQC,KAAIC,KACbN,OAAQA,EACRO,KAAQ,SAAAN,SAAOA,GAAID,EAAOC,KAG1BO,EAAO,SAAAC,EAAAC,SAASA,GAAA,GAAAC,UAAAC,UAAAC,MAAAC,KAAAH,UAAA,MACfI,MAAMN,EAAQC,IAGf,mBAAsBM,QAAA,MAAAA,OAAtBC,MAAM,cAGRC,EAAA,SAAAC,GAAS,IAAA,MAAAC,EAAA,EAAAC,EAAyBnB,EAAAU,OAAzBQ,EAAAC,IAAAD,EAAkBE,EAAOpB,EAAAkB,UAAzBjB,EAAII,KAAMe","file":"sourcemapin_sources.js","sourcesContent":["# Assignment:\nnumber = 42\nopposite = true\n\n# Conditions:\nnumber = -42 if opposite\n\n# Functions:\nsquare = (x) -> x * x\n\n# Arrays:\nlist = [1, 2, 3, 4, 5]\n\n# Objects:\nmath =\n root: Math.sqrt\n square: square\n cube: (x) -> x * square x\n\n# Splats:\nrace = (winner, runners...) ->\n print winner, runners\n\n# Existence:\nalert \"I knew it!\" if elvis?\n\n# Array comprehensions:\ncubes = (math.cube num for num in list)"]} \ No newline at end of file +{"version":3,"sources":["../test/fixtures/src/simple2.coffee"],"names":["number","opposite","square","x","list","math","root","Math","sqrt","cube","race","winner","runners","arguments","length","slice","call","print","elvis","alert","cubes","accum$","i$","length$","num"],"mappings":"iCACCA,GAAW,GACXC,GAAW,EAGKA,IAAhBD,GAAS,IAGTE,EAAS,SAAAC,SAAOA,GAAIA,GAGpBC,GAAQ,EAAG,EAAG,EAAG,EAAG,GAGpBC,GACGC,KAAQC,KAAIC,KACbN,OAAQA,EACRO,KAAQ,SAAAN,SAAOA,GAAID,EAAOC,KAG1BO,EAAO,SAAAC,EAAAC,SAASA,GAAA,GAAAC,UAAAC,UAAAC,MAAAC,KAAAH,UAAA,MACfI,MAAMN,EAAQC,IAGf,mBAAsBM,QAAA,MAAAA,OAAtBC,MAAM,cAGRC,EAAA,SAAAC,GAAS,IAAA,MAAAC,EAAA,EAAAC,EAAyBnB,EAAAU,OAAzBQ,EAAAC,IAAAD,EAAkBE,EAAOpB,EAAAkB,UAAzBjB,EAAII,KAAMe","file":"sourcemapin_sources.js","sourcesContent":["# Assignment:\nnumber = 42\nopposite = true\n\n# Conditions:\nnumber = -42 if opposite\n\n# Functions:\nsquare = (x) -> x * x\n\n# Arrays:\nlist = [1, 2, 3, 4, 5]\n\n# Objects:\nmath =\n root: Math.sqrt\n square: square\n cube: (x) -> x * square x\n\n# Splats:\nrace = (winner, runners...) ->\n print winner, runners\n\n# Existence:\nalert \"I knew it!\" if elvis?\n\n# Array comprehensions:\ncubes = (math.cube num for num in list)"]} \ No newline at end of file diff --git a/test/fixtures/src/screwIE8.js b/test/fixtures/src/screwIE8.js index 161b6c4d..70ce11e5 100644 --- a/test/fixtures/src/screwIE8.js +++ b/test/fixtures/src/screwIE8.js @@ -1,5 +1,5 @@ -// screw-ie8 true will remove quotes +// screw-ie8 false will not remove quotes var reserved_words = { 'class': true };