-
-
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): Do not inline into a template literal with sequenti…
- Loading branch information
Showing
10 changed files
with
185 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript", | ||
"jsx": false | ||
}, | ||
"target": "es2015", | ||
"loose": false, | ||
"minify": { | ||
"compress": { | ||
"arguments": false, | ||
"arrows": true, | ||
"booleans": true, | ||
"booleans_as_integers": false, | ||
"collapse_vars": true, | ||
"comparisons": true, | ||
"computed_props": true, | ||
"conditionals": true, | ||
"dead_code": true, | ||
"directives": true, | ||
"drop_console": false, | ||
"drop_debugger": true, | ||
"evaluate": true, | ||
"expression": false, | ||
"hoist_funs": false, | ||
"hoist_props": true, | ||
"hoist_vars": false, | ||
"if_return": true, | ||
"join_vars": true, | ||
"keep_classnames": false, | ||
"keep_fargs": true, | ||
"keep_fnames": false, | ||
"keep_infinity": false, | ||
"loops": true, | ||
"negate_iife": true, | ||
"properties": true, | ||
"reduce_funcs": false, | ||
"reduce_vars": false, | ||
"side_effects": true, | ||
"switches": true, | ||
"typeofs": true, | ||
"unsafe": false, | ||
"unsafe_arrows": false, | ||
"unsafe_comps": false, | ||
"unsafe_Function": false, | ||
"unsafe_math": false, | ||
"unsafe_symbols": false, | ||
"unsafe_methods": false, | ||
"unsafe_proto": false, | ||
"unsafe_regexp": false, | ||
"unsafe_undefined": false, | ||
"unused": true, | ||
"const_to_let": true, | ||
"pristine_globals": true, | ||
"passes": 1 | ||
}, | ||
"mangle": { | ||
"toplevel": false, | ||
"keep_classnames": false, | ||
"keep_fnames": false, | ||
"keep_private_props": false, | ||
"ie8": false, | ||
"safari10": false | ||
} | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"minify": true, | ||
"isModule": true | ||
} |
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,14 @@ | ||
let a = 0; | ||
function f(arr) { | ||
let b = a; | ||
return `${arr.map((child) => { | ||
a = b + "str"; | ||
})}`; | ||
} | ||
|
||
function g(arr) { | ||
return f(arr); | ||
} | ||
globalThis.g = g; | ||
g([1, 2, 3]) | ||
console.log(a); |
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 @@ | ||
let a=0;function g(l){var o;let t;return o=l,t=a,`${o.map(l=>{a=t+"str"})}`}globalThis.g=g,g([1,2,3]),console.log(a); |
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
3 changes: 2 additions & 1 deletion
3
...sts/tsc-references/taggedTemplateStringsWithManyCallAndMemberExpressionsES6.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,3 @@ | ||
//// [taggedTemplateStringsWithManyCallAndMemberExpressionsES6.ts] | ||
new new new (void 0)`abc${0}def`.member("hello")(42); | ||
var f; | ||
new new new f`abc${0}def`.member("hello")(42); |
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
46 changes: 46 additions & 0 deletions
46
crates/swc_ecma_minifier/tests/fixture/issues/7969/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,46 @@ | ||
{ | ||
"arguments": false, | ||
"arrows": true, | ||
"booleans": true, | ||
"booleans_as_integers": false, | ||
"collapse_vars": true, | ||
"comparisons": true, | ||
"computed_props": true, | ||
"conditionals": true, | ||
"dead_code": true, | ||
"directives": true, | ||
"drop_console": false, | ||
"drop_debugger": true, | ||
"evaluate": true, | ||
"expression": false, | ||
"hoist_funs": false, | ||
"hoist_props": true, | ||
"hoist_vars": false, | ||
"if_return": true, | ||
"join_vars": true, | ||
"keep_classnames": false, | ||
"keep_fargs": true, | ||
"keep_fnames": false, | ||
"keep_infinity": false, | ||
"loops": true, | ||
"negate_iife": true, | ||
"properties": true, | ||
"reduce_funcs": false, | ||
"reduce_vars": false, | ||
"side_effects": true, | ||
"switches": true, | ||
"typeofs": true, | ||
"unsafe": false, | ||
"unsafe_arrows": false, | ||
"unsafe_comps": false, | ||
"unsafe_Function": false, | ||
"unsafe_math": false, | ||
"unsafe_symbols": false, | ||
"unsafe_methods": false, | ||
"unsafe_proto": false, | ||
"unsafe_regexp": false, | ||
"unsafe_undefined": false, | ||
"unused": true, | ||
"const_to_let": true, | ||
"pristine_globals": true | ||
} |
14 changes: 14 additions & 0 deletions
14
crates/swc_ecma_minifier/tests/fixture/issues/7969/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,14 @@ | ||
let a = 0; | ||
function f(arr) { | ||
let b = a; | ||
return `${arr.map((child) => { | ||
a = b + "str"; | ||
})}`; | ||
} | ||
|
||
function g(arr) { | ||
return f(arr); | ||
} | ||
globalThis.g = g; | ||
g([1, 2, 3]) | ||
console.log(a); |
17 changes: 17 additions & 0 deletions
17
crates/swc_ecma_minifier/tests/fixture/issues/7969/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,17 @@ | ||
let a = 0; | ||
function f(arr) { | ||
let b = a; | ||
return `${arr.map((child)=>{ | ||
a = b + "str"; | ||
})}`; | ||
} | ||
function g(arr) { | ||
return f(arr); | ||
} | ||
globalThis.g = g; | ||
g([ | ||
1, | ||
2, | ||
3 | ||
]); | ||
console.log(a); |
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
b3d3a7b
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
286886
ns/iter (± 6299
)294861
ns/iter (± 9165
)0.97
es/full/minify/libraries/antd
1280831070
ns/iter (± 8690557
)1276729406
ns/iter (± 6433417
)1.00
es/full/minify/libraries/d3
273433265
ns/iter (± 4512194
)272276297
ns/iter (± 2833951
)1.00
es/full/minify/libraries/echarts
1017957232
ns/iter (± 5231996
)1024309245
ns/iter (± 3576884
)0.99
es/full/minify/libraries/jquery
83047561
ns/iter (± 118117
)83119981
ns/iter (± 130791
)1.00
es/full/minify/libraries/lodash
96159626
ns/iter (± 194911
)95894352
ns/iter (± 274397
)1.00
es/full/minify/libraries/moment
49107041
ns/iter (± 61522
)49178211
ns/iter (± 52541
)1.00
es/full/minify/libraries/react
17815133
ns/iter (± 33370
)17816917
ns/iter (± 36460
)1.00
es/full/minify/libraries/terser
213711347
ns/iter (± 505964
)213336424
ns/iter (± 976260
)1.00
es/full/minify/libraries/three
377898638
ns/iter (± 891271
)379062294
ns/iter (± 1640820
)1.00
es/full/minify/libraries/typescript
2583859208
ns/iter (± 10052705
)2583855773
ns/iter (± 9065923
)1.00
es/full/minify/libraries/victory
550200784
ns/iter (± 2526255
)553200056
ns/iter (± 3491556
)0.99
es/full/minify/libraries/vue
117807924
ns/iter (± 224833
)117926132
ns/iter (± 329741
)1.00
es/full/codegen/es3
34019
ns/iter (± 84
)34330
ns/iter (± 111
)0.99
es/full/codegen/es5
34031
ns/iter (± 58
)34300
ns/iter (± 192
)0.99
es/full/codegen/es2015
33969
ns/iter (± 77
)34350
ns/iter (± 146
)0.99
es/full/codegen/es2016
33871
ns/iter (± 82
)34317
ns/iter (± 147
)0.99
es/full/codegen/es2017
34003
ns/iter (± 115
)34314
ns/iter (± 148
)0.99
es/full/codegen/es2018
34015
ns/iter (± 49
)34240
ns/iter (± 114
)0.99
es/full/codegen/es2019
34036
ns/iter (± 130
)34193
ns/iter (± 163
)1.00
es/full/codegen/es2020
34025
ns/iter (± 109
)34229
ns/iter (± 261
)0.99
es/full/all/es3
168407277
ns/iter (± 1638634
)166367449
ns/iter (± 1152490
)1.01
es/full/all/es5
159229894
ns/iter (± 934335
)159051180
ns/iter (± 798895
)1.00
es/full/all/es2015
119489798
ns/iter (± 663427
)118748669
ns/iter (± 610255
)1.01
es/full/all/es2016
117978914
ns/iter (± 1003334
)117773786
ns/iter (± 680979
)1.00
es/full/all/es2017
118327526
ns/iter (± 1438429
)117092917
ns/iter (± 596829
)1.01
es/full/all/es2018
115939010
ns/iter (± 1239135
)115214440
ns/iter (± 750024
)1.01
es/full/all/es2019
114689955
ns/iter (± 647582
)114551411
ns/iter (± 693667
)1.00
es/full/all/es2020
110566140
ns/iter (± 440831
)110075088
ns/iter (± 597088
)1.00
es/full/parser
487871
ns/iter (± 4949
)485703
ns/iter (± 4702
)1.00
es/full/base/fixer
20659
ns/iter (± 89
)17637
ns/iter (± 80
)1.17
es/full/base/resolver_and_hygiene
82370
ns/iter (± 368
)78285
ns/iter (± 501
)1.05
serialization of serde
299
ns/iter (± 0
)296
ns/iter (± 1
)1.01
css/minify/libraries/bootstrap
28415042
ns/iter (± 39724
)28407070
ns/iter (± 56049
)1.00
css/visitor/compare/clone
1642276
ns/iter (± 2151
)1660482
ns/iter (± 6364
)0.99
css/visitor/compare/visit_mut_span
1772999
ns/iter (± 3476
)1784743
ns/iter (± 9225
)0.99
css/visitor/compare/visit_mut_span_panic
1860192
ns/iter (± 5057
)1830669
ns/iter (± 6619
)1.02
css/visitor/compare/fold_span
2580176
ns/iter (± 10854
)2561000
ns/iter (± 10057
)1.01
css/visitor/compare/fold_span_panic
2766375
ns/iter (± 15074
)2765193
ns/iter (± 11132
)1.00
css/lexer/bootstrap_5_1_3
4439354
ns/iter (± 7113
)4590623
ns/iter (± 4634
)0.97
css/lexer/foundation_6_7_4
3731274
ns/iter (± 7762
)3875618
ns/iter (± 2120
)0.96
css/lexer/tailwind_3_1_1
708835
ns/iter (± 464
)735101
ns/iter (± 1881
)0.96
css/parser/bootstrap_5_1_3
19521899
ns/iter (± 86828
)19379404
ns/iter (± 121540
)1.01
css/parser/foundation_6_7_4
15422977
ns/iter (± 24029
)15268986
ns/iter (± 82275
)1.01
css/parser/tailwind_3_1_1
2983275
ns/iter (± 5362
)2960867
ns/iter (± 18160
)1.01
es/codegen/colors
728618
ns/iter (± 397204
)727632
ns/iter (± 395770
)1.00
es/codegen/large
3131327
ns/iter (± 1665572
)3139585
ns/iter (± 1657343
)1.00
es/codegen/with-parser/colors
44995
ns/iter (± 495
)44842
ns/iter (± 311
)1.00
es/codegen/with-parser/large
488519
ns/iter (± 865
)489468
ns/iter (± 1639
)1.00
es/minify/libraries/antd
1122004852
ns/iter (± 10030039
)1114139376
ns/iter (± 8708410
)1.01
es/minify/libraries/d3
237599643
ns/iter (± 371889
)237334296
ns/iter (± 250182
)1.00
es/minify/libraries/echarts
879861196
ns/iter (± 2899891
)885579997
ns/iter (± 4849284
)0.99
es/minify/libraries/jquery
72903042
ns/iter (± 94737
)73140243
ns/iter (± 136805
)1.00
es/minify/libraries/lodash
86836419
ns/iter (± 162207
)86845966
ns/iter (± 150377
)1.00
es/minify/libraries/moment
43175817
ns/iter (± 42122
)43454350
ns/iter (± 68708
)0.99
es/minify/libraries/react
15993196
ns/iter (± 25938
)16020955
ns/iter (± 24628
)1.00
es/minify/libraries/terser
184753829
ns/iter (± 320259
)184473716
ns/iter (± 244642
)1.00
es/minify/libraries/three
316714995
ns/iter (± 650530
)317700061
ns/iter (± 772631
)1.00
es/minify/libraries/typescript
2201499311
ns/iter (± 6968000
)2204186727
ns/iter (± 4921868
)1.00
es/minify/libraries/victory
470648405
ns/iter (± 1358203
)464402458
ns/iter (± 969505
)1.01
es/minify/libraries/vue
105130218
ns/iter (± 161808
)105819565
ns/iter (± 136981
)0.99
es/visitor/compare/clone
1932371
ns/iter (± 4230
)1929407
ns/iter (± 24061
)1.00
es/visitor/compare/visit_mut_span
2268748
ns/iter (± 2542
)2274793
ns/iter (± 7965
)1.00
es/visitor/compare/visit_mut_span_panic
2325960
ns/iter (± 3920
)2308889
ns/iter (± 11366
)1.01
es/visitor/compare/fold_span
3361531
ns/iter (± 5810
)3339712
ns/iter (± 5599
)1.01
es/visitor/compare/fold_span_panic
3493679
ns/iter (± 7652
)3498960
ns/iter (± 20230
)1.00
es/lexer/colors
12882
ns/iter (± 29
)12907
ns/iter (± 59
)1.00
es/lexer/angular
6097854
ns/iter (± 11787
)6015281
ns/iter (± 26324
)1.01
es/lexer/backbone
776252
ns/iter (± 2504
)773723
ns/iter (± 3320
)1.00
es/lexer/jquery
4465378
ns/iter (± 16399
)4421781
ns/iter (± 24425
)1.01
es/lexer/jquery mobile
6786456
ns/iter (± 19277
)6766376
ns/iter (± 64562
)1.00
es/lexer/mootools
3551894
ns/iter (± 13279
)3503038
ns/iter (± 21051
)1.01
es/lexer/underscore
658402
ns/iter (± 3658
)645659
ns/iter (± 3394
)1.02
es/lexer/three
21344793
ns/iter (± 26041
)21033433
ns/iter (± 175829
)1.01
es/lexer/yui
3783477
ns/iter (± 11012
)3781558
ns/iter (± 13076
)1.00
es/parser/colors
27255
ns/iter (± 206
)27022
ns/iter (± 128
)1.01
es/parser/angular
13429081
ns/iter (± 46099
)13417903
ns/iter (± 58020
)1.00
es/parser/backbone
1977842
ns/iter (± 8146
)1967509
ns/iter (± 9559
)1.01
es/parser/jquery
10792994
ns/iter (± 35635
)10767250
ns/iter (± 27093
)1.00
es/parser/jquery mobile
16587359
ns/iter (± 41200
)16419099
ns/iter (± 59950
)1.01
es/parser/mootools
8326966
ns/iter (± 17904
)8309593
ns/iter (± 19903
)1.00
es/parser/underscore
1695115
ns/iter (± 8876
)1691918
ns/iter (± 11829
)1.00
es/parser/three
46381167
ns/iter (± 173460
)46195637
ns/iter (± 195110
)1.00
es/parser/yui
8212332
ns/iter (± 26583
)8240327
ns/iter (± 59344
)1.00
es/preset-env/usage/builtin_type
137495
ns/iter (± 33081
)135935
ns/iter (± 33012
)1.01
es/preset-env/usage/property
16332
ns/iter (± 99
)16094
ns/iter (± 180
)1.01
es/resolver/typescript
89837524
ns/iter (± 1247573
)87976309
ns/iter (± 943216
)1.02
es/fixer/typescript
63533513
ns/iter (± 334373
)62473404
ns/iter (± 553066
)1.02
es/hygiene/typescript
129586045
ns/iter (± 391645
)127933552
ns/iter (± 522901
)1.01
es/resolver_with_hygiene/typescript
241327438
ns/iter (± 857015
)239395377
ns/iter (± 1654189
)1.01
es/visitor/base-perf/module_clone
59846
ns/iter (± 210
)58736
ns/iter (± 577
)1.02
es/visitor/base-perf/fold_empty
62906
ns/iter (± 142
)62565
ns/iter (± 448
)1.01
es/visitor/base-perf/fold_noop_impl_all
63440
ns/iter (± 376
)62976
ns/iter (± 498
)1.01
es/visitor/base-perf/fold_noop_impl_vec
63357
ns/iter (± 340
)62803
ns/iter (± 535
)1.01
es/visitor/base-perf/boxing_boxed_clone
56
ns/iter (± 0
)56
ns/iter (± 0
)1
es/visitor/base-perf/boxing_unboxed_clone
39
ns/iter (± 0
)40
ns/iter (± 0
)0.97
es/visitor/base-perf/boxing_boxed
106
ns/iter (± 0
)105
ns/iter (± 0
)1.01
es/visitor/base-perf/boxing_unboxed
75
ns/iter (± 0
)76
ns/iter (± 0
)0.99
es/visitor/base-perf/visit_empty
0
ns/iter (± 0
)0
ns/iter (± 0
)NaN
es/visitor/base-perf/visit_contains_this
2548
ns/iter (± 10
)2536
ns/iter (± 12
)1.00
es/base/parallel/resolver/typescript
3802314304
ns/iter (± 252032441
)4285647758
ns/iter (± 203741328
)0.89
es/base/parallel/hygiene/typescript
1470554017
ns/iter (± 15579213
)1441749326
ns/iter (± 10948960
)1.02
misc/visitors/time-complexity/time 5
149
ns/iter (± 0
)149
ns/iter (± 0
)1
misc/visitors/time-complexity/time 10
439
ns/iter (± 4
)421
ns/iter (± 2
)1.04
misc/visitors/time-complexity/time 15
797
ns/iter (± 2
)789
ns/iter (± 1
)1.01
misc/visitors/time-complexity/time 20
1282
ns/iter (± 41
)1432
ns/iter (± 0
)0.90
misc/visitors/time-complexity/time 40
5258
ns/iter (± 6
)4343
ns/iter (± 10
)1.21
misc/visitors/time-complexity/time 60
9413
ns/iter (± 900
)10586
ns/iter (± 70
)0.89
es/full-target/es2016
229247
ns/iter (± 515
)230569
ns/iter (± 758
)0.99
es/full-target/es2017
217790
ns/iter (± 374
)218678
ns/iter (± 612
)1.00
es/full-target/es2018
206368
ns/iter (± 757
)207347
ns/iter (± 1730
)1.00
es2020_nullish_coalescing
69242
ns/iter (± 573
)69605
ns/iter (± 318
)0.99
es2020_optional_chaining
75210
ns/iter (± 6158
)75773
ns/iter (± 246
)0.99
es2022_class_properties
113688
ns/iter (± 498
)115388
ns/iter (± 281
)0.99
es2018_object_rest_spread
73476
ns/iter (± 275
)73498
ns/iter (± 137
)1.00
es2019_optional_catch_binding
62967
ns/iter (± 223
)63409
ns/iter (± 263
)0.99
es2017_async_to_generator
62655
ns/iter (± 274
)62735
ns/iter (± 426
)1.00
es2016_exponentiation
67133
ns/iter (± 181
)67933
ns/iter (± 189
)0.99
es2015_arrow
69811
ns/iter (± 271
)70488
ns/iter (± 344
)0.99
es2015_block_scoped_fn
66963
ns/iter (± 272
)68100
ns/iter (± 214
)0.98
es2015_block_scoping
118211
ns/iter (± 564
)120231
ns/iter (± 408
)0.98
This comment was automatically generated by workflow using github-action-benchmark.