-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/minifier): Preserve classes with side effects in static fields (…
- Loading branch information
Showing
25 changed files
with
612 additions
and
78 deletions.
There are no files selected for viewing
14 changes: 13 additions & 1 deletion
14
crates/swc/tests/tsc-references/classStaticBlock15(target=es2022).2.minified.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 |
---|---|---|
@@ -1,2 +1,14 @@ | ||
//// [classStaticBlock15.ts] | ||
console.log(void 0); | ||
var _C__1; | ||
class C { | ||
static #_1 = 1; | ||
static #_3 = 3; | ||
static #_5 = 5; | ||
static{} | ||
static{} | ||
static{} | ||
static{} | ||
static{} | ||
static{} | ||
} | ||
console.log(_C__1); |
7 changes: 6 additions & 1 deletion
7
crates/swc/tests/tsc-references/classStaticBlock23.2.minified.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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
//// [classStaticBlock23.ts] | ||
[ | ||
const nums = [ | ||
1, | ||
2, | ||
3 | ||
].map((n)=>Promise.resolve(n)); | ||
class C { | ||
static{ | ||
for await (let nn of nums)console.log(nn); | ||
} | ||
} |
12 changes: 11 additions & 1 deletion
12
crates/swc/tests/tsc-references/classStaticBlock5(target=es2022).2.minified.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 |
---|---|---|
@@ -1,2 +1,12 @@ | ||
//// [classStaticBlock5.ts] | ||
super.a; | ||
class B { | ||
static a = 1; | ||
static b = 2; | ||
} | ||
class C extends B { | ||
static b = 3; | ||
static c = super.a; | ||
static{ | ||
this.b, super.b, super.a; | ||
} | ||
} |
10 changes: 9 additions & 1 deletion
10
crates/swc/tests/tsc-references/classStaticBlockUseBeforeDef1.2.minified.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 |
---|---|---|
@@ -1,2 +1,10 @@ | ||
//// [classStaticBlockUseBeforeDef1.ts] | ||
this.x; | ||
class C { | ||
static{ | ||
this.x = 1; | ||
} | ||
static y = this.x; | ||
static{ | ||
this.z = this.y; | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
crates/swc/tests/tsc-references/classStaticBlockUseBeforeDef2.2.minified.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 |
---|---|---|
@@ -1 +1,6 @@ | ||
//// [classStaticBlockUseBeforeDef2.ts] | ||
class C { | ||
static{ | ||
this.x = 1; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...es/swc/tests/tsc-references/privateNameComputedPropertyName4(target=es2022).2.minified.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 |
---|---|---|
@@ -1 +1,13 @@ | ||
//// [privateNameComputedPropertyName4.ts] | ||
class C1 { | ||
static #qux = 42; | ||
bar() {} | ||
} | ||
class C2 { | ||
static #qux = 42; | ||
static bar() {} | ||
} | ||
class C3 { | ||
static #qux = 42; | ||
static bar = "test"; | ||
} |
Oops, something went wrong.
8d906b4
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
339249
ns/iter (± 19114
)348064
ns/iter (± 21090
)0.97
es/full/minify/libraries/antd
1926569394
ns/iter (± 34703410
)1861224113
ns/iter (± 18958664
)1.04
es/full/minify/libraries/d3
435442912
ns/iter (± 7649321
)389988874
ns/iter (± 6870003
)1.12
es/full/minify/libraries/echarts
1624471008
ns/iter (± 28803665
)1577763775
ns/iter (± 16905140
)1.03
es/full/minify/libraries/jquery
102257399
ns/iter (± 8813358
)98646680
ns/iter (± 2204385
)1.04
es/full/minify/libraries/lodash
130135274
ns/iter (± 4286135
)116542380
ns/iter (± 1726326
)1.12
es/full/minify/libraries/moment
63941126
ns/iter (± 3293122
)59429737
ns/iter (± 2548244
)1.08
es/full/minify/libraries/react
21328940
ns/iter (± 1355804
)19875033
ns/iter (± 430279
)1.07
es/full/minify/libraries/terser
325367259
ns/iter (± 28015923
)295769946
ns/iter (± 4592453
)1.10
es/full/minify/libraries/three
578632415
ns/iter (± 18338390
)556747640
ns/iter (± 9272686
)1.04
es/full/minify/libraries/typescript
3437266357
ns/iter (± 47791599
)3380624220
ns/iter (± 30967521
)1.02
es/full/minify/libraries/victory
856744228
ns/iter (± 28800418
)823330763
ns/iter (± 8991560
)1.04
es/full/minify/libraries/vue
158569815
ns/iter (± 7575003
)149893326
ns/iter (± 3945108
)1.06
es/full/codegen/es3
34035
ns/iter (± 1014
)32325
ns/iter (± 575
)1.05
es/full/codegen/es5
34007
ns/iter (± 807
)32309
ns/iter (± 874
)1.05
es/full/codegen/es2015
34081
ns/iter (± 957
)32335
ns/iter (± 1130
)1.05
es/full/codegen/es2016
34016
ns/iter (± 674
)32269
ns/iter (± 916
)1.05
es/full/codegen/es2017
33999
ns/iter (± 743
)32664
ns/iter (± 1410
)1.04
es/full/codegen/es2018
34008
ns/iter (± 715
)32273
ns/iter (± 669
)1.05
es/full/codegen/es2019
34020
ns/iter (± 1942
)32184
ns/iter (± 737
)1.06
es/full/codegen/es2020
33906
ns/iter (± 842
)32149
ns/iter (± 495
)1.05
es/full/all/es3
200541905
ns/iter (± 8865910
)185618286
ns/iter (± 5086021
)1.08
es/full/all/es5
187712132
ns/iter (± 7367374
)187186209
ns/iter (± 20265378
)1.00
es/full/all/es2015
147288770
ns/iter (± 6736358
)147104205
ns/iter (± 5903807
)1.00
es/full/all/es2016
145597155
ns/iter (± 5191199
)161329879
ns/iter (± 15039864
)0.90
es/full/all/es2017
145379414
ns/iter (± 5165232
)144670050
ns/iter (± 9934192
)1.00
es/full/all/es2018
144724573
ns/iter (± 9131420
)142704662
ns/iter (± 4543639
)1.01
es/full/all/es2019
142600788
ns/iter (± 7385079
)140021092
ns/iter (± 5206629
)1.02
es/full/all/es2020
136994947
ns/iter (± 6100882
)133891968
ns/iter (± 4505645
)1.02
es/full/parser
717720
ns/iter (± 50162
)713844
ns/iter (± 21609
)1.01
es/full/base/fixer
26456
ns/iter (± 818
)26263
ns/iter (± 433
)1.01
es/full/base/resolver_and_hygiene
92926
ns/iter (± 3163
)92195
ns/iter (± 3278
)1.01
serialization of ast node
205
ns/iter (± 1
)205
ns/iter (± 4
)1
serialization of serde
212
ns/iter (± 4
)213
ns/iter (± 7
)1.00
This comment was automatically generated by workflow using github-action-benchmark.