feat: refactoring project
This commit is contained in:
41
node_modules/terser/lib/compress/drop-unused.js
generated
vendored
41
node_modules/terser/lib/compress/drop-unused.js
generated
vendored
@@ -103,8 +103,8 @@ import {
|
||||
is_empty,
|
||||
is_ref_of,
|
||||
can_be_evicted_from_block,
|
||||
requires_sequence_to_maintain_binding,
|
||||
} from "./common.js";
|
||||
import { is_used_in_expression } from "./inference.js";
|
||||
|
||||
const r_keep_assign = /keep_assign/;
|
||||
|
||||
@@ -503,42 +503,3 @@ AST_Scope.DEFMETHOD("drop_unused", function(compressor) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user