From 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 18:09:58 +0800
Subject: [PATCH] 上报转运调试
---
node_modules/terser/lib/compress/evaluate.js | 41 ++++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/node_modules/terser/lib/compress/evaluate.js b/node_modules/terser/lib/compress/evaluate.js
index f658dff..1019924 100644
--- a/node_modules/terser/lib/compress/evaluate.js
+++ b/node_modules/terser/lib/compress/evaluate.js
@@ -371,6 +371,15 @@
return value;
});
+def_eval(AST_Chain, function (compressor, depth) {
+ const evaluated = this.expression._eval(compressor, depth, /*ast_chain=*/true);
+ return evaluated === nullish
+ ? undefined
+ : evaluated === this.expression
+ ? this
+ : evaluated;
+});
+
const global_objs = { Array, Math, Number, Object, String };
const regexp_flags = new Set([
@@ -382,9 +391,13 @@
"unicode",
]);
-def_eval(AST_PropAccess, function (compressor, depth) {
- let obj = this.expression._eval(compressor, depth + 1);
- if (obj === nullish || (this.optional && obj == null)) return nullish;
+def_eval(AST_PropAccess, function (compressor, depth, ast_chain) {
+ let obj = (ast_chain || this.property === "length" || compressor.option("unsafe"))
+ && this.expression._eval(compressor, depth + 1, ast_chain);
+
+ if (ast_chain) {
+ if (obj === nullish || (this.optional && obj == null)) return nullish;
+ }
// `.length` of strings and arrays is always safe
if (this.property === "length") {
@@ -455,26 +468,19 @@
return this;
});
-def_eval(AST_Chain, function (compressor, depth) {
- const evaluated = this.expression._eval(compressor, depth);
- return evaluated === nullish
- ? undefined
- : evaluated === this.expression
- ? this
- : evaluated;
-});
-
-def_eval(AST_Call, function (compressor, depth) {
+def_eval(AST_Call, function (compressor, depth, ast_chain) {
var exp = this.expression;
- const callee = exp._eval(compressor, depth);
- if (callee === nullish || (this.optional && callee == null)) return nullish;
+ if (ast_chain) {
+ const callee = exp._eval(compressor, depth, ast_chain);
+ if (callee === nullish || (this.optional && callee == null)) return nullish;
+ }
if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
var key = exp.property;
if (key instanceof AST_Node) {
key = key._eval(compressor, depth);
- if (key === exp.property)
+ if (typeof key !== "string" && typeof key !== "number")
return this;
}
var val;
@@ -492,7 +498,8 @@
if (!is_pure_native_fn(e.name, key)) return this;
val = global_objs[e.name];
} else {
- val = e._eval(compressor, depth + 1);
+ val = e._eval(compressor, depth + 1, /* don't pass ast_chain (exponential work) */);
+
if (val === e || !val)
return this;
if (!is_pure_native_method(val.constructor.name, key))
--
Gitblit v1.9.3