Skip to content

Commit

Permalink
Update uglify to v2.7.0. (#416)
Browse files Browse the repository at this point in the history
* bump uglify-js to 2.7

* Update files for `screw_ie8` being true in uglify 2.7.0.

* Minor lint tweaks.

* v2.0.0.
  • Loading branch information
XhmikosR authored and vladikoff committed Jul 19, 2016
1 parent 48285c9 commit 2d04f24
Show file tree
Hide file tree
Showing 16 changed files with 88 additions and 70 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_js:
- "0.12"
- "4"
- "5"
- "6"
- "iojs"

matrix:
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
70 changes: 35 additions & 35 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -141,7 +141,7 @@ module.exports = function(grunt) {
src: 'test/fixtures/src/screwIE8.js',
dest: 'tmp/screwIE8.js',
options: {
screwIE8: true
screwIE8: false
}
},
exportAll: {
Expand Down Expand Up @@ -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';
}
}
},
Expand All @@ -218,7 +218,7 @@ module.exports = function(grunt) {
},
options: {
sourceMap: true,
sourceMapName: function( dest ) {
sourceMapName: function(dest) {
return dest+'.fn.map';
}
}
Expand All @@ -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: {
Expand All @@ -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: {
Expand Down Expand Up @@ -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);
});

Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -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


Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.*
2 changes: 2 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/uglify-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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/"
Expand All @@ -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": {
Expand Down
36 changes: 24 additions & 12 deletions tasks/lib/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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();
}
Expand All @@ -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 = {};
Expand All @@ -140,16 +149,19 @@ 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
});
}
}

if (options.mangle !== false) {
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
Expand Down Expand Up @@ -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;
}

Expand All @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tasks/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module.exports = function(grunt) {
expression: false,
maxLineLen: 32000,
ASCIIOnly: false,
screwIE8: false,
screwIE8: true,
quoteStyle: 0
});

Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/expected/quotes_double.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/expected/quotes_original.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/expected/quotes_single.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/expected/screwIE8.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
var reserved_words={class:!0};
var reserved_words={"class":!0};
2 changes: 1 addition & 1 deletion test/fixtures/expected/sourcemapin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/expected/sourcemapin_sources.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/fixtures/src/screwIE8.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// screw-ie8 true will remove quotes
// screw-ie8 false will not remove quotes
var reserved_words = {
'class': true
};

0 comments on commit 2d04f24

Please sign in to comment.