Socket
Socket
Sign inDemoInstall

uglify-js

Package Overview
Dependencies
0
Maintainers
3
Versions
283
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.14.5 to 3.15.0

5

lib/minify.js

@@ -31,3 +31,3 @@ "use strict";

if (match[1] == "sourceMappingURL") {
match = /^data:application\/json(;.*?)?;base64,(\S+)$/.exec(match[2]);
match = /^data:application\/json(;.*?)?;base64,([^,]+)$/.exec(match[2]);
if (!match) break;

@@ -82,2 +82,3 @@ return to_ascii(match[2]);

ie8: false,
keep_fargs: false,
keep_fnames: false,

@@ -104,2 +105,3 @@ mangle: {},

if (options.ie) set_shorthand("ie", options, [ "compress", "mangle", "output" ]);
if (options.keep_fargs) set_shorthand("keep_fargs", options, [ "compress", "mangle" ]);
if (options.keep_fnames) set_shorthand("keep_fnames", options, [ "compress", "mangle" ]);

@@ -115,2 +117,3 @@ if (options.toplevel) set_shorthand("toplevel", options, [ "compress", "mangle" ]);

ie: false,
keep_fargs: false,
keep_fnames: false,

@@ -117,0 +120,0 @@ properties: false,

6

lib/mozilla-ast.js

@@ -1008,3 +1008,3 @@ /***********************************************************************

def_to_moz(AST_RegExp, function To_Moz_RegExpLiteral(M) {
var flags = M.value.toString().match(/[gimuy]*$/)[0];
var flags = M.value.toString().match(/\/([gimuy]*)$/)[1];
var value = "/" + M.value.raw_source + "/" + flags;

@@ -1017,4 +1017,4 @@ return {

pattern: M.value.raw_source,
flags: flags
}
flags: flags,
},
};

@@ -1021,0 +1021,0 @@ });

@@ -95,11 +95,15 @@ /***********************************************************************

unmangleable: function(options) {
return this.global && !options.toplevel
|| this.exported
|| this.undeclared
|| !options.eval && this.scope.pinned()
|| options.keep_fnames
&& (this.orig[0] instanceof AST_SymbolClass
|| this.orig[0] instanceof AST_SymbolDefClass
|| this.orig[0] instanceof AST_SymbolDefun
|| this.orig[0] instanceof AST_SymbolLambda);
if (this.exported) return true;
if (this.undeclared) return true;
if (!options.eval && this.scope.pinned()) return true;
if (options.keep_fargs && is_funarg(this)) return true;
if (options.keep_fnames) {
var sym = this.orig[0];
if (sym instanceof AST_SymbolClass) return true;
if (sym instanceof AST_SymbolDefClass) return true;
if (sym instanceof AST_SymbolDefun) return true;
if (sym instanceof AST_SymbolLambda) return true;
}
if (!options.toplevel && this.global) return true;
return false;
},

@@ -117,2 +121,6 @@ };

function is_funarg(def) {
return def.orig[0] instanceof AST_SymbolFunarg || def.orig[1] instanceof AST_SymbolFunarg;
}
var unary_side_effects = makePredicate("delete ++ --");

@@ -219,6 +227,4 @@

if (exported) def.exported = true;
entangle(defun, scope);
} else if (node instanceof AST_SymbolFunarg) {
defun.def_variable(node);
entangle(defun, scope);
} else if (node instanceof AST_SymbolLambda) {

@@ -233,3 +239,2 @@ var def = defun.def_function(node, node.name == "arguments" ? undefined : defun);

if (exported) def.exported = true;
entangle(defun, scope);
}

@@ -247,12 +252,2 @@

}
function entangle(defun, scope) {
if (defun === scope) return;
node.mark_enclosed(options);
var def = scope.find_variable(node.name);
if (node.thedef === def) return;
node.thedef = def;
def.orig.push(node);
node.mark_enclosed(options);
}
});

@@ -278,2 +273,3 @@ self.make_def = function(orig, init) {

in_arg.push(node);
if (node.name) node.name.walk(tw);
node.argnames.forEach(function(argname) {

@@ -305,2 +301,12 @@ argname.walk(tw);

if (redef) redef.const_redefs = true;
} else if (def.scope !== node.scope && (node instanceof AST_SymbolDefun
|| node instanceof AST_SymbolFunarg
|| node instanceof AST_SymbolVar)) {
node.mark_enclosed(options);
var redef = node.scope.find_variable(node.name);
if (node.thedef !== redef) {
node.thedef = redef;
redef.orig.push(node);
node.mark_enclosed(options);
}
}

@@ -485,4 +491,7 @@ if (node.name != "arguments") return true;

s._var_names = undefined;
} else if (options.keep_fnames) {
s.functions.each(function(d) {
} else {
if (options.keep_fargs && s instanceof AST_Lambda) s.each_argname(function(arg) {
push_uniq(def.scope.enclosed, arg.definition());
});
if (options.keep_fnames) s.functions.each(function(d) {
push_uniq(def.scope.enclosed, d);

@@ -592,2 +601,3 @@ });

ie : false,
keep_fargs : false,
keep_fnames : false,

@@ -600,3 +610,3 @@ reserved : [],

if (!Array.isArray(options.reserved)) options.reserved = [];
// Never mangle arguments
// Never mangle `arguments`
push_uniq(options.reserved, "arguments");

@@ -607,11 +617,8 @@ options.reserved.has = makePredicate(options.reserved);

// We only need to mangle declaration nodes. Special logic wired into the code
// generator will display the mangled name if it is present (and for
// `AST_SymbolRef`s it will use the mangled name of the `AST_SymbolDeclaration`
// that it points to).
AST_Toplevel.DEFMETHOD("mangle_names", function(options) {
options = _default_mangler_options(options);
// We only need to mangle declaration nodes. Special logic wired
// into the code generator will display the mangled name if it's
// present (and for AST_SymbolRef-s it'll use the mangled name of
// the AST_SymbolDeclaration that it points to).
var lname = -1;
if (options.cache && options.cache.props) {

@@ -623,7 +630,8 @@ var mangled_names = names_in_use(this, options);

}
var cutoff = 10;
var lname = -1;
var redefined = [];
var tw = new TreeWalker(function(node, descend) {
if (node instanceof AST_LabeledStatement) {
// lname is incremented when we get to the AST_Label
// `lname` is incremented when we get to the `AST_Label`
var save_nesting = lname;

@@ -650,5 +658,5 @@ descend();

}
node.to_mangle = [];
var to_mangle = node.to_mangle = [];
node.variables.each(function(def) {
if (!defer_redef(def)) node.to_mangle.push(def);
if (!defer_redef(def)) to_mangle.push(def);
});

@@ -664,3 +672,19 @@ descend();

}
node.to_mangle.forEach(mangle);
if (to_mangle.length > cutoff) {
var indices = to_mangle.map(function(def, index) {
return index;
}).sort(function(i, j) {
return to_mangle[j].references.length - to_mangle[i].references.length || i - j;
});
to_mangle = indices.slice(0, cutoff).sort(function(i, j) {
return i - j;
}).map(function(index) {
return to_mangle[index];
}).concat(indices.slice(cutoff).sort(function(i, j) {
return i - j;
}).map(function(index) {
return to_mangle[index];
}));
}
to_mangle.forEach(mangle);
return true;

@@ -667,0 +691,0 @@ }

@@ -6,3 +6,3 @@ {

"license": "BSD-2-Clause",
"version": "3.14.5",
"version": "3.15.0",
"engines": {

@@ -9,0 +9,0 @@ "node": ">=0.8.0"

@@ -118,2 +118,3 @@ UglifyJS 3

By default UglifyJS will not try to be IE-proof.
--keep-fargs Do not mangle/drop function arguments.
--keep-fnames Do not mangle/drop function names. Useful for

@@ -508,2 +509,5 @@ code relying on Function.prototype.name.

- `keep_fargs` (default: `false`) — pass `true` to prevent discarding or mangling
of function arguments.
- `keep_fnames` (default: `false`) — pass `true` to prevent discarding or mangling

@@ -712,3 +716,4 @@ of function names. Useful for code relying on `Function.prototype.name`.

- `3` — inline functions with arguments and variables
- `true` — same as `3`
- `4` — inline functions with arguments, variables and statements
- `true` — same as `4`

@@ -873,2 +878,5 @@ - `join_vars` (default: `true`) — join consecutive `var` statements

- `keep_fargs` (default: `false`) — Use `true` to prevent mangling of function
arguments.
- `keep_quoted` (default: `false`) — Only mangle unquoted property names.

@@ -875,0 +883,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc