From 87af68c0928d169f94e211c8fd069d27d1e29af4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 19 May 2013 11:45:24 -0700 Subject: [PATCH] Add Java options for faster Closure Compiler minification to minify.js. Former-commit-id: b493d461e78d0df80c80805a570220fdff93d487 --- build/minify.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/build/minify.js b/build/minify.js index 2b8a670ec..a007984db 100755 --- a/build/minify.js +++ b/build/minify.js @@ -3,8 +3,8 @@ 'use strict'; /** Load Node.js modules */ - var https = require('https'), - spawn = require('child_process').spawn, + var cp = require('child_process'), + https = require('https'), zlib = require('zlib'); /** Load other modules */ @@ -59,6 +59,17 @@ }; }()); + /** + * Java command-line options used for faster minification. + * See https://code.google.com/p/closure-compiler/wiki/FAQ#What_are_the_recommended_Java_VM_command-line_options?. + */ + var javaOptions = []; + cp.exec('java -version -client -d32', function(error) { + if (!error && process.platform != 'win32') { + javaOptions.push('-client', '-d32'); + } + }); + /** The Closure Compiler optimization modes */ var optimizationModes = { 'simple': 'SIMPLE_OPTIMIZATIONS', @@ -375,8 +386,7 @@ if (isMapped) { options.push('--create_source_map=' + mapPath, '--source_map_format=V3'); } - - var compiler = spawn('java', ['-jar', closurePath].concat(options)); + var compiler = cp.spawn('java', javaOptions.concat('-jar', closurePath, options)); if (!this.isSilent) { console.log('Compressing ' + path.basename(outputPath, '.js') + ' using the Closure Compiler (' + mode + ')...'); }