How to use the uglify-js.AST_Toplevel function in uglify-js

To help you get started, we’ve selected a few uglify-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jlooper / MIKE / sample-app / public / kendo / bower_components / kendo-ui / src / build / kendo-meta.js View on Github external
var code = [];
    loadComponents(files).forEach(function(f){
        var comp = getKendoFile(f);
        var ast = comp.getFullAST_noDeps();
        // must be an IIFE.
        if (!(ast instanceof U2.AST_Lambda)) {
            console.log("Got wrong node!", ast.TYPE);
            throw new Error("BAD AST NOTE IN BUILD");
        }
        code.push(new U2.AST_SimpleStatement({
            body: new U2.AST_Call({
                expression: ast, args: []
            })
        }));
    });
    var min = minify(new U2.AST_Toplevel({ body: code }));
    return get_wrapper().wrap([], min);
}
github telerik / kendo-ui-core / build / kendo-meta.js View on Github external
var code = [];
    loadComponents(files).forEach(function(f){
        var comp = getKendoFile(f);
        var ast = comp.getFullAST_noDeps();
        // must be an IIFE.
        if (!(ast instanceof U2.AST_Lambda)) {
            console.log("Got wrong node!", ast.TYPE);
            throw new Error("BAD AST NOTE IN BUILD");
        }
        code.push(new U2.AST_SimpleStatement({
            body: new U2.AST_Call({
                expression: ast, args: []
            })
        }));
    });
    var min = minify(new U2.AST_Toplevel({ body: code }));
    return get_wrapper().wrap([], min);
}
github jlooper / MIKE / sample-app / public / kendo / bower_components / kendo-ui / src / build / kendo-meta.js View on Github external
function extract_widget_info(ast) {
    ast = new U2.AST_Toplevel(ast);
    ast.figure_out_scope();
    var widgets = [];
    var scope = null;

    // Quick-n-dirty heuristic that should cover the use cases in Kendo.
    function dumb_eval(node) {
        if (node instanceof U2.AST_Constant) {
            return node.getValue();
        }
        if (node instanceof U2.AST_SymbolRef) {
            var init = node.definition().init;
            if (init) {
                return dumb_eval(init);
            }
            return node.name;
        }
github telerik / kendo-ui-core / build / kendo-meta.js View on Github external
function extract_widget_info(ast) {
    ast = new U2.AST_Toplevel(ast);
    ast.figure_out_scope();
    var widgets = [];
    var scope = null;

    // Quick-n-dirty heuristic that should cover the use cases in Kendo.
    function dumb_eval(node) {
        if (node instanceof U2.AST_Constant) {
            return node.getValue();
        }
        if (node instanceof U2.AST_SymbolRef) {
            var init = node.definition().init;
            if (init) {
                return dumb_eval(init);
            }
            return node.name;
        }
github mishoo / livenode / livenode.js View on Github external
function rewrite_globals(code, ctx) {
    var ast;
    if (code instanceof u2.AST_Node) {
        ast = new u2.AST_Toplevel({
            body: [ code ]
        });
    } else {
        ast = u2.parse(code);
        ast.figure_out_scope({ screw_ie: true });
    }
    var hoisted = [];
    var warnings = [];
    function in_context(sym) {
        if (ctx) {
            return sym.global() && sym.name in ctx;
        } else {
            return sym.global() && !sym.undeclared();
        }
    };
    var tt = new u2.TreeTransformer(function before(node, descend){