aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-12 18:05:43 +0100
committerGitHub <noreply@github.com>2020-09-13 01:05:43 +0800
commitd33a3a3253e2370f6874b2e5b01e94d78406162d (patch)
tree66723d0b6f6b8b1f3887f67a9190b7ffca80720d
parentd7456a2dc220112a5fc294b102612c568395d72c (diff)
downloadtracifyjs-d33a3a3253e2370f6874b2e5b01e94d78406162d.tar.gz
tracifyjs-d33a3a3253e2370f6874b2e5b01e94d78406162d.zip
enhance `unused` (#4098)
-rw-r--r--lib/compress.js1
-rw-r--r--test/compress/drop-unused.js22
2 files changed, 22 insertions, 1 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 50a37a68..f34673d6 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4400,6 +4400,7 @@ merge(Compressor.prototype, {
}
return scan_ref_scoped(node, descend, true);
});
+ tw.directives = Object.create(compressor.directives);
self.walk(tw);
// pass 2: for every used symbol we need to walk its
// initialization code to figure out if it uses other
diff --git a/test/compress/drop-unused.js b/test/compress/drop-unused.js
index 052a013b..96273a8d 100644
--- a/test/compress/drop-unused.js
+++ b/test/compress/drop-unused.js
@@ -1997,7 +1997,7 @@ issue_3146_4: {
expect_stdout: "PASS"
}
-issue_3192: {
+issue_3192_1: {
options = {
unused: true,
}
@@ -2025,6 +2025,26 @@ issue_3192: {
]
}
+issue_3192_2: {
+ options = {
+ keep_fargs: "strict",
+ unused: true,
+ }
+ input: {
+ "use strict";
+ (function(a) {
+ console.log(a = "foo", arguments[0]);
+ })("bar");
+ }
+ expect: {
+ "use strict";
+ (function() {
+ console.log("foo", arguments[0]);
+ })("bar");
+ }
+ expect_stdout: "foo bar"
+}
+
issue_3233: {
options = {
pure_getters: "strict",