-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(es/codegen): Skip whitespaces for comments in minify mode (#6465)
Co-authored-by: Donny/강동윤 <[email protected]>
- Loading branch information
1 parent
5a3ae50
commit 08a9e21
Showing
9 changed files
with
96 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
crates/swc_html_minifier/tests/fixture/element/script-custom-type/input.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" | ||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
<body> | ||
<script type="text/ng-template"> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script> | ||
|
||
<script type="text/ng-template"> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script> | ||
<script type="text/html"> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script> | ||
<script type="text/html"> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script> | ||
</body> | ||
</html> |
21 changes: 21 additions & 0 deletions
21
crates/swc_html_minifier/tests/fixture/element/script-custom-type/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<!doctype html><html lang=en><meta charset=UTF-8><meta name=viewport content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"><title>Document</title><body><script type=text/ng-template> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script><script type=text/ng-template> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script><script type=text/html> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script><script type=text/html> | ||
<!--test--> | ||
<div> | ||
<span> foobar </span> | ||
</div> | ||
</script> |
4 changes: 2 additions & 2 deletions
4
crates/swc_html_minifier/tests/fixture/element/script-options-2/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<!doctype html><html lang=en><title>Document</title><div>Script:</div> | ||
<script>/* Should mangle top level stuff */ var o=function(){let o="bar";o&&(o+="baz"),console.log(o)}</script> | ||
<script>/* Should mangle top level stuff */var o=function(){let o="bar";o&&(o+="baz"),console.log(o)}</script> | ||
|
||
<div>Module:</div> | ||
<script type=module>/* Should mangle top level stuff */ var o=function(){let o="bar";o&&(o+="baz"),console.log(o)}</script> | ||
<script type=module>/* Should mangle top level stuff */var o=function(){let o="bar";o&&(o+="baz"),console.log(o)}</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
crates/swc_html_minifier/tests/fixture/element/script-options/output.min.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
<!doctype html><html lang=en><title>Document</title><body><script type=module>/* Keep comment */ debugger;// Keep comment | ||
console.log("test \u{1F600} test")</script> | ||
<!doctype html><html lang=en><title>Document</title><body><script type=module>/* Keep comment */debugger;// Keep comment | ||
console.log("test \u{1F600} test")</script><script>// Comment | ||
var a="test",b="test",/* Comment */c/* Comment */=/* Comment */"test"/* Comment */,a="test"// test | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
08a9e21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark
es/full/bugs-1
343924
ns/iter (± 22485
)389841
ns/iter (± 22054
)0.88
es/full/minify/libraries/antd
1843749333
ns/iter (± 35421072
)2094374257
ns/iter (± 82448426
)0.88
es/full/minify/libraries/d3
387498447
ns/iter (± 5737899
)502630299
ns/iter (± 27607030
)0.77
es/full/minify/libraries/echarts
1572904733
ns/iter (± 20004804
)1873070557
ns/iter (± 758763072
)0.84
es/full/minify/libraries/jquery
98456298
ns/iter (± 1250161
)125668872
ns/iter (± 7586107
)0.78
es/full/minify/libraries/lodash
118166720
ns/iter (± 2299627
)161579804
ns/iter (± 21023829
)0.73
es/full/minify/libraries/moment
59148603
ns/iter (± 1227695
)88708545
ns/iter (± 29765105
)0.67
es/full/minify/libraries/react
19805763
ns/iter (± 491219
)26280308
ns/iter (± 4046363
)0.75
es/full/minify/libraries/terser
294796142
ns/iter (± 8290835
)374533985
ns/iter (± 18064188
)0.79
es/full/minify/libraries/three
565727456
ns/iter (± 7292018
)652642002
ns/iter (± 31323109
)0.87
es/full/minify/libraries/typescript
3371443301
ns/iter (± 25883126
)4136959214
ns/iter (± 252717032
)0.81
es/full/minify/libraries/victory
813563327
ns/iter (± 9071427
)927628403
ns/iter (± 61741347
)0.88
es/full/minify/libraries/vue
149708038
ns/iter (± 2072901
)178428798
ns/iter (± 9735215
)0.84
es/full/codegen/es3
32100
ns/iter (± 588
)35629
ns/iter (± 8609
)0.90
es/full/codegen/es5
32174
ns/iter (± 943
)38103
ns/iter (± 6502
)0.84
es/full/codegen/es2015
32209
ns/iter (± 599
)36890
ns/iter (± 5849
)0.87
es/full/codegen/es2016
32185
ns/iter (± 691
)34100
ns/iter (± 6093
)0.94
es/full/codegen/es2017
32113
ns/iter (± 1559
)38119
ns/iter (± 7737
)0.84
es/full/codegen/es2018
32131
ns/iter (± 932
)37150
ns/iter (± 6840
)0.86
es/full/codegen/es2019
32293
ns/iter (± 1393
)36291
ns/iter (± 6934
)0.89
es/full/codegen/es2020
32442
ns/iter (± 1290
)36868
ns/iter (± 5595
)0.88
es/full/all/es3
186157363
ns/iter (± 4084748
)225387040
ns/iter (± 24353389
)0.83
es/full/all/es5
176933693
ns/iter (± 3280462
)213631035
ns/iter (± 17082855
)0.83
es/full/all/es2015
141729882
ns/iter (± 9827151
)169123795
ns/iter (± 9833735
)0.84
es/full/all/es2016
140943158
ns/iter (± 2932572
)171026993
ns/iter (± 15511849
)0.82
es/full/all/es2017
140890007
ns/iter (± 7364971
)169572869
ns/iter (± 12352684
)0.83
es/full/all/es2018
140345275
ns/iter (± 8031443
)164007453
ns/iter (± 10050642
)0.86
es/full/all/es2019
138207241
ns/iter (± 4187062
)164051983
ns/iter (± 11626394
)0.84
es/full/all/es2020
132581196
ns/iter (± 2728081
)161819590
ns/iter (± 14091917
)0.82
es/full/parser
693874
ns/iter (± 30441
)822178
ns/iter (± 111880
)0.84
es/full/base/fixer
25086
ns/iter (± 896
)28915
ns/iter (± 4716
)0.87
es/full/base/resolver_and_hygiene
88295
ns/iter (± 6324
)97233
ns/iter (± 11134
)0.91
serialization of ast node
212
ns/iter (± 9
)244
ns/iter (± 32
)0.87
serialization of serde
217
ns/iter (± 7
)228
ns/iter (± 28
)0.95
This comment was automatically generated by workflow using github-action-benchmark.