diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-28 23:13:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-01 07:13:49 +0800 |
commit | ec0440f26492ff548a670605f232de8e14a93390 (patch) | |
tree | ab33d0e2cf42e16687c2b668a086752aaffcefd9 /lib | |
parent | 81254f67e473f2a1db8341de26cd923f9c592e17 (diff) | |
download | tracifyjs-ec0440f26492ff548a670605f232de8e14a93390.tar.gz tracifyjs-ec0440f26492ff548a670605f232de8e14a93390.zip |
fix corner cases with `import` (#4709)
fixes #4708
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index ba7ab4a0..fb6d16f9 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -1127,6 +1127,9 @@ merge(Compressor.prototype, { def(AST_SymbolCatch, function() { this.definition().fixed = false; }); + def(AST_SymbolImport, function() { + this.definition().fixed = false; + }); def(AST_SymbolRef, function(tw, descend, compressor) { var d = this.definition(); push_ref(d, this); @@ -5836,6 +5839,14 @@ merge(Compressor.prototype, { assignments.add(def.id, node); return true; } + if (node instanceof AST_SymbolImport) { + var def = node.definition(); + if (!(def.id in in_use_ids) && (!drop_vars || !is_safe_lexical(def))) { + in_use_ids[def.id] = true; + in_use.push(def); + } + return true; + } } else if (node instanceof AST_This && scope instanceof AST_DefClass) { var def = scope.name.definition(); if (!(def.id in in_use_ids)) { |