support import statements (#4646)

This commit is contained in:
Alex Lam S.L
2021-02-13 20:26:43 +00:00
committed by GitHub
parent a6bb66931b
commit b7219ac489
8 changed files with 312 additions and 10 deletions

View File

@@ -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);