Support SpiderMonkey AST in UglifyJS.minify. Fix #393.
This commit is contained in:
@@ -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,22 +61,26 @@ 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;
|
||||||
files.forEach(function(file){
|
|
||||||
var code = options.fromString
|
if (options.spidermonkey) {
|
||||||
? file
|
toplevel = UglifyJS.AST_Node.from_mozilla_ast(files);
|
||||||
: fs.readFileSync(file, "utf8");
|
} else {
|
||||||
toplevel = UglifyJS.parse(code, {
|
if (typeof files == "string")
|
||||||
filename: options.fromString ? "?" : file,
|
files = [ files ];
|
||||||
toplevel: toplevel
|
files.forEach(function(file){
|
||||||
|
var code = options.fromString
|
||||||
|
? file
|
||||||
|
: fs.readFileSync(file, "utf8");
|
||||||
|
toplevel = UglifyJS.parse(code, {
|
||||||
|
filename: options.fromString ? "?" : file,
|
||||||
|
toplevel: toplevel
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
// 2. compress
|
// 2. compress
|
||||||
if (options.compress) {
|
if (options.compress) {
|
||||||
|
|||||||
Reference in New Issue
Block a user