[Pkg-javascript-commits] [pdf.js] 179/414: Use UglifyJS to minify files in minified target

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:19 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit e403f5272232c87581b0471e04c5e94c60aca91d
Author: Timothy Gu <timothygu99 at gmail.com>
Date:   Tue Jun 30 21:47:15 2015 -0700

    Use UglifyJS to minify files in minified target
    
    It is written in JavaScript, is less buggy, and compresses better.
---
 make.js      | 30 +++++++++++-------------------
 package.json |  1 +
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/make.js b/make.js
index d7a7b96..050a798 100644
--- a/make.js
+++ b/make.js
@@ -652,15 +652,9 @@ function cleanupCSSSource(file) {
 //
 // make minified
 // Builds the minified production viewer that should be compatible with most
-// modern HTML5 browsers. Requires Google Closure Compiler.
+// modern HTML5 browsers.
 //
 target.minified = function() {
-  var compilerPath = process.env['CLOSURE_COMPILER'];
-  if (!compilerPath) {
-    echo('### Closure Compiler is not set. Specify CLOSURE_COMPILER variable');
-    exit(1);
-  }
-
   target.bundle({});
   target.locale();
 
@@ -703,22 +697,20 @@ target.minified = function() {
     MINIFIED_DIR + BUILD_DIR + 'pdf.js',
     MINIFIED_DIR + '/web/viewer.js'
   ];
-  var cmdPrefix = 'java -jar \"' + compilerPath + '\" ' +
-    '--language_in ECMASCRIPT5 ' +
-    '--warning_level QUIET ' +
-    '--compilation_level SIMPLE_OPTIMIZATIONS ';
 
   echo();
   echo('### Minifying js files');
 
-  exec(cmdPrefix + viewerFiles.map(function(s) {
-    return '--js \"' + s + '\"';
-  }).join(' ') +
-    ' --js_output_file \"' + MINIFIED_DIR + '/web/pdf.viewer.js\"');
-  exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.js' + '\" ' +
-    '--js_output_file \"' + MINIFIED_DIR + '/build/pdf.min.js' + '\"');
-  exec(cmdPrefix + '--js \"' + MINIFIED_DIR + '/build/pdf.worker.js' + '\" ' +
-    '--js_output_file \"' + MINIFIED_DIR + '/build/pdf.worker.min.js' + '\"');
+  var UglifyJS = require('uglify-js');
+  // V8 chokes on very long sequences. Works around that.
+  var optsForHugeFile = {compress: {sequences: false}};
+
+  UglifyJS.minify(viewerFiles).code
+    .to(MINIFIED_DIR + '/web/pdf.viewer.js');
+  UglifyJS.minify(MINIFIED_DIR + '/build/pdf.js').code
+    .to(MINIFIED_DIR + '/build/pdf.min.js');
+  UglifyJS.minify(MINIFIED_DIR + '/build/pdf.worker.js', optsForHugeFile).code
+    .to(MINIFIED_DIR + '/build/pdf.worker.min.js');
 
   echo();
   echo('### Cleaning js files');
diff --git a/package.json b/package.json
index 17d6076..ada1163 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
     "rimraf": "^2.4.1",
     "shelljs": "~0.4.0",
     "typogr": "~0.6.5",
+    "uglify-js": "^2.6.1",
     "wintersmith": "^2.0.0",
     "yargs": "^3.14.0"
   },

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list