Socket
Socket
Sign inDemoInstall

uglify-js

Package Overview
Dependencies
Maintainers
3
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uglify-js - npm Package Compare versions

Comparing version 2.3.6 to 2.4.0

test/compress/negate-iife.js

3

lib/ast.js

@@ -948,2 +948,5 @@ /***********************************************************************

},
has_directive: function(type) {
return this.find_parent(AST_Scope).has_directive(type);
},
in_boolean_context: function() {

@@ -950,0 +953,0 @@ var stack = this.stack;

36

lib/output.js

@@ -57,3 +57,2 @@ /***********************************************************************

max_line_len : 32000,
ie_proof : true,
beautify : false,

@@ -65,3 +64,3 @@ source_map : null,

preserve_line : false,
negate_iife : !(options && options.beautify),
screw_ie8 : false,
}, true);

@@ -101,3 +100,3 @@

case "'": ++sq; return "'";
case "\0": return "\\0";
case "\0": return "\\x00";
}

@@ -357,17 +356,13 @@ return s;

var self = this, generator = self._codegen;
stream.push_node(self);
var needs_parens = self.needs_parens(stream);
var fc = self instanceof AST_Function && stream.option("negate_iife");
if (force_parens || (needs_parens && !fc)) {
stream.with_parens(function(){
self.add_comments(stream);
self.add_source_map(stream);
generator(self, stream);
});
} else {
function doit() {
self.add_comments(stream);
if (needs_parens && fc) stream.print("!");
self.add_source_map(stream);
generator(self, stream);
}
stream.push_node(self);
if (force_parens || self.needs_parens(stream)) {
stream.with_parens(doit);
} else {
doit();
}
stream.pop_node();

@@ -768,3 +763,3 @@ });

if (self.body instanceof AST_Do
&& output.option("ie_proof")) {
&& !output.option("screw_ie8")) {
// https://github.com/mishoo/UglifyJS/issues/#issue/57 IE

@@ -1024,2 +1019,7 @@ // croaks with "syntax error" on code like this: if (foo)

exp.print(output);
// If the final element is a hole, we need to make sure it
// doesn't look like a trailing comma, by inserting an actual
// trailing comma.
if (i === len - 1 && exp instanceof AST_Hole)
output.comma();
});

@@ -1052,6 +1052,6 @@ if (len > 0) output.space();

output.print(make_num(key));
} else if (!is_identifier(key)) {
} else if (RESERVED_WORDS(key) ? output.option("screw_ie8") : is_identifier_string(key)) {
output.print_name(key);
} else {
output.print_string(key);
} else {
output.print_name(key);
}

@@ -1058,0 +1058,0 @@ output.colon();

@@ -258,3 +258,3 @@ /***********************************************************************

function token(type, value, is_comment) {
S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX[value]) ||
S.regex_allowed = ((type == "operator" && !UNARY_POSTFIX(value)) ||
(type == "keyword" && KEYWORDS_BEFORE_EXPRESSION(value)) ||

@@ -261,0 +261,0 @@ (type == "punc" && PUNC_BEFORE_EXPRESSION(value)));

@@ -162,2 +162,3 @@ /***********************************************************************

_(AST_VarDef, function(self, tw){
self.name = self.name.transform(tw);
if (self.value) self.value = self.value.transform(tw);

@@ -164,0 +165,0 @@ });

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

"main": "tools/node.js",
"version": "2.3.6",
"version": "2.4.0",
"engines": { "node" : ">=0.4.0" },

@@ -21,4 +21,8 @@ "maintainers": [{

"source-map" : "~0.1.7",
"optimist" : "~0.3.5"
"optimist" : "~0.3.5",
"uglify-to-browserify": "~1.0.0"
},
"browserify": {
"transform": [ "uglify-to-browserify" ]
},
"bin": {

@@ -25,0 +29,0 @@ "uglifyjs" : "bin/uglifyjs"

@@ -49,51 +49,60 @@ UglifyJS 2

--source-map Specify an output file where to generate source map.
[string]
--source-map-root The path to the original source to be included in the
source map. [string]
--source-map-url The path to the source map to be added in //@
sourceMappingURL. Defaults to the value passed with
--source-map. [string]
--in-source-map Input source map, useful if you're compressing JS that was
generated from some other original code.
--screw-ie8 Pass this flag if you don't care about full compliance with
Internet Explorer 6-8 quirks (by default UglifyJS will try
to be IE-proof).
-p, --prefix Skip prefix for original filenames that appear in source
maps. For example -p 3 will drop 3 directories from file
names and ensure they are relative paths.
-o, --output Output file (default STDOUT).
-b, --beautify Beautify output/specify output options. [string]
-m, --mangle Mangle names/pass mangler options. [string]
-r, --reserved Reserved names to exclude from mangling.
-c, --compress Enable compressor/pass compressor options. Pass options
like -c hoist_vars=false,if_return=false. Use -c with no
argument to use the default compression options. [string]
-d, --define Global definitions [string]
--comments Preserve copyright comments in the output. By default this
works like Google Closure, keeping JSDoc-style comments
that contain "@license" or "@preserve". You can optionally
pass one of the following arguments to this flag:
- "all" to keep all comments
- a valid JS regexp (needs to start with a slash) to keep
only comments that match.
Note that currently not *all* comments can be kept when
compression is on, because of dead code removal or
cascading statements into sequences. [string]
--stats Display operations run time on STDERR. [boolean]
--acorn Use Acorn for parsing. [boolean]
--spidermonkey Assume input files are SpiderMonkey AST format (as JSON).
[boolean]
--self Build itself (UglifyJS2) as a library (implies
--wrap=UglifyJS --export-all) [boolean]
--wrap Embed everything in a big function, making the “exports”
and “global” variables available. You need to pass an
argument to this option to specify the name that your
module will take when included in, say, a browser.
[string]
--export-all Only used when --wrap, this tells UglifyJS to add code to
automatically export all globals. [boolean]
--lint Display some scope warnings [boolean]
-v, --verbose Verbose [boolean]
-V, --version Print version number and exit. [boolean]
```
--source-map Specify an output file where to generate source map.
[string]
--source-map-root The path to the original source to be included in the
source map. [string]
--source-map-url The path to the source map to be added in //#
sourceMappingURL. Defaults to the value passed with
--source-map. [string]
--in-source-map Input source map, useful if you're compressing JS that was
generated from some other original code.
--screw-ie8 Pass this flag if you don't care about full compliance
with Internet Explorer 6-8 quirks (by default UglifyJS
will try to be IE-proof). [boolean]
--expr Parse a single expression, rather than a program (for
parsing JSON) [boolean]
-p, --prefix Skip prefix for original filenames that appear in source
maps. For example -p 3 will drop 3 directories from file
names and ensure they are relative paths. You can also
specify -p relative, which will make UglifyJS figure out
itself the relative paths between original sources, the
source map and the output file. [string]
-o, --output Output file (default STDOUT).
-b, --beautify Beautify output/specify output options. [string]
-m, --mangle Mangle names/pass mangler options. [string]
-r, --reserved Reserved names to exclude from mangling.
-c, --compress Enable compressor/pass compressor options. Pass options
like -c hoist_vars=false,if_return=false. Use -c with no
argument to use the default compression options. [string]
-d, --define Global definitions [string]
-e, --enclose Embed everything in a big function, with a configurable
parameter/argument list. [string]
--comments Preserve copyright comments in the output. By default this
works like Google Closure, keeping JSDoc-style comments
that contain "@license" or "@preserve". You can optionally
pass one of the following arguments to this flag:
- "all" to keep all comments
- a valid JS regexp (needs to start with a slash) to keep
only comments that match.
Note that currently not *all* comments can be kept when
compression is on, because of dead code removal or
cascading statements into sequences. [string]
--stats Display operations run time on STDERR. [boolean]
--acorn Use Acorn for parsing. [boolean]
--spidermonkey Assume input files are SpiderMonkey AST format (as JSON).
[boolean]
--self Build itself (UglifyJS2) as a library (implies
--wrap=UglifyJS --export-all) [boolean]
--wrap Embed everything in a big function, making the “exports”
and “global” variables available. You need to pass an
argument to this option to specify the name that your
module will take when included in, say, a browser.
[string]
--export-all Only used when --wrap, this tells UglifyJS to add code to
automatically export all globals. [boolean]
--lint Display some scope warnings [boolean]
-v, --verbose Verbose [boolean]
-V, --version Print version number and exit. [boolean]
```

@@ -204,2 +213,5 @@ Specify `--output` (`-o`) to declare the output file. Otherwise the output

declarations etc.
- `negate_iife` -- negate "Immediately-Called Function Expressions"
where the return value is discarded, to avoid the parens that the
code generator would insert.

@@ -282,5 +294,2 @@ ### The `unsafe` option

- `max-line-len` (default 32000) -- maximum line length (for uglified code)
- `ie-proof` (default `true`) -- generate “IE-proof” code (for now this
means add brackets around the do/while in code like this: `if (foo) do
something(); while (bar); else ...`.
- `bracketize` (default `false`) -- always insert brackets in `if`, `for`,

@@ -293,6 +302,2 @@ `do`, `while` or `with` statements, even if their body is a single

gzip could be smaller; size after gzip insignificantly larger).
- `negate-iife` (default `!beautify`) -- prefer negation, rather than
parens, for "Immediately-Called Function Expressions". This defaults to
`true` when beautification is off, and `false` if beautification is on;
pass it manually to force a value.

@@ -299,0 +304,0 @@ ### Keeping copyright notices or other comments

holes_and_undefined: {
input: {
w = [1,,];
x = [1, 2, undefined];

@@ -8,2 +9,3 @@ y = [1, , 2, ];

expect: {
w=[1,,];
x=[1,2,void 0];

@@ -10,0 +12,0 @@ y=[1,,2];

@@ -98,1 +98,25 @@ unused_funarg_1: {

}
unused_keep_setter_arg: {
options = { unused: true };
input: {
var x = {
_foo: null,
set foo(val) {
},
get foo() {
return this._foo;
}
}
}
expect: {
var x = {
_foo: null,
set foo(val) {
},
get foo() {
return this._foo;
}
}
}
}

@@ -66,2 +66,4 @@ var path = require("path");

UglifyJS.base54.reset();
// 1. parse

@@ -68,0 +70,0 @@ var toplevel = null;

Sorry, the diff of this file is not supported yet

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc