enable --module by default (#5738)

- fix corner case in `mangle`
This commit is contained in:
Alex Lam S.L
2022-11-21 18:25:34 +00:00
committed by GitHub
parent 21aff996a5
commit 68d62a8a31
17 changed files with 294 additions and 92 deletions

View File

@@ -10234,22 +10234,24 @@ Compressor.prototype.compress = function(node) {
}
function varify(self, compressor) {
return all(self.definitions, function(defn) {
if (all(self.definitions, function(defn) {
return !defn.name.match_symbol(function(node) {
if (node instanceof AST_SymbolDeclaration) return !can_varify(compressor, node);
}, true);
}) ? to_var(self, compressor.find_parent(AST_Scope)) : self;
})) return to_var(self, compressor.find_parent(AST_Scope));
}
OPT(AST_Const, function(self, compressor) {
if (!compressor.option("varify")) return self;
var decl = varify(self, compressor);
if (decl) return decl;
if (can_letify(self, compressor, 0)) return to_let(self);
return varify(self, compressor);
return self;
});
OPT(AST_Let, function(self, compressor) {
if (!compressor.option("varify")) return self;
return varify(self, compressor);
return varify(self, compressor) || self;
});
function trim_optional_chain(node, compressor) {