Switched to Closure Compiler
This is nothing against uglify. Rather, here's the story on this: Commit e4cd1e fixed an error that was causing minified files to break in IE. This was due to how IE interprets things, not how UglifyJS was minifying them. Indeed, Closure Compiler had the exact same problem. The decision to move to Closure Compiler was due to a variety of factors, which came down to primarily feature set and tests. Closure Compiler is well tested and maintained. It also includes a number of additional, beneficial features. UglifyJS is an excellent project and I would recommend it to anyone, but it is not tested (no unit tests; it's tested by ensuring common libraries like jQuery run after minification). It is, however, significantly faster. It's likely that, in the future, once I add autoconf for the build process to configure certain settings, that I will add UglifyJS as an option. I'm sure many people would prefer that, especially those who dislike Java and do not wish to have it installed. Hopefully those that do decide to install Java will go with openjdk, not Oracle's proprietary implementation.closure/master
parent
58f2e3afc4
commit
66fd2ece83
|
@ -1,2 +1,5 @@
|
||||||
build
|
build
|
||||||
node_modules
|
node_modules
|
||||||
|
|
||||||
|
# downloaded by minification build
|
||||||
|
tools/compiler.jar
|
||||||
|
|
19
Makefile
19
Makefile
|
@ -17,10 +17,11 @@ src_tests := index.js $(shell find "$(path_test)" -name test-* \
|
||||||
|
|
||||||
path_doc := ./doc
|
path_doc := ./doc
|
||||||
|
|
||||||
combine=${path_tools}/combine
|
combine := $(path_tools)/combine
|
||||||
|
compiler := $(path_tools)/compiler.jar
|
||||||
|
|
||||||
|
|
||||||
.PHONY: combine min doc test test-combine
|
.PHONY: combine min doc test test-combine clean distclean
|
||||||
|
|
||||||
|
|
||||||
default: combine min
|
default: combine min
|
||||||
|
@ -55,10 +56,15 @@ perf: default $(perf_tests)
|
||||||
perf-%.js: default
|
perf-%.js: default
|
||||||
@node $@
|
@node $@
|
||||||
|
|
||||||
min: build/ease.min.js build/ease-full.min.js $(path_build)/browser-test-min.html
|
# minificatino process uses Google Closure compiler
|
||||||
build/%.min.js: build/%.js
|
min: build/ease.min.js build/ease-full.min.js $(path_build)/browser-test-min.html \
|
||||||
|
| combine
|
||||||
|
$(compiler):
|
||||||
|
wget -O- http://closure-compiler.googlecode.com/files/compiler-latest.tar.gz \
|
||||||
|
| tar -C $(path_tools) -xzv compiler.jar
|
||||||
|
build/%.min.js: build/%.js $(compiler)
|
||||||
cat $(path_tools)/license.tpl > $@
|
cat $(path_tools)/license.tpl > $@
|
||||||
node $(path_tools)/minify.js < $< > $@
|
java -jar $(compiler) --js $< >> $@ || rm $@
|
||||||
|
|
||||||
install: doc-info
|
install: doc-info
|
||||||
[ -d $(path_info_install) ] || mkdir -p $(path_info_install)
|
[ -d $(path_info_install) ] || mkdir -p $(path_info_install)
|
||||||
|
@ -72,3 +78,6 @@ clean:
|
||||||
$(MAKE) -C $(path_doc) clean
|
$(MAKE) -C $(path_doc) clean
|
||||||
rm -rf "${path_build}"
|
rm -rf "${path_build}"
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm $(compiler)
|
||||||
|
|
||||||
|
|
|
@ -1,66 +0,0 @@
|
||||||
/**
|
|
||||||
* Minification script
|
|
||||||
*
|
|
||||||
* Takes input from stdin, mangles and minifies it, then outputs to stdout.
|
|
||||||
* ex: $ node minify.js < source.js > source.min.js
|
|
||||||
*/
|
|
||||||
|
|
||||||
// uses UglifyJS
|
|
||||||
var uglify,
|
|
||||||
FILE_ROOT = '../build/';
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// attempt to load UglifyJS
|
|
||||||
var uglify = require( 'uglify-js' );
|
|
||||||
}
|
|
||||||
catch ( e )
|
|
||||||
{
|
|
||||||
// if there's a problem loading it, let the user know what they probably
|
|
||||||
// need to do
|
|
||||||
process.stderr.write(
|
|
||||||
"Unable to located UglifyJS. Please run:\n\n" +
|
|
||||||
" $ npm install uglify-js\n\n" +
|
|
||||||
"and then try again.\n"
|
|
||||||
);
|
|
||||||
|
|
||||||
process.exit( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
var parser = uglify.parser,
|
|
||||||
uglify = uglify.uglify;
|
|
||||||
|
|
||||||
// we should receive the file via stdin
|
|
||||||
var data = '';
|
|
||||||
process.stdin
|
|
||||||
.on( 'data', function( chunk )
|
|
||||||
{
|
|
||||||
data += chunk;
|
|
||||||
} )
|
|
||||||
.on( 'end', function()
|
|
||||||
{
|
|
||||||
minify();
|
|
||||||
} )
|
|
||||||
;
|
|
||||||
|
|
||||||
// stdin is paused by default, so we have to unpause it to read
|
|
||||||
process.stdin.setEncoding( 'utf8' )
|
|
||||||
process.stdin.resume()
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Minifies and outputs the code
|
|
||||||
*
|
|
||||||
* The process involves mangling the code and minifying it.
|
|
||||||
*/
|
|
||||||
function minify()
|
|
||||||
{
|
|
||||||
var ast = parser.parse( data );
|
|
||||||
|
|
||||||
// mange and minify
|
|
||||||
ast = uglify.ast_squeeze( ast );
|
|
||||||
|
|
||||||
// output final, compressed code
|
|
||||||
process.stdout.write( uglify.gen_code( ast ) );
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue