From: Igor Lima Date: Thu, 21 Feb 2013 02:24:24 +0000 (-0300) Subject: Upgrading from 1.0 to 2.0 uglify version X-Git-Tag: 2.1.0~55^2~1^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F647%2Fhead;p=thirdparty%2Fmoment.git Upgrading from 1.0 to 2.0 uglify version --- diff --git a/Gruntfile.js b/Gruntfile.js index 6e65f57aa..1bc22691b 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,5 +1,4 @@ -var fs = require('fs'), - uglifyjs = require('uglify-js'); +var fs = require('fs'); module.exports = function (grunt) { @@ -51,13 +50,12 @@ module.exports = function (grunt) { files: minifiedFiles }, options: { - mangle: { - toplevel: true - }, - squeeze: { + fromString: true, + mangle: true, + compress: { dead_code: false }, - codegen: { + output: { ascii_only: true } } diff --git a/package.json b/package.json index 5ba43f7a7..748edb009 100755 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ } ], "devDependencies" : { - "uglify-js" : "1.3.4", + "uglify-js" : "latest", "grunt" : "latest", "grunt-contrib-jshint" : "latest", "grunt-contrib-nodeunit" : "latest", diff --git a/tasks/minify-lang.js b/tasks/minify-lang.js index d7b3803d6..e22b74842 100644 --- a/tasks/minify-lang.js +++ b/tasks/minify-lang.js @@ -34,18 +34,21 @@ module.exports = function (grunt) { min, code, comments, - tok; + tok, + result; // Concat specified files. This should really be a single, pre-built (and // linted) file, but it supports any number of files. code = helpers.concat(files, {separator: this.data.separator}); // Add the first comments - tok = uglifyjs.parser.tokenizer(code); - min = showCopyright(tok().comments_before); + //tok = uglifyjs.parse(code); + tok = uglifyjs.parse(code); + min = showCopyright(tok.start.comments_before); // Add the minified source. - min += uglifyjs(wrapFile(code), grunt.config('uglify')); + result = uglifyjs.minify(wrapFile(code), grunt.config('uglify.options')); + min += result.code; grunt.file.write(this.data.dest, min); // Fail task if errors were logged. diff --git a/tasks/minify.js b/tasks/minify.js index a6b09445b..c8ff9c82b 100644 --- a/tasks/minify.js +++ b/tasks/minify.js @@ -15,18 +15,20 @@ module.exports = function (grunt) { min, code, comments, - tok; + tok, + result; // Concat specified files. This should really be a single, pre-built (and // linted) file, but it supports any number of files. code = helpers.concat(files, {separator: this.data.separator}); // Add the first comments - tok = uglifyjs.parser.tokenizer(code); - min = showCopyright(tok().comments_before); + tok = uglifyjs.parse(code); + min = showCopyright(tok.start.comments_before); // Add the minified source. - min += uglifyjs(code, grunt.config('uglify')); + result = uglifyjs.minify(code, grunt.config('uglify.options')); + min += result.code; grunt.file.write(this.data.dest, min); // Fail task if errors were logged.