aboutsummaryrefslogtreecommitdiff
path: root/tmp/test-node.js
blob: f2e0626b15857d4d3b506513712e005bcf2b41dc (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/env node

var sys = require("util");
var fs = require("fs");

var UglifyJS = require("../tools/node");

var filename = process.argv[2];
var code = fs.readFileSync(filename, "utf8");

var ast = UglifyJS.parse(code);

var tt = new UglifyJS.TreeTransformer(
    function before(node, descend) {
        if (node instanceof UglifyJS.AST_Var) {
            //return new UglifyJS.AST_EmptyStatement(node);
            return UglifyJS.MAP.skip;
        }
    },
    function after(node) {
        console.log("After ", node.TYPE);
    }
);

var x = ast.transform(tt);
sys.print(x.print_to_string({ beautify: true }));

// ast.figure_out_scope();
// ast = ast.squeeze(UglifyJS.Compressor());

// ast.compute_char_frequency();
// UglifyJS.base54.sort();

// ast.figure_out_scope();
// ast.scope_warnings();
// ast.mangle_names();

// sys.error(UglifyJS.base54.get());
// sys.print(ast.print_to_string({ beautify: true }));