aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2014-01-07 18:42:48 +0200
committerMihai Bazon <mihai@bazon.net>2014-01-07 18:42:48 +0200
commitb9fac687ff0b2689f7ca7bdc26aa0b3671df72ce (patch)
tree7b79241698c877f96352e549145b68e3f679d4c3 /tools
parent2c88eb6fbe82d663874ae2ee144d5457cd512127 (diff)
downloadtracifyjs-b9fac687ff0b2689f7ca7bdc26aa0b3671df72ce.tar.gz
tracifyjs-b9fac687ff0b2689f7ca7bdc26aa0b3671df72ce.zip
Support SpiderMonkey AST in UglifyJS.minify. Fix #393.
Diffstat (limited to 'tools')
-rw-r--r--tools/node.js27
1 files changed, 16 insertions, 11 deletions
diff --git a/tools/node.js b/tools/node.js
index 614e083d..7e6a38df 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -51,6 +51,7 @@ for (var i in UglifyJS) {
exports.minify = function(files, options) {
options = UglifyJS.defaults(options, {
+ spidermonkey : false,
outSourceMap : null,
sourceRoot : null,
inSourceMap : null,
@@ -60,22 +61,26 @@ exports.minify = function(files, options) {
output : null,
compress : {}
});
- if (typeof files == "string")
- files = [ files ];
-
UglifyJS.base54.reset();
// 1. parse
var toplevel = null;
- files.forEach(function(file){
- var code = options.fromString
- ? file
- : fs.readFileSync(file, "utf8");
- toplevel = UglifyJS.parse(code, {
- filename: options.fromString ? "?" : file,
- toplevel: toplevel
+
+ if (options.spidermonkey) {
+ toplevel = UglifyJS.AST_Node.from_mozilla_ast(files);
+ } else {
+ if (typeof files == "string")
+ files = [ files ];
+ 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
if (options.compress) {