fix(es/codegen): Fix codegen of classes with minify enabled (#1767)

This commit is contained in:
Shinobu Hayashi 2021-05-30 15:05:14 +09:00 committed by GitHub
parent 65ffd87771
commit 5d219b8cd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -7,7 +7,7 @@ include = ["Cargo.toml", "src/**/*.rs"]
license = "Apache-2.0/MIT"
name = "swc_ecma_codegen"
repository = "https://github.com/swc-project/swc.git"
version = "0.55.3"
version = "0.55.4"
[dependencies]
bitflags = "1"

View File

@ -37,7 +37,6 @@ impl<'a> Emitter<'a> {
space!();
emit!(node.ident);
emit!(node.class.type_params);
formatting_space!();
self.emit_class_trailing(&node.class)?;
}
@ -117,6 +116,15 @@ mod tests {
);
}
#[test]
fn issue_1764() {
assert_min(
"class Hoge {};
class HogeFuga extends Hoge {};",
"class Hoge{};class HogeFuga extends Hoge{};",
);
}
#[test]
fn single_argument_arrow_expression() {
assert_min("function* f(){ yield x => x}", "function*f(){yield x=>x}");

View File

@ -823,10 +823,6 @@ impl<'a> Emitter<'a> {
space!();
emit!(i);
emit!(node.class.type_params);
formatting_space!();
} else {
space!();
}
self.emit_class_trailing(&node.class)?;
@ -835,12 +831,13 @@ impl<'a> Emitter<'a> {
#[emitter]
fn emit_class_trailing(&mut self, node: &Class) -> Result {
if node.super_class.is_some() {
space!();
keyword!("extends");
space!();
emit!(node.super_class);
space!();
}
formatting_space!();
punct!("{");
self.emit_list(node.span, Some(&node.body), ListFormat::ClassMembers)?;
punct!("}");