Socket
Socket
Sign inDemoInstall

terser

Package Overview
Dependencies
Maintainers
1
Versions
180
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.22.0 to 5.23.0

4

CHANGELOG.md
# Changelog
## v5.23.0
- When top_retain will keep a variable assignment around, inline the assignee when it's shorter than the name (#1434)
- Remove empty class `static {}` blocks.
## v5.22.0

@@ -4,0 +8,0 @@ - Do not `unsafe`ly shorten expressions like a?.toString() when they're conditional.

@@ -87,3 +87,3 @@ /***********************************************************************

_NOINLINE,
_PURE
_PURE,
} from "../ast.js";

@@ -152,8 +152,34 @@ import { make_node, has_annotation } from "../utils/index.js";

/**
* An extra check function for `top_retain` option, compare the length of const identifier
* and init value length and return true if init value is longer than identifier. for example:
* ```
* // top_retain: ["example"]
* const example = 100
* ```
* it will return false because length of "100" is short than identifier "example".
*/
function is_const_symbol_short_than_init_value(def, fixed_value) {
if (def.orig.length === 1 && fixed_value) {
const init_value_length = fixed_value.size();
const identifer_length = def.name.length;
return init_value_length > identifer_length;
}
return true;
}
export function inline_into_symbolref(self, compressor) {
const parent = compressor.parent();
const def = self.definition();
const nearest_scope = compressor.find_scope();
if (compressor.top_retain && def.global && compressor.top_retain(def)) {
let fixed = self.fixed_value();
if (
compressor.top_retain &&
def.global &&
compressor.top_retain(def) &&
// when identifier is in top_retain option dose not mean we can always inline it.
// if identifier name is longer then init value, we can replace it.
is_const_symbol_short_than_init_value(def, fixed)
) {
// keep it
def.fixed = false;

@@ -164,3 +190,2 @@ def.single_use = false;

let fixed = self.fixed_value();
let single_use = def.single_use

@@ -167,0 +192,0 @@ && !(parent instanceof AST_Call

2

package.json

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

"license": "BSD-2-Clause",
"version": "5.22.0",
"version": "5.23.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