Support SpiderMonkey AST in UglifyJS.minify. Fix #393.

This commit is contained in:
Mihai Bazon
2014-01-07 18:42:48 +02:00
parent 2c88eb6fbe
commit b9fac687ff

View File

@@ -51,6 +51,7 @@ for (var i in UglifyJS) {
exports.minify = function(files, options) { exports.minify = function(files, options) {
options = UglifyJS.defaults(options, { options = UglifyJS.defaults(options, {
spidermonkey : false,
outSourceMap : null, outSourceMap : null,
sourceRoot : null, sourceRoot : null,
inSourceMap : null, inSourceMap : null,
@@ -60,13 +61,16 @@ exports.minify = function(files, options) {
output : null, output : null,
compress : {} compress : {}
}); });
if (typeof files == "string")
files = [ files ];
UglifyJS.base54.reset(); UglifyJS.base54.reset();
// 1. parse // 1. parse
var toplevel = null; var toplevel = null;
if (options.spidermonkey) {
toplevel = UglifyJS.AST_Node.from_mozilla_ast(files);
} else {
if (typeof files == "string")
files = [ files ];
files.forEach(function(file){ files.forEach(function(file){
var code = options.fromString var code = options.fromString
? file ? file
@@ -76,6 +80,7 @@ exports.minify = function(files, options) {
toplevel: toplevel toplevel: toplevel
}); });
}); });
}
// 2. compress // 2. compress
if (options.compress) { if (options.compress) {