aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2021-02-13 20:26:43 +0000
committerGitHub <noreply@github.com>2021-02-14 04:26:43 +0800
commitb7219ac489e47091f17091a08d7ef50980d68972 (patch)
treec46da154cf918ec3573ddb9b4dfd9df244919556 /lib/compress.js
parenta6bb66931bfdd04d6ce05b640d89a8deff7ca3de (diff)
downloadtracifyjs-b7219ac489e47091f17091a08d7ef50980d68972.tar.gz
tracifyjs-b7219ac489e47091f17091a08d7ef50980d68972.zip
support `import` statements (#4646)
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 7e113ecc..f7151441 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -70,6 +70,7 @@ function Compressor(options, false_by_default) {
hoist_vars : false,
ie8 : false,
if_return : !false_by_default,
+ imports : !false_by_default,
inline : !false_by_default,
join_vars : !false_by_default,
keep_fargs : false_by_default,
@@ -6081,6 +6082,10 @@ merge(Compressor.prototype, {
scope = save_scope;
return node;
}
+ if (node instanceof AST_SymbolImport) {
+ if (!compressor.option("imports") || node.definition().id in in_use_ids) return node;
+ return in_list ? List.skip : null;
+ }
}, function(node, in_list) {
if (node instanceof AST_BlockStatement) {
return trim_block(node, in_list);