Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(es/minifier): Add tests for preserving top-level directives (#6545)
- Loading branch information
Showing
12 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_minifier/tests/fixture/issues/6508/1/input.js
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,2 @@ | ||
'use client'; | ||
foo(() => { }) |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_minifier/tests/fixture/issues/6508/1/output.js
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,2 @@ | ||
'use client'; | ||
foo(()=>{}); |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_minifier/tests/fixture/issues/6508/1/output/input.js
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,2 @@ | ||
"use client"; | ||
foo(function() {}); |
2 changes: 2 additions & 0 deletions
2
crates/swc_ecma_minifier/tests/fixture/issues/6508/1/output/output.js
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,2 @@ | ||
"use client"; | ||
foo(function() {}); |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_minifier/tests/fixture/issues/6508/2/input.js
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,6 @@ | ||
'use client'; | ||
|
||
|
||
export class Foo { | ||
foo() { } | ||
} |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/6508/2/output.js
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,4 @@ | ||
'use client'; | ||
export class Foo { | ||
foo() {} | ||
} |
16 changes: 16 additions & 0 deletions
16
crates/swc_ecma_minifier/tests/fixture/issues/6508/2/output/output.js
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,16 @@ | ||
"use client"; | ||
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs"; | ||
import _create_class from "@swc/helpers/src/_create_class.mjs"; | ||
export var Foo = /*#__PURE__*/ function() { | ||
"use strict"; | ||
function Foo() { | ||
_class_call_check(this, Foo); | ||
} | ||
_create_class(Foo, [ | ||
{ | ||
key: "foo", | ||
value: function foo() {} | ||
} | ||
]); | ||
return Foo; | ||
}(); |
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_minifier/tests/fixture/issues/6508/3/input.js
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,6 @@ | ||
'use client'; | ||
|
||
|
||
export var Foo = { | ||
foo() { } | ||
} |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/6508/3/output.js
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,4 @@ | ||
'use client'; | ||
export var Foo = { | ||
foo () {} | ||
}; |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/6508/3/output/input.js
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,4 @@ | ||
"use client"; | ||
export var Foo = { | ||
foo: function foo() {} | ||
}; |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/6508/3/output/output.js
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,4 @@ | ||
"use client"; | ||
export var Foo = { | ||
foo: function() {} | ||
}; |
4 changes: 4 additions & 0 deletions
4
crates/swc_ecma_minifier/tests/fixture/issues/6508/config.json
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,4 @@ | ||
{ | ||
"defaults": true, | ||
"directives": false | ||
} |
8d8f150
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
358744
ns/iter (± 33787
)334484
ns/iter (± 25253
)1.07
es/full/minify/libraries/antd
2054077725
ns/iter (± 67546884
)1985033267
ns/iter (± 54616024
)1.03
es/full/minify/libraries/d3
464984035
ns/iter (± 29231946
)451264885
ns/iter (± 20399640
)1.03
es/full/minify/libraries/echarts
1734326571
ns/iter (± 49239593
)1729017452
ns/iter (± 117064850
)1.00
es/full/minify/libraries/jquery
117758691
ns/iter (± 5769183
)119329511
ns/iter (± 3731635
)0.99
es/full/minify/libraries/lodash
135239700
ns/iter (± 4787750
)128354724
ns/iter (± 6467181
)1.05
es/full/minify/libraries/moment
70338142
ns/iter (± 2332834
)70627826
ns/iter (± 5695381
)1.00
es/full/minify/libraries/react
22497693
ns/iter (± 1665945
)20674106
ns/iter (± 710523
)1.09
es/full/minify/libraries/terser
351031518
ns/iter (± 12365286
)334164428
ns/iter (± 20205839
)1.05
es/full/minify/libraries/three
617854671
ns/iter (± 17185071
)603461179
ns/iter (± 8553684
)1.02
es/full/minify/libraries/typescript
3820428142
ns/iter (± 104269447
)3708197985
ns/iter (± 111801337
)1.03
es/full/minify/libraries/victory
926912015
ns/iter (± 35524000
)905737848
ns/iter (± 24437369
)1.02
es/full/minify/libraries/vue
182563335
ns/iter (± 21950587
)167752283
ns/iter (± 9716446
)1.09
es/full/codegen/es3
33529
ns/iter (± 1021
)33029
ns/iter (± 391
)1.02
es/full/codegen/es5
33358
ns/iter (± 770
)32717
ns/iter (± 614
)1.02
es/full/codegen/es2015
33513
ns/iter (± 561
)32818
ns/iter (± 952
)1.02
es/full/codegen/es2016
36367
ns/iter (± 20275
)32662
ns/iter (± 1004
)1.11
es/full/codegen/es2017
33464
ns/iter (± 1251
)32587
ns/iter (± 969
)1.03
es/full/codegen/es2018
33506
ns/iter (± 1162
)32652
ns/iter (± 1581
)1.03
es/full/codegen/es2019
33356
ns/iter (± 3174
)32719
ns/iter (± 556
)1.02
es/full/codegen/es2020
33684
ns/iter (± 1195
)32867
ns/iter (± 698
)1.02
es/full/all/es3
196893420
ns/iter (± 13425021
)186076105
ns/iter (± 11338774
)1.06
es/full/all/es5
187382004
ns/iter (± 14118598
)178762626
ns/iter (± 5144917
)1.05
es/full/all/es2015
146705443
ns/iter (± 9072113
)143152033
ns/iter (± 5274196
)1.02
es/full/all/es2016
151644955
ns/iter (± 13089969
)140941150
ns/iter (± 5224637
)1.08
es/full/all/es2017
157280192
ns/iter (± 11380078
)140996963
ns/iter (± 5534235
)1.12
es/full/all/es2018
149640588
ns/iter (± 11178546
)138547701
ns/iter (± 7491855
)1.08
es/full/all/es2019
148781706
ns/iter (± 11796853
)137104844
ns/iter (± 7630053
)1.09
es/full/all/es2020
142419570
ns/iter (± 12021188
)131219634
ns/iter (± 5035700
)1.09
es/full/parser
724790
ns/iter (± 41415
)702270
ns/iter (± 35195
)1.03
es/full/base/fixer
26319
ns/iter (± 537
)26360
ns/iter (± 342
)1.00
es/full/base/resolver_and_hygiene
92555
ns/iter (± 7569
)91446
ns/iter (± 1905
)1.01
serialization of ast node
216
ns/iter (± 4
)220
ns/iter (± 2
)0.98
serialization of serde
219
ns/iter (± 7
)218
ns/iter (± 5
)1.00
This comment was automatically generated by workflow using github-action-benchmark.