fix(minifier): the mangle phase should come after the compress phase

To align with terser
This commit is contained in:
Boshen 2023-05-27 19:12:51 +08:00
parent a0b9628177
commit 22664a3a83
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1

View file

@ -46,12 +46,12 @@ impl<'a> Minifier<'a> {
let ret = Parser::new(&allocator, self.source_text, self.source_type).parse();
let ret = AstLower::new(&allocator, self.source_type).build(&ret.program);
let mut program = ret.program;
let mut semantic = ret.semantic;
let semantic = ret.semantic;
let mut semantic =
Compressor::new(&allocator, semantic, self.options.compress).build(&mut program);
if self.options.mangle {
semantic.mangle();
}
let semantic =
Compressor::new(&allocator, semantic, self.options.compress).build(&mut program);
Printer::new(self.source_text.len(), self.options.print)
.with_mangle(semantic.symbol_table, self.options.mangle)
.build(&program)