-
-
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): Abort IIFE invoker completely on eval (#6659)
**Related issue:** - Closes #6628.
- Loading branch information
Showing
8 changed files
with
1,675 additions
and
1,595 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
18 changes: 18 additions & 0 deletions
18
crates/swc_ecma_minifier/tests/fixture/issues/6628/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,18 @@ | ||
(function () { | ||
var Collector = function () { | ||
var e = function e(e) { }; | ||
return e.usePlugin = function (t, i, n) { | ||
|
||
}, e.plugins = [], e; | ||
}(); | ||
var CallbackType; | ||
!function (e) { | ||
e[e.Var = 0] = "Var", e[e.All = 1] = "All"; | ||
}(CallbackType || (CallbackType = {})); | ||
var CepRule = function () { | ||
eval(); | ||
}(); | ||
Collector.usePlugin(CepRule, "cep"); | ||
|
||
exports.Collector = Collector; | ||
})() |
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 changes: 13 additions & 0 deletions
13
crates/swc_ecma_minifier/tests/fixture/issues/6628/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 @@ | ||
!function() { | ||
var CallbackType, Collector = function() { | ||
var n = function(n) {}; | ||
return n.usePlugin = function(n, u, l) {}, n.plugins = [], n; | ||
}(); | ||
!function(n) { | ||
n[n.Var = 0] = "Var", n[n.All = 1] = "All"; | ||
}(CallbackType || (CallbackType = {})); | ||
var CepRule = function() { | ||
eval(); | ||
}(); | ||
Collector.usePlugin(CepRule, "cep"), exports.Collector = Collector; | ||
}(); |
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
2,492 changes: 1,245 additions & 1,247 deletions
2,492
crates/swc_ecma_minifier/tests/fixture/next/feedback-3/579-dcac359116b2707c/output.js
Large diffs are not rendered by default.
Oops, something went wrong.
554 changes: 293 additions & 261 deletions
554
crates/swc_ecma_minifier/tests/fixture/next/wrap-contracts/output.js
Large diffs are not rendered by default.
Oops, something went wrong.
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
bb9fab8
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
294436
ns/iter (± 18672
)303209
ns/iter (± 10929
)0.97
es/full/minify/libraries/antd
1682929952
ns/iter (± 22010166
)1587710313
ns/iter (± 18766309
)1.06
es/full/minify/libraries/d3
355263299
ns/iter (± 6437494
)301636658
ns/iter (± 7133572
)1.18
es/full/minify/libraries/echarts
1392993601
ns/iter (± 13312952
)1246789912
ns/iter (± 36546225
)1.12
es/full/minify/libraries/jquery
91520549
ns/iter (± 874153
)89489127
ns/iter (± 2142963
)1.02
es/full/minify/libraries/lodash
109655120
ns/iter (± 910534
)105863771
ns/iter (± 879694
)1.04
es/full/minify/libraries/moment
53472926
ns/iter (± 381720
)52496464
ns/iter (± 380899
)1.02
es/full/minify/libraries/react
19432660
ns/iter (± 120930
)18943610
ns/iter (± 83851
)1.03
es/full/minify/libraries/terser
256302558
ns/iter (± 3615254
)247181343
ns/iter (± 2809917
)1.04
es/full/minify/libraries/three
472979053
ns/iter (± 9766481
)438388012
ns/iter (± 24985808
)1.08
es/full/minify/libraries/typescript
3131604239
ns/iter (± 27741782
)3000023682
ns/iter (± 12683321
)1.04
es/full/minify/libraries/victory
735437178
ns/iter (± 8807430
)663531396
ns/iter (± 9980992
)1.11
es/full/minify/libraries/vue
140084586
ns/iter (± 1289782
)139623880
ns/iter (± 7243646
)1.00
es/full/codegen/es3
27338
ns/iter (± 44
)27440
ns/iter (± 40
)1.00
es/full/codegen/es5
27310
ns/iter (± 53
)27513
ns/iter (± 49
)0.99
es/full/codegen/es2015
27316
ns/iter (± 39
)27516
ns/iter (± 40
)0.99
es/full/codegen/es2016
27258
ns/iter (± 37
)27484
ns/iter (± 28
)0.99
es/full/codegen/es2017
27366
ns/iter (± 35
)27454
ns/iter (± 43
)1.00
es/full/codegen/es2018
27296
ns/iter (± 37
)27487
ns/iter (± 46
)0.99
es/full/codegen/es2019
27338
ns/iter (± 57
)27530
ns/iter (± 40
)0.99
es/full/codegen/es2020
27291
ns/iter (± 58
)27480
ns/iter (± 37
)0.99
es/full/all/es3
166551369
ns/iter (± 2324597
)167799668
ns/iter (± 1875658
)0.99
es/full/all/es5
158377352
ns/iter (± 1348868
)157142581
ns/iter (± 3502055
)1.01
es/full/all/es2015
118910261
ns/iter (± 759066
)120166192
ns/iter (± 902495
)0.99
es/full/all/es2016
117633050
ns/iter (± 698753
)118520849
ns/iter (± 542854
)0.99
es/full/all/es2017
117200000
ns/iter (± 800425
)117706169
ns/iter (± 977039
)1.00
es/full/all/es2018
115294995
ns/iter (± 749570
)116732374
ns/iter (± 564493
)0.99
es/full/all/es2019
114894506
ns/iter (± 1060860
)115613290
ns/iter (± 1140164
)0.99
es/full/all/es2020
110434503
ns/iter (± 742005
)111478868
ns/iter (± 562029
)0.99
es/full/parser
500817
ns/iter (± 8391
)512444
ns/iter (± 6920
)0.98
es/full/base/fixer
21928
ns/iter (± 122
)22066
ns/iter (± 68
)0.99
es/full/base/resolver_and_hygiene
77659
ns/iter (± 173
)78636
ns/iter (± 216
)0.99
serialization of ast node
138
ns/iter (± 0
)138
ns/iter (± 0
)1
serialization of serde
124
ns/iter (± 0
)124
ns/iter (± 0
)1
css/minify/libraries/bootstrap
26887820
ns/iter (± 102574
)26919346
ns/iter (± 76220
)1.00
css/visitor/compare/clone
2075951
ns/iter (± 9801
)2082848
ns/iter (± 4896
)1.00
css/visitor/compare/visit_mut_span
2273458
ns/iter (± 10834
)2243161
ns/iter (± 5127
)1.01
css/visitor/compare/visit_mut_span_panic
2338348
ns/iter (± 9293
)2297752
ns/iter (± 8713
)1.02
css/visitor/compare/fold_span
3043917
ns/iter (± 31390
)2981484
ns/iter (± 37204
)1.02
css/visitor/compare/fold_span_panic
3168852
ns/iter (± 31699
)3110372
ns/iter (± 11360
)1.02
css/lexer/bootstrap_5_1_3
5192281
ns/iter (± 3829
)5205471
ns/iter (± 36256
)1.00
css/lexer/foundation_6_7_4
4412449
ns/iter (± 2479
)4422622
ns/iter (± 666
)1.00
css/lexer/tailwind_3_1_1
826178
ns/iter (± 2449
)830543
ns/iter (± 479
)0.99
css/parser/bootstrap_5_1_3
20596008
ns/iter (± 67809
)20619402
ns/iter (± 132303
)1.00
css/parser/foundation_6_7_4
16520169
ns/iter (± 85931
)16534417
ns/iter (± 36692
)1.00
css/parser/tailwind_3_1_1
3179605
ns/iter (± 14653
)3197659
ns/iter (± 983
)0.99
es/codegen/colors
332505
ns/iter (± 184587
)332466
ns/iter (± 186799
)1.00
es/codegen/large
1214663
ns/iter (± 638499
)1213847
ns/iter (± 638900
)1.00
es/codegen/with-parser/colors
46525
ns/iter (± 308
)46577
ns/iter (± 390
)1.00
es/codegen/with-parser/large
507275
ns/iter (± 3069
)511041
ns/iter (± 1332
)0.99
es/minify/libraries/antd
1426407874
ns/iter (± 35008575
)1558965036
ns/iter (± 41307947
)0.91
es/minify/libraries/d3
291770407
ns/iter (± 8919424
)295510326
ns/iter (± 4354042
)0.99
es/minify/libraries/echarts
1234274153
ns/iter (± 18205554
)1122750872
ns/iter (± 46174284
)1.10
es/minify/libraries/jquery
78429729
ns/iter (± 462202
)83067135
ns/iter (± 1260605
)0.94
es/minify/libraries/lodash
96527179
ns/iter (± 810436
)101761087
ns/iter (± 973827
)0.95
es/minify/libraries/moment
45601333
ns/iter (± 409756
)47665255
ns/iter (± 482377
)0.96
es/minify/libraries/react
17188800
ns/iter (± 48269
)16853037
ns/iter (± 298960
)1.02
es/minify/libraries/terser
217834267
ns/iter (± 5117316
)208326575
ns/iter (± 2366821
)1.05
es/minify/libraries/three
375739149
ns/iter (± 8066482
)364694851
ns/iter (± 8489963
)1.03
es/minify/libraries/typescript
2667070863
ns/iter (± 17619355
)2574257962
ns/iter (± 10507572
)1.04
es/minify/libraries/victory
650161833
ns/iter (± 5953547
)570466048
ns/iter (± 15295365
)1.14
es/minify/libraries/vue
126373991
ns/iter (± 1633084
)116655060
ns/iter (± 4423715
)1.08
es/visitor/compare/clone
2462465
ns/iter (± 54473
)2438470
ns/iter (± 39319
)1.01
es/visitor/compare/visit_mut_span
2829867
ns/iter (± 5572
)2811265
ns/iter (± 2720
)1.01
es/visitor/compare/visit_mut_span_panic
2870932
ns/iter (± 31975
)2859335
ns/iter (± 3173
)1.00
es/visitor/compare/fold_span
4024262
ns/iter (± 30676
)3963409
ns/iter (± 11429
)1.02
es/visitor/compare/fold_span_panic
4200530
ns/iter (± 62954
)4125503
ns/iter (± 71228
)1.02
es/lexer/colors
17202
ns/iter (± 8
)17170
ns/iter (± 14
)1.00
es/lexer/angular
8242882
ns/iter (± 7031
)8213584
ns/iter (± 11472
)1.00
es/lexer/backbone
1072940
ns/iter (± 1007
)1069540
ns/iter (± 392
)1.00
es/lexer/jquery
5954217
ns/iter (± 4914
)5937745
ns/iter (± 4234
)1.00
es/lexer/jquery mobile
9170690
ns/iter (± 76548
)9141494
ns/iter (± 4421
)1.00
es/lexer/mootools
4666905
ns/iter (± 1661
)4659290
ns/iter (± 2615
)1.00
es/lexer/underscore
895575
ns/iter (± 432
)893837
ns/iter (± 497
)1.00
es/lexer/three
27956337
ns/iter (± 21218
)27835717
ns/iter (± 12550
)1.00
es/lexer/yui
5057986
ns/iter (± 4264
)5030143
ns/iter (± 3750
)1.01
es/parser/colors
31100
ns/iter (± 87
)31414
ns/iter (± 101
)0.99
es/parser/angular
16296176
ns/iter (± 221851
)15815396
ns/iter (± 99112
)1.03
es/parser/backbone
2307745
ns/iter (± 15186
)2305423
ns/iter (± 6601
)1.00
es/parser/jquery
12509076
ns/iter (± 173857
)12401949
ns/iter (± 47305
)1.01
es/parser/jquery mobile
20019512
ns/iter (± 245125
)19615981
ns/iter (± 96056
)1.02
es/parser/mootools
9518618
ns/iter (± 38550
)9503324
ns/iter (± 21482
)1.00
es/parser/underscore
1970016
ns/iter (± 13241
)1962407
ns/iter (± 11597
)1.00
es/parser/three
58861235
ns/iter (± 988584
)57345315
ns/iter (± 574452
)1.03
es/parser/yui
9668789
ns/iter (± 59036
)9561154
ns/iter (± 45923
)1.01
es/preset-env/usage/builtin_type
139745
ns/iter (± 32025
)139559
ns/iter (± 31145
)1.00
es/preset-env/usage/property
21622
ns/iter (± 116
)21032
ns/iter (± 58
)1.03
es/resolver/typescript
112657650
ns/iter (± 5869324
)109129948
ns/iter (± 1636515
)1.03
es/fixer/typescript
88737974
ns/iter (± 3462499
)86634818
ns/iter (± 3510518
)1.02
es/hygiene/typescript
174923076
ns/iter (± 1264461
)168819139
ns/iter (± 1081812
)1.04
es/resolver_with_hygiene/typescript
303966080
ns/iter (± 2716871
)302860220
ns/iter (± 2130832
)1.00
es/visitor/base-perf/module_clone
76881
ns/iter (± 926
)76590
ns/iter (± 1809
)1.00
es/visitor/base-perf/fold_empty
84810
ns/iter (± 1205
)86029
ns/iter (± 433
)0.99
es/visitor/base-perf/fold_noop_impl_all
85526
ns/iter (± 1294
)86448
ns/iter (± 1163
)0.99
es/visitor/base-perf/fold_noop_impl_vec
85464
ns/iter (± 1275
)86534
ns/iter (± 1487
)0.99
es/visitor/base-perf/boxing_boxed_clone
56
ns/iter (± 0
)56
ns/iter (± 0
)1
es/visitor/base-perf/boxing_unboxed_clone
59
ns/iter (± 0
)59
ns/iter (± 0
)1
es/visitor/base-perf/boxing_boxed
102
ns/iter (± 0
)102
ns/iter (± 0
)1
es/visitor/base-perf/boxing_unboxed
103
ns/iter (± 0
)102
ns/iter (± 0
)1.01
es/visitor/base-perf/visit_contains_this
3532
ns/iter (± 53
)3588
ns/iter (± 56
)0.98
es/base/parallel/resolver/typescript
5417307049
ns/iter (± 559709080
)5347031256
ns/iter (± 388772925
)1.01
es/base/parallel/hygiene/typescript
2019229736
ns/iter (± 29826157
)1993638482
ns/iter (± 24039035
)1.01
misc/visitors/time-complexity/time 5
94
ns/iter (± 0
)93
ns/iter (± 0
)1.01
misc/visitors/time-complexity/time 10
324
ns/iter (± 0
)328
ns/iter (± 4
)0.99
misc/visitors/time-complexity/time 15
649
ns/iter (± 13
)634
ns/iter (± 0
)1.02
misc/visitors/time-complexity/time 20
1217
ns/iter (± 5
)1197
ns/iter (± 4
)1.02
misc/visitors/time-complexity/time 40
6171
ns/iter (± 20
)6144
ns/iter (± 1
)1.00
misc/visitors/time-complexity/time 60
15504
ns/iter (± 27
)15517
ns/iter (± 24
)1.00
es/full-target/es2016
188499
ns/iter (± 1045
)188333
ns/iter (± 428
)1.00
es/full-target/es2017
182801
ns/iter (± 574
)183372
ns/iter (± 397
)1.00
es/full-target/es2018
171970
ns/iter (± 311
)172652
ns/iter (± 620
)1.00
es2020_nullish_coalescing
66432
ns/iter (± 152
)66805
ns/iter (± 4960
)0.99
es2020_optional_chaining
95684
ns/iter (± 281
)96327
ns/iter (± 6612
)0.99
es2022_class_properties
92974
ns/iter (± 125
)93971
ns/iter (± 207
)0.99
es2018_object_rest_spread
71432
ns/iter (± 142
)71921
ns/iter (± 196
)0.99
es2019_optional_catch_binding
60902
ns/iter (± 116
)61421
ns/iter (± 242
)0.99
es2017_async_to_generator
61542
ns/iter (± 193
)61866
ns/iter (± 182
)0.99
es2016_exponentiation
64302
ns/iter (± 153
)65405
ns/iter (± 104
)0.98
es2015_arrow
70195
ns/iter (± 247
)70817
ns/iter (± 176
)0.99
es2015_block_scoped_fn
65728
ns/iter (± 99
)66246
ns/iter (± 144
)0.99
es2015_block_scoping
152273
ns/iter (± 9926
)151173
ns/iter (± 10838
)1.01
es2015_classes
116749
ns/iter (± 483
)116761
ns/iter (± 358
)1.00
es2015_computed_props
61249
ns/iter (± 131
)61484
ns/iter (± 150
)1.00
es2015_destructuring
115586
ns/iter (± 501
)116532
ns/iter (± 288
)0.99
es2015_duplicate_keys
63812
ns/iter (± 104
)64175
ns/iter (± 60
)0.99
es2015_parameters
79481
ns/iter (± 205
)80367
ns/iter (± 169
)0.99
es2015_fn_name
66330
ns/iter (± 442
)66767
ns/iter (± 406
)0.99
es2015_for_of
63789
ns/iter (± 158
)64403
ns/iter (± 115
)0.99
es2015_instanceof
63006
ns/iter (± 155
)63419
ns/iter (± 83
)0.99
es2015_shorthand_property
60640
ns/iter (± 186
)61212
ns/iter (± 66
)0.99
es2015_spread
60779
ns/iter (± 236
)61206
ns/iter (± 133
)0.99
es2015_sticky_regex
61598
ns/iter (± 404
)62808
ns/iter (± 98
)0.98
es2015_typeof_symbol
61235
ns/iter (± 363
)62592
ns/iter (± 91
)0.98
es/transform/baseline/base
50836
ns/iter (± 337
)51968
ns/iter (± 136
)0.98
es/transform/baseline/common_reserved_word
61213
ns/iter (± 645
)62745
ns/iter (± 178
)0.98
es/transform/baseline/common_typescript
168027
ns/iter (± 9919
)169862
ns/iter (± 200
)0.99
es/target/es3
168926
ns/iter (± 317
)169868
ns/iter (± 369
)0.99
es/target/es2015
628567
ns/iter (± 940
)633147
ns/iter (± 3155
)0.99
es/target/es2016
64598
ns/iter (± 119
)65300
ns/iter (± 153
)0.99
es/target/es2017
61544
ns/iter (± 63
)61979
ns/iter (± 157
)0.99
es/target/es2018
81707
ns/iter (± 153
)81769
ns/iter (± 98
)1.00
es/target/es2020
132298
ns/iter (± 423
)132736
ns/iter (± 136
)1.00
babelify-only
676449
ns/iter (± 5412
)672293
ns/iter (± 995
)1.01
parse_and_babelify_angular
43617700
ns/iter (± 1323660
)42328559
ns/iter (± 1187386
)1.03
parse_and_babelify_backbone
5487939
ns/iter (± 46905
)5356164
ns/iter (± 28162
)1.02
parse_and_babelify_jquery
32504788
ns/iter (± 447983
)31530283
ns/iter (± 320228
)1.03
parse_and_babelify_jquery_mobile
55565622
ns/iter (± 1072970
)53394251
ns/iter (± 655577
)1.04
parse_and_babelify_mootools
33313681
ns/iter (± 432095
)32373073
ns/iter (± 349943
)1.03
parse_and_babelify_underscore
4370814
ns/iter (± 25748
)4341349
ns/iter (± 141993
)1.01
parse_and_babelify_yui
32557445
ns/iter (± 515317
)30838423
ns/iter (± 353773
)1.06
html/minify/document/css_spec
42067483
ns/iter (± 289318
)41753992
ns/iter (± 626432
)1.01
html/minify/document/github
17501483
ns/iter (± 46000
)17237361
ns/iter (± 33008
)1.02
html/minify/document/stackoverflow
15491201
ns/iter (± 48719
)15567762
ns/iter (± 43955
)1.00
html/minify/document_fragment/css_spec
39677040
ns/iter (± 257148
)39754401
ns/iter (± 383066
)1.00
html/minify/document_fragment/github
16734193
ns/iter (± 72746
)16613414
ns/iter (± 168150
)1.01
html/minify/document_fragment/stackoverflow
15151481
ns/iter (± 78267
)15080906
ns/iter (± 35267
)1.00
html/document/visitor/compare/clone
337130
ns/iter (± 2597
)339947
ns/iter (± 1842
)0.99
html/document/visitor/compare/visit_mut_span
362307
ns/iter (± 1419
)361693
ns/iter (± 1744
)1.00
html/document/visitor/compare/visit_mut_span_panic
373646
ns/iter (± 1167
)374921
ns/iter (± 3235
)1.00
html/document/visitor/compare/fold_span
398408
ns/iter (± 1779
)403585
ns/iter (± 1955
)0.99
html/document/visitor/compare/fold_span_panic
465858
ns/iter (± 1782
)455176
ns/iter (± 2087
)1.02
html/document_fragment/visitor/compare/clone
337247
ns/iter (± 1851
)333618
ns/iter (± 2157
)1.01
html/document_fragment/visitor/compare/visit_mut_span
365285
ns/iter (± 2376
)365031
ns/iter (± 2283
)1.00
html/document_fragment/visitor/compare/visit_mut_span_panic
375328
ns/iter (± 3124
)368830
ns/iter (± 1692
)1.02
html/document_fragment/visitor/compare/fold_span
399443
ns/iter (± 1518
)403702
ns/iter (± 1883
)0.99
html/document_fragment/visitor/compare/fold_span_panic
457163
ns/iter (± 2796
)454263
ns/iter (± 1610
)1.01
html/lexer/css_2021_spec
15536961
ns/iter (± 31091
)15494293
ns/iter (± 17337
)1.00
html/lexer/github_com_17_05_2022
6040970
ns/iter (± 14460
)6005660
ns/iter (± 5578
)1.01
html/lexer/stackoverflow_com_17_05_2022
5616909
ns/iter (± 1670
)5603026
ns/iter (± 7744
)1.00
html/parser/parser_document/css_2021_spec
26651772
ns/iter (± 392650
)25889167
ns/iter (± 303429
)1.03
html/parser/parser_document/github_com_17_05_2022
8797885
ns/iter (± 33020
)8764073
ns/iter (± 4372
)1.00
html/parser/parser_document/stackoverflow_com_17_05_2022
7710602
ns/iter (± 49959
)7737208
ns/iter (± 22563
)1.00
html/parser/parser_document_fragment/css_2021_spec
25755418
ns/iter (± 212978
)25885643
ns/iter (± 182856
)0.99
html/parser/parser_document_fragment/github_com_17_05_2022
8816610
ns/iter (± 15131
)8757094
ns/iter (± 5342
)1.01
html/parser/parser_document_fragment/stackoverflow_com_17_05_2022
7715076
ns/iter (± 11361
)7711193
ns/iter (± 4434
)1.00
This comment was automatically generated by workflow using github-action-benchmark.