enhance imports (#5287)

This commit is contained in:
Alex Lam S.L
2022-01-12 08:24:04 +00:00
committed by GitHub
parent f639a30bd2
commit 9a58270b70
2 changed files with 17 additions and 0 deletions

View File

@@ -459,6 +459,7 @@ Compressor.prototype.compress = function(node) {
if (ref.in_arg && is_funarg(def)) return false;
return all(def.orig, function(sym) {
if (sym instanceof AST_SymbolConst || sym instanceof AST_SymbolLet) {
if (sym instanceof AST_SymbolImport) return true;
return compressor && can_varify(compressor, sym);
}
return !(keep_lambda && sym instanceof AST_SymbolLambda);

View File

@@ -106,6 +106,22 @@ drop_unused: {
}
}
drop_side_effect_free: {
options = {
imports: true,
side_effects: true,
toplevel: true,
unused: true,
}
input: {
import foo from "bar";
var a = foo;
}
expect: {
import "bar";
}
}
mangle: {
rename = false
mangle = {