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.33.0 to 5.34.0

6

CHANGELOG.md
# Changelog
## v5.34.0
- internal: stop assigning properties to objects they don't belong in
- internal: run compress tests in parallel
- `drop_console`: emit an empty function if the return value of `console.METHOD(...)` may be called.
## v5.33.0

@@ -4,0 +10,0 @@

@@ -110,2 +110,19 @@ /***********************************************************************

export function make_empty_function(self) {
return make_node(AST_Function, self, {
uses_arguments: false,
argnames: [],
body: [],
is_generator: false,
async: false,
variables: new Map(),
uses_with: false,
uses_eval: false,
parent_scope: null,
enclosed: [],
cname: 0,
block_scope: undefined,
});
}
export function make_node_from_constant(val, orig) {

@@ -112,0 +129,0 @@ switch (typeof val) {

41

lib/compress/drop-unused.js

@@ -106,4 +106,4 @@ /***********************************************************************

can_be_evicted_from_block,
requires_sequence_to_maintain_binding,
} from "./common.js";
import { is_used_in_expression } from "./inference.js";

@@ -507,40 +507,1 @@ const r_keep_assign = /keep_assign/;

});
/**
* Check if a node may be used by the expression it's in
* void (0, 1, {node}, 2) -> false
* console.log(0, {node}) -> true
*/
function is_used_in_expression(tw) {
for (let p = -1, node, parent; node = tw.parent(p), parent = tw.parent(p + 1); p++) {
if (parent instanceof AST_Sequence) {
const nth_expression = parent.expressions.indexOf(node);
if (nth_expression !== parent.expressions.length - 1) {
// Detect (0, x.noThis)() constructs
const grandparent = tw.parent(p + 2);
if (
parent.expressions.length > 2
|| parent.expressions.length === 1
|| !requires_sequence_to_maintain_binding(grandparent, parent, parent.expressions[1])
) {
return false;
}
return true;
} else {
continue;
}
}
if (parent instanceof AST_Unary) {
const op = parent.operator;
if (op === "void") {
return false;
}
if (op === "typeof" || op === "+" || op === "-" || op === "!" || op === "~") {
continue;
}
}
return true;
}
return true;
}

@@ -124,3 +124,3 @@ /***********************************************************************

} from "../utils/index.js";
import { make_sequence, best_of_expression, read_property } from "./common.js";
import { make_sequence, best_of_expression, read_property, requires_sequence_to_maintain_binding } from "./common.js";

@@ -986,1 +986,49 @@ import { INLINED, UNDEFINED, has_flag } from "./compressor-flags.js";

}
/**
* Check if a node may be used by the expression it's in
* void (0, 1, {node}, 2) -> false
* console.log(0, {node}) -> true
*/
export function is_used_in_expression(tw) {
for (let p = -1, node, parent; node = tw.parent(p), parent = tw.parent(p + 1); p++) {
if (parent instanceof AST_Sequence) {
const nth_expression = parent.expressions.indexOf(node);
if (nth_expression !== parent.expressions.length - 1) {
// Detect (0, x.noThis)() constructs
const grandparent = tw.parent(p + 2);
if (
parent.expressions.length > 2
|| parent.expressions.length === 1
|| !requires_sequence_to_maintain_binding(grandparent, parent, parent.expressions[1])
) {
return false;
}
return true;
} else {
continue;
}
}
if (parent instanceof AST_Unary) {
const op = parent.operator;
if (op === "void") {
return false;
}
if (op === "typeof" || op === "+" || op === "-" || op === "!" || op === "~") {
continue;
}
}
if (
parent instanceof AST_SimpleStatement
|| parent instanceof AST_LabeledStatement
) {
return false;
}
if (parent instanceof AST_Scope) {
return false;
}
return true;
}
return true;
}

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

node.block_scope.enclosed = undefined;
node.parent_scope = undefined;
node.block_scope.parent_scope = undefined;
}

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

@@ -329,3 +329,5 @@ /***********************************************************************

if (!keep_quoted || !node.quote) {
node.key.name = mangle(node.key.name);
if (!node.computed_key()) {
node.key.name = mangle(node.key.name);
}
}

@@ -332,0 +334,0 @@ } else if (node instanceof AST_Dot) {

@@ -203,3 +203,3 @@ /***********************************************************************

AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = null, toplevel = this } = {}) {
AST_Scope.DEFMETHOD("figure_out_scope", function(options, { parent_scope = undefined, toplevel = this } = {}) {
options = defaults(options, {

@@ -528,3 +528,3 @@ cache: null,

// Propagate to this.uses_arguments from arrow functions
if ((scope instanceof AST_Arrow) && !this.uses_arguments) {
if ((scope instanceof AST_Arrow) && (this instanceof AST_Lambda && !this.uses_arguments)) {
this.uses_arguments = walk(scope, node => {

@@ -531,0 +531,0 @@ if (

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

"license": "BSD-2-Clause",
"version": "5.33.0",
"version": "5.34.0",
"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

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