How to use the uglify-js.parser 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 jadonk / bonescript / node_modules / bonescript / node_modules / socket.io / node_modules / socket.io-client / bin / builder.js View on Github external
ignore++;
            ret = ignore;
          }

          // stop ignoring the next line
          if (end) {
            ignore--;
          }

          return ret == 0;
        }).join('\n');
      }

      // check if we need to process it any further
      if (settings.minify) {
        var ast = uglify.parser.parse(code);
        ast = uglify.uglify.ast_mangle(ast);
        ast = uglify.uglify.ast_squeeze(ast);

        code = production + uglify.uglify.gen_code(ast, { ascii_only: true });
      }

      callback(error, code);
    })
  })
github spmjs / spm / lib / actions / build / core / dependency.js View on Github external
// 依赖分析
// 在这个模块里面,会对所有的模块进行依赖分析,命名替换等操作。

var util = require('util');
var path = require('path');
var async = require('async');

var Sources = require('./sources');
var astParser = require('uglify-js').parser;
var Ast = require('../../../utils/ast.js');

var splice = Array.prototype.splice;

var fsExt = require('../../../utils/fs_ext.js');

function Dependency(project) {
  this.project = project;
  this.srcDir = project.srcDirectory;
  this.sources = new Sources(true, project);
}

/**
 * 获取项目所有模块直接的依赖关系
 * { '#widget/0.9.13/templatable':
 *  [ '#jquery/1.7.2/jquery',
github zazl / optimizer / org.dojotoolkit.optimizer.nodejs / zazloptimizer / lib / zazloptimizer.js View on Github external
/*
    Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
    Available via Academic Free License >= 2.1 OR the modified BSD license.
    see: http://dojotoolkit.org/license for details
*/
print = console.log;

var url = require('url');
var path = require('path');
var qs = require('querystring');
var resourceloader = require('zazlutil').resourceloader;
var utils = require('zazlutil').utils;
var zlib = require('zlib');
var analyzer = require('./analyzer');
var jsp = require("uglify-js").parser;
var pro = require("uglify-js").uglify;

var compressedCache = {};

var ResponseWriter = function(request, response){
	this.request = request;
	this.response = response;
	this.usegzip = false;
	var encoding = request.headers["accept-encoding"];
	if (encoding && encoding.match(/\bgzip\b/)) {
		this.usegzip = true;
		this.buffer = "";
		this.response.writeHead(200, { 'content-encoding': 'gzip' });
	}
};
github dasilva333 / TowerGhostForDestiny / www / bower_modules / crossroads / build.js View on Github external
function uglify(srcPath) {
    var
      uglyfyJS = require('uglify-js'),
      jsp = uglyfyJS.parser,
      pro = uglyfyJS.uglify,
      ast = jsp.parse( _fs.readFileSync(srcPath, FILE_ENCODING) );

    ast = pro.ast_mangle(ast);
    ast = pro.ast_squeeze(ast);

    return pro.gen_code(ast);
}
github BrainJS / brain.js / Jakefile.js View on Github external
function minify(code) {
  var uglifyjs = require("uglify-js"),
      parser = uglifyjs.parser,
      uglify = uglifyjs.uglify;

  var ast = parser.parse(code);
  ast = uglify.ast_mangle(ast);
  ast = uglify.ast_squeeze(ast);
  return uglify.gen_code(ast);
}
github kaelzhang / neuron.js / upgrade / util / walker.js View on Github external
'use strict';

/**
 * enhanced ast walker based on uglifyjs
 */

var

NR = require('../../lib/neuron'),

lang = require('./lang'),

uglify = require('uglify-js'),
parser = uglify.parser,
pro = uglify.uglify,
fs = require('fs'),

ast_walker = pro.ast_walker(),

Walker = exports,

REGEX_MATCH_DOT = /\.(?!$)/;


function adaptWalkers(walkers, current_item, current_sub_ast){
    var stat;
    
    for(stat in walkers){
        if(current_item === stat){
            walkers[stat](current_sub_ast);
github david-mark-llc / jessie / bin / build.js View on Github external
#!/usr/bin/env node

var program = require('commander'),
	Table = require('cli-table'),
	Set = require('simplesets').Set,
	fs = require('fs'),
	path = require('path'),
	jsp = require("uglify-js").parser,
	pro = require("uglify-js").uglify;

program
	.version('0.0.1')
	.usage('[options] ')
	.option('-l, --list', 'Print a list of available functions')
	.option('-o, --output [file]', 'The file to output to (outputs to stdout by default)')
	.option('-a, --all', 'Include all Functions and Renditions')
	.option('--all-renditions', 'Include all renditions of a function if not specified explicitly')
	.option('-u, --uglify', 'Minify the output using UglifyJS')
	.option('--mangle', 'Mangle the generated output via UglifyJS')
	.option('--beautify', 'Output beautified JS')
	.option('--root [path]', 'the folder that jessie functions are located in', path.join(__dirname, '../functions/'))
	.option('--no-wrap', 'Don\'nt wrap the built file with the header/footer file contents')
	.option('--header [path]', 'The header file', path.join(__dirname, '../libraries/header1.inc'))
	.option('--footer [path]', 'The footer file', path.join(__dirname, '../libraries/footer1.inc'))
github danwrong / loadbuilder / lib / loadbuilder / analyzer.js View on Github external
var parser = require('uglify-js').parser;

function match(fragment, tree) {
  var matches = [];

  if ((fragment.length <= tree.length) && fragment.every(function(item, i) {
    var subMatches;

    if (item === null) {
      matches.push(tree[i]);
      return true;
    }

    if (item === tree[i]) {
      return true;
    }
github alex-seville / blanket / lib / builder.js View on Github external
}else{

    var result = compiled({
        requirejs: requirejs,
        parser: parser,
        transformer: transformer,
        blanket: blanket,
        reporter: reporter,
        blanketRequire: blanketRequire,
        noAutoRun: noAutoRun,
        testhooks: testhooks,
        version:version
    });


    var jsp = uglifyjs.parser;
    var pro = uglifyjs.uglify;

    ast = jsp.parse(result);
    ast = pro.ast_mangle(ast,  {});
    ast = pro.ast_squeeze(ast,  {});
    var minResult = pro.gen_code(ast,  {});


    //need to check for existence of dist folders and create them
    fs.writeFileSync(__dirname+"/../dist/"+testrunner+"/blanket.js",result,'utf8');
    fs.writeFileSync(__dirname+"/../dist/"+testrunner+"/blanket.min.js",minResult,'utf8');
}