feat(minifier): print decorators

This commit is contained in:
Boshen 2023-05-14 18:18:39 +08:00
parent e6737fdc48
commit 73b2a9a52b
No known key found for this signature in database
GPG key ID: 9C7A8C8AB22BEBD1

View file

@ -528,6 +528,7 @@ impl<'a> Gen for FunctionBody<'a> {
impl<'a> Gen for FormalParameter<'a> {
fn gen(&self, p: &mut Printer) {
self.decorators.gen(p);
self.pattern.gen(p);
}
}
@ -1415,6 +1416,7 @@ impl Gen for MetaProperty {
impl<'a> Gen for Class<'a> {
fn gen(&self, p: &mut Printer) {
self.decorators.gen(p);
p.print_str(b"class");
if let Some(id) = &self.id {
p.print(b' ');
@ -1669,6 +1671,8 @@ impl<'a> Gen for StaticBlock<'a> {
impl<'a> Gen for MethodDefinition<'a> {
fn gen(&self, p: &mut Printer) {
self.decorators.gen(p);
if self.r#static {
p.print_str(b"static ");
}
@ -1706,6 +1710,7 @@ impl<'a> Gen for MethodDefinition<'a> {
impl<'a> Gen for PropertyDefinition<'a> {
fn gen(&self, p: &mut Printer) {
self.decorators.gen(p);
if self.r#static {
p.print_str(b"static ");
}
@ -1822,3 +1827,19 @@ impl<'a> Gen for AssignmentPattern<'a> {
self.right.gen(p);
}
}
impl<'a> Gen for Vec<'a, Decorator<'a>> {
fn gen(&self, p: &mut Printer) {
for decorator in self {
decorator.gen(p);
p.print(b' ');
}
}
}
impl<'a> Gen for Decorator<'a> {
fn gen(&self, p: &mut Printer) {
p.print(b'@');
self.expression.gen(p);
}
}