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 exports in DCE (#5973)
- Loading branch information
Showing
5 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
crates/swc_ecma_minifier/tests/fixture/issues/5955/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,16 @@ | ||
export var foo; | ||
export function init() { | ||
function bar() { | ||
foo = bar; | ||
console.log(111); | ||
} | ||
return bar; | ||
} | ||
|
||
function bar() { | ||
foo = bar; | ||
console.log(111); | ||
} | ||
export function init1() { | ||
return bar; | ||
} |
13 changes: 13 additions & 0 deletions
13
crates/swc_ecma_minifier/tests/fixture/issues/5955/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,13 @@ | ||
export var foo; | ||
export function init() { | ||
function bar() { | ||
foo = bar, console.log(111); | ||
} | ||
return bar; | ||
} | ||
function bar() { | ||
foo = bar, console.log(111); | ||
} | ||
export function init1() { | ||
return bar; | ||
} |
15 changes: 15 additions & 0 deletions
15
crates/swc_ecma_minifier/tests/fixture/issues/5955/output.mangleOnly.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,15 @@ | ||
export var foo; | ||
export function init() { | ||
function o() { | ||
foo = o; | ||
console.log(111); | ||
} | ||
return o; | ||
} | ||
function o() { | ||
foo = o; | ||
console.log(111); | ||
} | ||
export function init1() { | ||
return o; | ||
} |
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
aff4ea5
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/minify/libraries/antd
1871351911
ns/iter (± 20840435
)1886603543
ns/iter (± 66301921
)0.99
es/full/minify/libraries/d3
358780313
ns/iter (± 8406390
)371781632
ns/iter (± 5151697
)0.97
es/full/minify/libraries/echarts
1431744852
ns/iter (± 32911771
)1437616304
ns/iter (± 162784716
)1.00
es/full/minify/libraries/jquery
94377821
ns/iter (± 4148671
)93344574
ns/iter (± 9911106
)1.01
es/full/minify/libraries/lodash
109474365
ns/iter (± 1661123
)123449611
ns/iter (± 14454768
)0.89
es/full/minify/libraries/moment
50824564
ns/iter (± 1786081
)56263510
ns/iter (± 3126820
)0.90
es/full/minify/libraries/react
19232153
ns/iter (± 892420
)20130054
ns/iter (± 858554
)0.96
es/full/minify/libraries/terser
269327497
ns/iter (± 5148462
)280284921
ns/iter (± 11841440
)0.96
es/full/minify/libraries/three
477551369
ns/iter (± 8546481
)486880643
ns/iter (± 16700538
)0.98
es/full/minify/libraries/typescript
3292719996
ns/iter (± 91584606
)3306784806
ns/iter (± 83570505
)1.00
es/full/minify/libraries/victory
741739918
ns/iter (± 8192530
)768606553
ns/iter (± 18621402
)0.97
es/full/minify/libraries/vue
129287034
ns/iter (± 5991678
)144207013
ns/iter (± 8444782
)0.90
es/full/codegen/es3
33395
ns/iter (± 425
)44481
ns/iter (± 16412
)0.75
es/full/codegen/es5
32788
ns/iter (± 750
)33523
ns/iter (± 1430
)0.98
es/full/codegen/es2015
32632
ns/iter (± 1114
)33422
ns/iter (± 1223
)0.98
es/full/codegen/es2016
32531
ns/iter (± 1090
)33379
ns/iter (± 1583
)0.97
es/full/codegen/es2017
33439
ns/iter (± 1082
)33298
ns/iter (± 1777
)1.00
es/full/codegen/es2018
33465
ns/iter (± 548
)34223
ns/iter (± 4425
)0.98
es/full/codegen/es2019
33586
ns/iter (± 816
)33308
ns/iter (± 1285
)1.01
es/full/codegen/es2020
33643
ns/iter (± 2405
)33268
ns/iter (± 2519
)1.01
es/full/all/es3
203519354
ns/iter (± 9795970
)194310351
ns/iter (± 12407609
)1.05
es/full/all/es5
193292251
ns/iter (± 11496848
)181894836
ns/iter (± 13325535
)1.06
es/full/all/es2015
151822373
ns/iter (± 5782091
)153680358
ns/iter (± 12671739
)0.99
es/full/all/es2016
146393878
ns/iter (± 7300563
)157749673
ns/iter (± 11486430
)0.93
es/full/all/es2017
148433426
ns/iter (± 5946553
)144792103
ns/iter (± 10924287
)1.03
es/full/all/es2018
141622940
ns/iter (± 3350024
)142775177
ns/iter (± 5763312
)0.99
es/full/all/es2019
139895867
ns/iter (± 3429394
)145978995
ns/iter (± 11826326
)0.96
es/full/all/es2020
134768734
ns/iter (± 3191662
)138104495
ns/iter (± 8651077
)0.98
es/full/parser
708284
ns/iter (± 17958
)714488
ns/iter (± 39459
)0.99
es/full/base/fixer
25588
ns/iter (± 562
)25867
ns/iter (± 1760
)0.99
es/full/base/resolver_and_hygiene
92175
ns/iter (± 1817
)91897
ns/iter (± 3088
)1.00
serialization of ast node
214
ns/iter (± 8
)216
ns/iter (± 25
)0.99
serialization of serde
224
ns/iter (± 6
)217
ns/iter (± 4
)1.03
This comment was automatically generated by workflow using github-action-benchmark.