Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

terser

Package Overview
Dependencies
Maintainers
1
Versions
182
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terser - npm Package Compare versions

Comparing version 5.16.3 to 5.16.4

9

CHANGELOG.md
# Changelog
## v5.16.4
- Keep `(defaultArg = undefined) => ...`, because default args don't count for function length
- Prevent inlining variables into `?.` optional chains
- Avoid removing unused arguments while transforming
- Optimize iterating AST node lists
- Make sure `catch` and `finally` aren't children of `try` in the AST
- Use modern unicode property escapes (`\p{...}`) to parse identifiers when available
## v5.16.3

@@ -4,0 +13,0 @@

4

lib/compress/inference.js

@@ -303,3 +303,3 @@ /***********************************************************************

def_has_side_effects(AST_Try, function(compressor) {
return any(this.body, compressor)
return this.body.has_side_effects(compressor)
|| this.bcatch && this.bcatch.has_side_effects(compressor)

@@ -533,3 +533,3 @@ || this.bfinally && this.bfinally.has_side_effects(compressor);

def_may_throw(AST_Try, function(compressor) {
return this.bcatch ? this.bcatch.may_throw(compressor) : any(this.body, compressor)
return this.bcatch ? this.bcatch.may_throw(compressor) : this.body.may_throw(compressor)
|| this.bfinally && this.bfinally.may_throw(compressor);

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

@@ -627,3 +627,3 @@ /***********************************************************************

push(tw);
walk_body(this, tw);
this.body.walk(tw);
pop(tw);

@@ -630,0 +630,0 @@ if (this.bcatch) {

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

AST_Case,
AST_Catch,
AST_Chain,

@@ -75,3 +74,2 @@ AST_Class,

AST_Export,
AST_Finally,
AST_For,

@@ -108,2 +106,3 @@ AST_ForIn,

AST_Try,
AST_TryBlock,
AST_Unary,

@@ -240,9 +239,7 @@ AST_UnaryPostfix,

do {
if (node instanceof AST_Catch || node instanceof AST_Finally) {
level++;
} else if (node instanceof AST_IterationStatement) {
if (node instanceof AST_IterationStatement) {
in_loop = true;
} else if (node instanceof AST_Scope) {
break;
} else if (node instanceof AST_Try) {
} else if (node instanceof AST_TryBlock) {
in_try = true;

@@ -291,2 +288,5 @@ }

|| node instanceof AST_Call && lhs instanceof AST_PropAccess && lhs.equivalent_to(node.expression)
||
(node instanceof AST_Call || node instanceof AST_PropAccess)
&& node.optional
|| node instanceof AST_Debugger

@@ -465,3 +465,7 @@ || node instanceof AST_Destructuring

if (!can_replace) {
for (var j = compressor.self().argnames.lastIndexOf(candidate.name) + 1; !abort && j < args.length; j++) {
for (
let j = compressor.self().argnames.lastIndexOf(candidate.name) + 1;
!abort && j < args.length;
j++
) {
args[j].transform(scanner);

@@ -468,0 +472,0 @@ }

@@ -175,3 +175,3 @@ import {

AST_Try.prototype.shallow_cmp = function(other) {
return (this.bcatch == null ? other.bcatch == null : this.bcatch === other.bcatch) && (this.bfinally == null ? other.bfinally == null : this.bfinally === other.bfinally);
return (this.body === other.body) && (this.bcatch == null ? other.bcatch == null : this.bcatch === other.bcatch) && (this.bfinally == null ? other.bfinally == null : this.bfinally === other.bfinally);
};

@@ -178,0 +178,0 @@

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

AST_Try,
AST_TryBlock,
AST_Unary,

@@ -348,3 +349,3 @@ AST_UnaryPostfix,

end : my_end_token(M),
body : from_moz(M.block).body,
body : new AST_TryBlock(from_moz(M.block)),
bcatch : from_moz(handlers[0]),

@@ -1320,3 +1321,3 @@ bfinally : M.finalizer ? new AST_Finally(from_moz(M.finalizer)) : null

type: "TryStatement",
block: to_moz_block(M),
block: to_moz_block(M.body),
handler: to_moz(M.bcatch),

@@ -1323,0 +1324,0 @@ guardedHandlers: [],

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

AST_Call,
AST_Catch,
AST_Class,

@@ -227,8 +226,3 @@ AST_Conditional,

scope._block_scope = true;
// AST_Try in the AST sadly *is* (not has) a body itself,
// and its catch and finally branches are children of the AST_Try itself
const parent_scope = node instanceof AST_Catch
? save_scope.parent_scope
: save_scope;
scope.init_scope_vars(parent_scope);
scope.init_scope_vars(save_scope);
scope.uses_with = save_scope.uses_with;

@@ -248,3 +242,3 @@ scope.uses_eval = save_scope.uses_eval;

// while the body inside belongs to the switch itself.
// This is pretty nasty and warrants an AST change similar to AST_Try (read above)
// This is pretty nasty and warrants an AST change
const the_block_scope = scope;

@@ -251,0 +245,0 @@ scope = save_scope;

@@ -219,5 +219,3 @@ import {

AST_Try.prototype._size = function () {
return 3 + list_overhead(this.body);
};
AST_Try.prototype._size = () => 3;

@@ -224,0 +222,0 @@ AST_Catch.prototype._size = function () {

@@ -92,3 +92,3 @@ /***********************************************************************

import {
MAP,
MAP as do_list,
noop,

@@ -115,8 +115,2 @@ } from "./utils/index.js";

function do_list(list, tw) {
return MAP(list, function(node) {
return node.transform(tw, true);
});
}
def_transform(AST_Node, noop);

@@ -190,3 +184,3 @@

def_transform(AST_Try, function(self, tw) {
self.body = do_list(self.body, tw);
self.body = self.body.transform(tw);
if (self.bcatch) self.bcatch = self.bcatch.transform(tw);

@@ -216,3 +210,3 @@ if (self.bfinally) self.bfinally = self.bfinally.transform(tw);

if (self.name) self.name = self.name.transform(tw);
self.argnames = do_list(self.argnames, tw);
self.argnames = do_list(self.argnames, tw, /* allow_splicing */ false);
if (self.body instanceof AST_Node) {

@@ -227,3 +221,3 @@ self.body = self.body.transform(tw);

self.expression = self.expression.transform(tw);
self.args = do_list(self.args, tw);
self.args = do_list(self.args, tw, /* allow_splicing */ false);
});

@@ -230,0 +224,0 @@

@@ -46,2 +46,4 @@ /***********************************************************************

import { AST_Node } from "../ast.js";
function characters(str) {

@@ -100,44 +102,38 @@ return str.split("");

var MAP = (function() {
function MAP(a, f, backwards) {
var ret = [], top = [], i;
function doit() {
var val = f(a[i], i);
var is_last = val instanceof Last;
if (is_last) val = val.v;
if (val instanceof AtTop) {
val = val.v;
if (val instanceof Splice) {
top.push.apply(top, backwards ? val.v.slice().reverse() : val.v);
} else {
top.push(val);
function MAP(a, tw, allow_splicing = true) {
// Loop but try not to build a new array
for (let i = 0; i < a.length; ++i) {
let item = a[i];
let ret = item.transform(tw, allow_splicing);
if (ret !== item) {
const a1 = a.slice(0, i);
// Looks like something was transformed. Change the loop.
if (ret instanceof AST_Node) {
a1.push(ret);
} else if (ret instanceof Splice) {
a1.push(...ret.v);
}
} else if (val !== skip) {
if (val instanceof Splice) {
ret.push.apply(ret, backwards ? val.v.slice().reverse() : val.v);
} else {
ret.push(val);
while ((item = a[++i])) {
const ret = item.transform(tw, true);
if (ret instanceof AST_Node) {
a1.push(ret);
} else if (ret instanceof Splice) {
a1.push(...ret.v);
}
}
return a1;
}
return is_last;
}
if (Array.isArray(a)) {
if (backwards) {
for (i = a.length; --i >= 0;) if (doit()) break;
ret.reverse();
top.reverse();
} else {
for (i = 0; i < a.length; ++i) if (doit()) break;
}
} else {
for (i in a) if (HOP(a, i)) if (doit()) break;
}
return top.concat(ret);
return a;
}
MAP.at_top = function(val) { return new AtTop(val); };
MAP.splice = function(val) { return new Splice(val); };
MAP.last = function(val) { return new Last(val); };
var skip = MAP.skip = {};
function AtTop(val) { this.v = val; }
MAP.skip = {};
function Splice(val) { this.v = val; }
function Last(val) { this.v = val; }
return MAP;

@@ -144,0 +140,0 @@ })();

@@ -7,3 +7,3 @@ {

"license": "BSD-2-Clause",
"version": "5.16.3",
"version": "5.16.4",
"engines": {

@@ -10,0 +10,0 @@ "node": ">=10"

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc