Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function runUglify(mergedFile) {
var ast;
try {
ast = jsp.parse(mergedFile); // parse code and get the initial AST
} catch (e) {
console.log('UglifyJS parse failed', e);
}
ast = pro.ast_mangle(ast); // get a new AST with mangled names
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
return pro.gen_code(ast); // compressed code here
}
Builder.prototype.minify = function(output) {
var ast = uglifyParser.parse(output);
switch(this.options.minificationLevel) {
case "1":
output = pro.gen_code(ast, { beautify: true });
break;
case "2":
output = pro.gen_code(ast);
break;
case "3":
ast = pro.ast_mangle(ast);
output = pro.gen_code(ast);
break;
default:
// nothing
}
return output;
};
function analyzeRequireCode (requireAst, descriptor, errs, sourceIndex) {
//OPTIMIZATION: use footprints to determine if we need deeper analysis
var originalSrc = descriptor.jsCode;
if (Common.MIXIN_FOOTPRINT_REGEXP.test(descriptor.jsCode)) {
var rebuildCode = extractMixins(requireAst, descriptor, errs, sourceIndex);
//NOTE: we need to rebuild js code if mixins were removed from AST
if (rebuildCode) {
requireAst = Ast.getRemainderAst(requireAst);
descriptor.jsCode = requireAst ? astProcessor.gen_code(requireAst, { beautify: true }) : '';
}
}
if (Common.ACTION_OR_ASSERTION_FOOTPRINT_REGEXP.test(descriptor.jsCode)) {
//NOTE: validate what require file doesn't contain action functions calls and update source index
if (CallAnalyzer.run(requireAst, descriptor.filename, errs, true, sourceIndex, originalSrc)) {
//NOTE: if call analyzer found assertions and added them to index, we need to rebuild again
descriptor.jsCode = requireAst ? astProcessor.gen_code(requireAst, { beautify: true }) : '';
}
}
}
Compiler.prototype._addOutputTestStepData = function (testName, testStepData) {
var js = astProcessor.gen_code(['array', testStepData.asts], {beautify: true});
this.out.testsStepData[testName] = {
names: testStepData.names,
js: Hammerhead.wrapDomAccessors(js, true)
};
};
* FaxTailConstructionOptimizer.optimizeTailConstructions(reducedRoot);
*/
optimizedRoot =
FaxTailConstructionOptimizer.optimizeTailConstructions(jsParser.parse(src));
} catch (e) {
console.error("ERROR: CAUGHT EXCEPTION OPTIMIZING:" + fileName);
optimizedRoot = jsParser.parse(src);
}
if (squeeze) {
optimizedRoot = uglify.ast_squeeze(optimizedRoot);
}
if (mangle) {
optimizedRoot = uglify.ast_mangle(optimizedRoot);
}
var gened = uglify.gen_code(optimizedRoot);
if(gened !== src) {
require('sys').puts("Found optimizations in file:" + fileName);
} else {
require('sys').puts("Did not find optimizations in:" + fileName);
}
return gened;
};
"const" : do_stat,
"return" : do_stat,
"throw" : do_stat,
"try" : do_stat,
"defun" : do_stat,
"if" : do_stat,
"while" : do_stat,
"do" : do_stat,
"for" : do_stat,
"for-in" : do_stat,
"switch" : do_stat,
"with" : do_stat
}, function () {
return w.walk( ast );
} );
return pro.gen_code( new_ast, { beautify : true } );
}
exports.minify = function (input) {
var ast = uglify.ast_squeeze(uglify.ast_mangle(parser.parse(input)));
return uglify.gen_code(ast);
};
function compress(data, compressorOptions) {
var ast = parser.parse(data)
var uglifyOptions = {}
if (typeof compressorOptions !== 'undefined') {
uglifyOptions = compressorOptions
} else if (options.uglify !== 'undefined') {
uglifyOptions = options.uglify
}
ast = uglifyer.ast_mangle(ast, uglifyOptions)
ast = uglifyer.ast_squeeze(ast, uglifyOptions)
return uglifyer.gen_code(ast, uglifyOptions)
}
function minifyjs(js) {
var ast = jsp.parse(js);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
var minJs = pro.gen_code(ast);
return minJs;
}
function minifyjs(js) {
var ast = jsp.parse(js);
ast = pro.ast_mangle(ast);
ast = pro.ast_squeeze(ast);
var minJs = pro.gen_code(ast);
return minJs;
}