How to use the uglify-js.AST_Call 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 ctripcorp / moles-packer / lib / transform.js View on Github external
// 创建“函数”节点。
            var nodeFunction = new UglifyJS.AST_Function({
                argnames: funargs,
                body: node.body
            });

            // 创建“返回”节点。
            var nodeReturn = new UglifyJS.AST_Return({
                value: new UglifyJS.AST_SymbolRef({ name: 'module.exports' })
            });
            let nodeSemicolon = new UglifyJS.AST_Symbol({ name: ';' });
            nodeFunction.body.push(nodeSemicolon);
            nodeFunction.body.push(nodeReturn);

            // 创建“函数调用”节点。
            var nodeDefine = new UglifyJS.AST_Call({
                expression: new UglifyJS.AST_SymbolRef({ name: CONFIG.symbol.define }),
                args: [ nodeString, nodeArray, nodeFunction ]
            });

            return nodeDefine;
        }

        // 捕捉所有的 require() 调用。
        else if (node instanceof UglifyJS.AST_Call && node.expression.name == 'require') {
            // @debug 本段仅供调试
            if (node.start.value != 'require') {
                console.log(exporter.format(node));
                inform.exit('DEV ERROR No. 1');
            }

            // 获取 require 参数字符串值。
github jlooper / MIKE / sample-app / public / kendo / bower_components / kendo-ui / src / build / kendo-meta.js View on Github external
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 }));
github dequelabs / axe-core / build / tasks / generate-imports.js View on Github external
const removeUMD = new UglifyJS.TreeTransformer(node => {
				if (node.body[0].body.args.length <= 0) {
					throw new Error('Not a UMD wrapper as arguments are missing.');
				}

				// the last (or only) argument in umd resolver is the factory to be mounted
				const umdFactory =
					node.body[0].body.args[node.body[0].body.args.length - 1];
				const funcCall = new UglifyJS.AST_Call({
					expression: umdFactory,
					args: umdFactory.argnames // pass arguments into self invoking func
				});
				const statement = new UglifyJS.AST_SimpleStatement({
					body: funcCall,
					start: {
						comments_before: node.start.comments_before // bring over comments
					}
				});
				return new UglifyJS.AST_Toplevel({ body: [statement] });
			});
github mishoo / livenode / livenode.js View on Github external
// exports.__defineGetter__("foo", function(){ return bar }),
            // exports.__defineSetter__("foo", function(v){
            //   exports.__defineGetter__("foo", function(){ return v });
            // })
            //
            // this way we emulate the functionality of exports.bar
            // while allowing it to refer to "global" (module)
            // variables that might be changed later, i.e. bar would
            // turn to $__CONTEXT.bar.

            var prop = node.left.property instanceof u2.AST_Node
                ? node.left.property
                : new u2.AST_String({ value: node.left.property });

            var exp = new u2.AST_Seq({
                car: new u2.AST_Call({
                    expression: new u2.AST_Dot({
                        expression: node.left.expression,
                        property: "__defineGetter__"
                    }),
                    args: [
                        prop,
                        new u2.AST_Lambda({
                            argnames: [],
                            body: [
                                new u2.AST_Return({ value: node.right })
                            ]
                        })
                    ]
                }),
                cdr: new u2.AST_Call({
                    expression: new u2.AST_Dot({
github fishbar / jscoverage / lib / instrument.js View on Github external
new Uglify.AST_Number({value: line})
      ];
    } else if (type === this.T_COND) {
      var start = expr.start.col;
      var offset = expr.end.endpos - expr.start.pos;
      var key = line + '_' + start + '_' + offset;  // 编码
      this.conds[key] = 0;
      args = [
        new Uglify.AST_String({value: this.filename}),
        new Uglify.AST_String({value: type}),
        new Uglify.AST_String({value: key}),
        expr
      ];
    }

    var call = new Uglify.AST_Call({
      expression: new Uglify.AST_SymbolRef({name: '_$jscmd'}),
      //end: new Uglify.AST_
      args: args
    });

    if (type === this.T_LINE) {
      return new Uglify.AST_SimpleStatement({
        body: call,
        end: new Uglify.AST_Token({value: ';'})
      });
    } else {
      return call;
    }
  },
  /**
github ctripcorp / moles-packer / lib / transform.js View on Github external
&& node.body
            && node.body.expression
            && node.body.expression.property == 'registerComponent'
            && node.body.expression.expression
            && node.body.expression.expression.property == 'AppRegistry'
        ) {
            _project.componentName = node.body.args[0].value;

            let nodeReturn = node.body.args[1].body.pop();

            // info.registerComponentVarname = nodeReturn.value.name;
            /^return (.+);$/.exec(exporter.format(nodeReturn, true));
            info.registerComponentVarname = RegExp.$1;

            // 创建“函数调用”节点,用于“注册(替换)”组件。
            let nodeRegisterComponent = new UglifyJS.AST_Call({
                expression: new UglifyJS.AST_SymbolRef({ name: CONFIG.symbol.changeComponent }),
                args: [ new UglifyJS.AST_SymbolRef({ name: info.registerComponentVarname }) ]
            });

            // return nodeRegisterComponent;

            // // 返回空声明,即等同于删除该节点。
            return new UglifyJS.AST_EmptyStatement();
        }

        else {
            descend(node, this);
            return node;
        }
    });
github mishoo / livenode / livenode.js View on Github external
]
                        })
                    ]
                }),
                cdr: new u2.AST_Call({
                    expression: new u2.AST_Dot({
                        expression: node.left.expression,
                        property: "__defineSetter__"
                    }),
                    args: [
                        prop,
                        new u2.AST_Lambda({
                            argnames: [ new u2.AST_SymbolFunarg({ name: "v" }) ],
                            body: [
                                new u2.AST_SimpleStatement({
                                    body: new u2.AST_Call({
                                        expression: new u2.AST_Dot({
                                            expression: node.left.expression,
                                            property: "__defineGetter__"
                                        }),
                                        args: [
                                            prop,
                                            new u2.AST_Lambda({
                                                argnames: [],
                                                body: [
                                                    new u2.AST_Return({
                                                        value: new u2.AST_SymbolRef({ name: "v" })
                                                    })
                                                ]
                                            })
                                        ]
                                    })
github kaelzhang / neuron.js / upgrade / lib / transformer / dom.js View on Github external
}


                    
                    _expression = new UglifyJS.AST_Call({

                                      expression : new UglifyJS.AST_Dot({
                                          expression : _expression,
                                          property : map_2[_property] || _property
                                       }),
                                      args : node.args 
                                  })
                    

                    if(map_3[_property]){
                        _expression = new UglifyJS.AST_Call({

                            expression: new UglifyJS.AST_Dot({
                                            expression : _expression,
                                            property : "eq"
                                         }),

                            args : [
                                    new UglifyJS.AST_Number({
                                          value : 0                                
                                    })
                            ]                                                                                                      
                          });
                    }                    

                    
                    descend(_expression,this);
github dbankier / TiShadow / cli / support / uglify.js View on Github external
function functionCall(name, args) {
  return new UglifyJS.AST_Call({
    expression: new UglifyJS.AST_SymbolRef({ name: name }),
    args: args
  });
}
github mishoo / livenode / livenode.js View on Github external
car: new u2.AST_Call({
                    expression: new u2.AST_Dot({
                        expression: node.left.expression,
                        property: "__defineGetter__"
                    }),
                    args: [
                        prop,
                        new u2.AST_Lambda({
                            argnames: [],
                            body: [
                                new u2.AST_Return({ value: node.right })
                            ]
                        })
                    ]
                }),
                cdr: new u2.AST_Call({
                    expression: new u2.AST_Dot({
                        expression: node.left.expression,
                        property: "__defineSetter__"
                    }),
                    args: [
                        prop,
                        new u2.AST_Lambda({
                            argnames: [ new u2.AST_SymbolFunarg({ name: "v" }) ],
                            body: [
                                new u2.AST_SimpleStatement({
                                    body: new u2.AST_Call({
                                        expression: new u2.AST_Dot({
                                            expression: node.left.expression,
                                            property: "__defineGetter__"
                                        }),
                                        args: [