mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
feat(codege): minify whitespace in object getter / setter (#8080)
This commit is contained in:
parent
1d5ae817d7
commit
618b6aa085
3 changed files with 15 additions and 5 deletions
|
|
@ -1665,18 +1665,22 @@ impl Gen for ObjectProperty<'_> {
|
|||
PropertyKind::Init => false,
|
||||
PropertyKind::Get => {
|
||||
p.add_source_mapping(self.span);
|
||||
p.print_str("get ");
|
||||
p.print_str("get");
|
||||
p.print_soft_space();
|
||||
true
|
||||
}
|
||||
PropertyKind::Set => {
|
||||
p.add_source_mapping(self.span);
|
||||
p.print_str("set ");
|
||||
p.print_str("set");
|
||||
p.print_soft_space();
|
||||
true
|
||||
}
|
||||
};
|
||||
if self.method || is_accessor {
|
||||
if func.r#async {
|
||||
p.print_str("async ");
|
||||
p.print_space_before_identifier();
|
||||
p.print_str("async");
|
||||
p.print_soft_space();
|
||||
}
|
||||
if func.generator {
|
||||
p.print_str("*");
|
||||
|
|
|
|||
|
|
@ -405,3 +405,9 @@ fn directive() {
|
|||
test_options("'\"'", "'\"';\n", double_quote.clone());
|
||||
test_options(r#""'\"""#, "\"'\\\"\";\n", double_quote);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn getter_setter() {
|
||||
test_minify("({ get [foo]() {} })", "({get[foo](){}});");
|
||||
test_minify("({ set [foo]() {} })", "({set[foo](){}});");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Original | minified | minified | gzip | gzip | Fixture
|
|||
|
||||
1.01 MB | 467.00 kB | 458.89 kB | 126.74 kB | 126.71 kB | bundle.min.js
|
||||
|
||||
1.25 MB | 661.60 kB | 646.76 kB | 163.94 kB | 163.73 kB | three.js
|
||||
1.25 MB | 661.59 kB | 646.76 kB | 163.94 kB | 163.73 kB | three.js
|
||||
|
||||
2.14 MB | 740.48 kB | 724.14 kB | 181.35 kB | 181.07 kB | victory.js
|
||||
|
||||
|
|
@ -23,5 +23,5 @@ Original | minified | minified | gzip | gzip | Fixture
|
|||
|
||||
6.69 MB | 2.39 MB | 2.31 MB | 495.62 kB | 488.28 kB | antd.js
|
||||
|
||||
10.95 MB | 3.54 MB | 3.49 MB | 909.70 kB | 915.50 kB | typescript.js
|
||||
10.95 MB | 3.54 MB | 3.49 MB | 909.71 kB | 915.50 kB | typescript.js
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue