diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-12 18:05:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-13 01:05:43 +0800 |
commit | d33a3a3253e2370f6874b2e5b01e94d78406162d (patch) | |
tree | 66723d0b6f6b8b1f3887f67a9190b7ffca80720d | |
parent | d7456a2dc220112a5fc294b102612c568395d72c (diff) | |
download | tracifyjs-d33a3a3253e2370f6874b2e5b01e94d78406162d.tar.gz tracifyjs-d33a3a3253e2370f6874b2e5b01e94d78406162d.zip |
enhance `unused` (#4098)
-rw-r--r-- | lib/compress.js | 1 | ||||
-rw-r--r-- | test/compress/drop-unused.js | 22 |
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", |