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.17.7 to 5.18.0

3

CHANGELOG.md
# Changelog
## v7.18.0
- Add new `/*@__MANGLE_PROP__*/` annotation, to mark properties that should be mangled.
## v5.17.7

@@ -4,0 +7,0 @@ - Update some dependencies

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

_KEY,
_MANGLEPROP,
walk,
} from "./ast.js";

@@ -192,2 +195,3 @@ import { domprops } from "../tools/domprops.js";

undeclared: false,
only_annotated: false,
}, true);

@@ -211,2 +215,3 @@

var only_annotated = options.only_annotated;
var regex = options.regex && new RegExp(options.regex);

@@ -223,2 +228,3 @@

var annotated_names = new Set();
var names_to_mangle = new Set();

@@ -232,3 +238,34 @@ var unmangleable = new Set();

// step 1: find candidates to mangle
// Step 1: Find all annotated /*@__MANGLEPROP__*/
walk(ast, node => {
if (
node instanceof AST_ClassPrivateProperty
|| node instanceof AST_PrivateMethod
|| node instanceof AST_PrivateGetter
|| node instanceof AST_PrivateSetter
|| node instanceof AST_DotHash
) {
// handled by mangle_private_properties
} else if (node instanceof AST_ObjectKeyVal) {
if (
typeof node.key == "string"
&& has_annotation(node, _MANGLEPROP)
&& can_mangle(node.key)
) {
annotated_names.add(node.key);
clear_annotation(node, _MANGLEPROP);
}
} else if (node instanceof AST_ObjectProperty) {
// setter or getter, since KeyVal is handled above
if (
has_annotation(node, _MANGLEPROP)
&& can_mangle(node.key.name)
) {
annotated_names.add(node.key.name);
clear_annotation(node, _MANGLEPROP);
}
}
});
// step 2: find candidates to mangle
ast.walk(new TreeWalker(function(node) {

@@ -329,3 +366,6 @@ if (

function should_mangle(name) {
if (regex && !regex.test(name)) return false;
if (only_annotated && !annotated_names.has(name)) return false;
if (regex && !regex.test(name)) {
return annotated_names.has(name);
}
if (reserved.has(name)) return false;

@@ -337,4 +377,5 @@ return cache.has(name)

function add(name) {
if (can_mangle(name))
if (can_mangle(name)) {
names_to_mangle.add(name);
}

@@ -341,0 +382,0 @@ if (!should_mangle(name)) {

2

package.json

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

"license": "BSD-2-Clause",
"version": "5.17.7",
"version": "5.18.0",
"engines": {

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

@@ -109,2 +109,3 @@ <h1><img src="https://terser.org/img/terser-banner-logo.png" alt="Terser" width="400"></h1>

`regex` Only mangle matched property names.
`only_annotated` Only mangle properties defined with /*@__MANGLE_PROP__*/.
`reserved` List of names that should not be mangled.

@@ -1193,2 +1194,3 @@ -f, --format [options] Specify format options.

* `/*@__KEY__*/` - Marks a string literal as a property to also mangle it when mangling properties.
* `/*@__MANGLE_PROP__*/` - Opts-in an object property (or class field) for mangling, when the property mangler is enabled.

@@ -1195,0 +1197,0 @@ You can use either a `@` sign at the start, or a `#`.

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