upgrade to uglify-js 3.0.5
authoralexlamsl <alexlamsl@gmail.com>
Mon, 15 May 2017 19:26:18 +0000 (03:26 +0800)
committeralexlamsl <alexlamsl@gmail.com>
Mon, 15 May 2017 19:26:18 +0000 (03:26 +0800)
bump to clean-css 4.1.2

Gruntfile.js
package.json
src/htmlminifier.js

index 07b36d6..caf4790 100644 (file)
@@ -30,7 +30,25 @@ module.exports = function(grunt) {
       src: {
         options: {
           banner: '<%= banner %>',
+          preBundleCB: function() {
+            var fs = require('fs');
+            var UglifyJS = require('uglify-js');
+            var files = {};
+            UglifyJS.FILES.forEach(function(file) {
+              files[file] = fs.readFileSync(file, 'utf8');
+            });
+            fs.writeFileSync('./dist/uglify.js', UglifyJS.minify(files, {
+              compress: false,
+              mangle: false,
+              wrap: 'exports'
+            }).code);
+          },
+          postBundleCB: function(err, src, next) {
+            require('fs').unlinkSync('./dist/uglify.js');
+            next(err, src);
+          },
           require: [
+            './dist/uglify.js:uglify-js',
             './src/htmlminifier.js:html-minifier'
           ]
         },
index 86a2f12..8e565e9 100644 (file)
   },
   "dependencies": {
     "camel-case": "3.0.x",
-    "clean-css": "4.0.x",
+    "clean-css": "4.1.x",
     "commander": "2.9.x",
     "he": "1.1.x",
     "ncname": "1.0.x",
     "param-case": "2.1.x",
     "relateurl": "0.2.x",
-    "uglify-js": "~2.8.22"
+    "uglify-js": "3.0.x"
   },
   "devDependencies": {
     "grunt": "1.0.x",
     "grunt-browserify": "5.0.x",
-    "grunt-contrib-uglify": "2.3.x",
+    "grunt-contrib-uglify": "3.0.x",
     "gruntify-eslint": "3.1.x",
     "phantomjs-prebuilt": "2.1.x",
-    "qunitjs": "2.x",
-    "uglify-to-browserify": "1.0.x"
+    "qunitjs": "2.x"
   },
   "benchmarkDependencies": {
     "brotli": "1.3.x",
index 318e0ad..db2c56a 100644 (file)
@@ -676,23 +676,17 @@ function processOptions(options) {
     if (typeof minifyJS !== 'object') {
       minifyJS = {};
     }
-    minifyJS.fromString = true;
     (minifyJS.parse || (minifyJS.parse = {})).bare_returns = false;
     options.minifyJS = function(text, inline) {
       var start = text.match(/^\s*<!--.*/);
       var code = start ? text.slice(start[0].length).replace(/\n\s*-->\s*$/, '') : text;
-      try {
-        minifyJS.parse.bare_returns = inline;
-        code = UglifyJS.minify(code, minifyJS).code;
-        if (/;$/.test(code)) {
-          code = code.slice(0, -1);
-        }
-        return code;
-      }
-      catch (err) {
-        options.log(err);
+      minifyJS.parse.bare_returns = inline;
+      var result = UglifyJS.minify(code, minifyJS);
+      if (result.error) {
+        options.log(result.error);
         return text;
       }
+      return result.code.replace(/;$/, '');
     };
   }