-
-
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/compat): Use
async
and await
correctly in block-scoping
…
- Loading branch information
Showing
6 changed files
with
79 additions
and
13 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,24 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript", | ||
"jsx": false | ||
}, | ||
"loose": false, | ||
"minify": { | ||
"compress": false, | ||
"mangle": false, | ||
"format": { | ||
"comments": "all" | ||
} | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"minify": false, | ||
"isModule": true, | ||
"env": { | ||
"targets": "supports async-functions" | ||
} | ||
} |
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 @@ | ||
async function foo(a, b) { | ||
for (let i = 0; i < 5; i++) { | ||
const boo = await a(); | ||
b(() => boo) | ||
} | ||
} |
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,7 @@ | ||
async function foo(a, b) { | ||
var _loop = async function(i) { | ||
var boo = await a(); | ||
b(()=>boo); | ||
}; | ||
for(var i = 0; i < 5; i++)await _loop(i); | ||
} |
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
6 changes: 6 additions & 0 deletions
6
crates/swc_ecma_transforms_compat/tests/block-scoping/issue-7989/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 @@ | ||
async function foo(a, b) { | ||
for (let i = 0; i < 5; i++) { | ||
const boo = await a(); | ||
b(() => boo) | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
crates/swc_ecma_transforms_compat/tests/block-scoping/issue-7989/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,7 @@ | ||
async function foo__2(a__3, b__3) { | ||
var _loop__6 = async function(i__4) { | ||
var boo__5 = await a__3(); | ||
b__3(()=>boo__5); | ||
}; | ||
for(var i__4 = 0; i__4 < 5; i__4++)await _loop__6(i__4); | ||
} |
8318ea8
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
273215
ns/iter (± 3807
)277833
ns/iter (± 5957
)0.98
es/full/minify/libraries/antd
1308437156
ns/iter (± 19160635
)1315453138
ns/iter (± 5262929
)0.99
es/full/minify/libraries/d3
270678444
ns/iter (± 3126234
)287366028
ns/iter (± 7212246
)0.94
es/full/minify/libraries/echarts
1041894723
ns/iter (± 8806873
)1050258731
ns/iter (± 7499031
)0.99
es/full/minify/libraries/jquery
83284971
ns/iter (± 134508
)84348807
ns/iter (± 293647
)0.99
es/full/minify/libraries/lodash
96542692
ns/iter (± 935417
)97891776
ns/iter (± 505731
)0.99
es/full/minify/libraries/moment
49447384
ns/iter (± 113482
)49991198
ns/iter (± 92971
)0.99
es/full/minify/libraries/react
17884505
ns/iter (± 28511
)18044672
ns/iter (± 51497
)0.99
es/full/minify/libraries/terser
215348630
ns/iter (± 1018931
)218019297
ns/iter (± 788292
)0.99
es/full/minify/libraries/three
380737079
ns/iter (± 2328222
)384113257
ns/iter (± 2838047
)0.99
es/full/minify/libraries/typescript
2566953718
ns/iter (± 14698786
)2654667541
ns/iter (± 8719701
)0.97
es/full/minify/libraries/victory
557997694
ns/iter (± 3247628
)565656105
ns/iter (± 4851121
)0.99
es/full/minify/libraries/vue
117457437
ns/iter (± 285203
)119145169
ns/iter (± 438108
)0.99
es/full/codegen/es3
34642
ns/iter (± 132
)34990
ns/iter (± 74
)0.99
es/full/codegen/es5
34645
ns/iter (± 111
)34883
ns/iter (± 56
)0.99
es/full/codegen/es2015
34696
ns/iter (± 120
)34946
ns/iter (± 125
)0.99
es/full/codegen/es2016
34722
ns/iter (± 114
)34889
ns/iter (± 115
)1.00
es/full/codegen/es2017
34705
ns/iter (± 68
)34908
ns/iter (± 48
)0.99
es/full/codegen/es2018
34682
ns/iter (± 112
)34990
ns/iter (± 123
)0.99
es/full/codegen/es2019
34645
ns/iter (± 94
)34970
ns/iter (± 104
)0.99
es/full/codegen/es2020
34695
ns/iter (± 95
)34996
ns/iter (± 105
)0.99
es/full/all/es3
166033412
ns/iter (± 1005481
)164994483
ns/iter (± 1442444
)1.01
es/full/all/es5
157590970
ns/iter (± 1153631
)158121658
ns/iter (± 1041097
)1.00
es/full/all/es2015
116367137
ns/iter (± 774187
)117656178
ns/iter (± 1027051
)0.99
es/full/all/es2016
116207870
ns/iter (± 412454
)116266336
ns/iter (± 1367325
)1.00
es/full/all/es2017
115234523
ns/iter (± 585119
)115513112
ns/iter (± 583101
)1.00
es/full/all/es2018
112779888
ns/iter (± 737765
)114083148
ns/iter (± 1121684
)0.99
es/full/all/es2019
112824110
ns/iter (± 311244
)112838529
ns/iter (± 436015
)1.00
es/full/all/es2020
108275991
ns/iter (± 702679
)109306000
ns/iter (± 913711
)0.99
es/full/parser
488985
ns/iter (± 5137
)489804
ns/iter (± 5783
)1.00
es/full/base/fixer
20347
ns/iter (± 343
)19055
ns/iter (± 208
)1.07
es/full/base/resolver_and_hygiene
82203
ns/iter (± 126
)80324
ns/iter (± 119
)1.02
This comment was automatically generated by workflow using github-action-benchmark.