-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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): Fix span hygiene of function naming pass (#6345)
**Related issue:** - Closes #6344.
- Loading branch information
Showing
35 changed files
with
469 additions
and
112 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,26 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript", | ||
"jsx": false | ||
}, | ||
"target": "es5", | ||
"loose": false, | ||
"minify": { | ||
"compress": false, | ||
"mangle": { | ||
"toplevel": false, | ||
"keep_classnames": false, | ||
"keep_fnames": false, | ||
"keep_private_props": false, | ||
"ie8": false, | ||
"safari10": false | ||
} | ||
} | ||
}, | ||
"module": { | ||
"type": "commonjs" | ||
}, | ||
"minify": false, | ||
"isModule": true | ||
} |
21 changes: 21 additions & 0 deletions
21
crates/swc/tests/fixture/issues-6xxx/6345/1/input/index.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,21 @@ | ||
function a() { } | ||
var te = function () { | ||
function n(e) { } | ||
var t = null; | ||
return { | ||
init: function (e) { | ||
return t = new n(e); | ||
} | ||
} | ||
}(); | ||
var he = function () { | ||
function n() { | ||
a(); | ||
}; | ||
var t = null; | ||
return { | ||
init: function (e) { | ||
return t | ||
} | ||
} | ||
}(); |
23 changes: 23 additions & 0 deletions
23
crates/swc/tests/fixture/issues-6xxx/6345/1/output/index.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,23 @@ | ||
"use strict"; | ||
function n() {} | ||
var r = function() { | ||
var n = function n(n) {}; | ||
var r = null; | ||
return { | ||
init: function t(t) { | ||
return r = new n(t); | ||
} | ||
}; | ||
}(); | ||
var t = function() { | ||
var r = function r() { | ||
n(); | ||
}; | ||
; | ||
var t = null; | ||
return { | ||
init: function n(n) { | ||
return t; | ||
} | ||
}; | ||
}(); |
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,26 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript", | ||
"jsx": false | ||
}, | ||
"target": "es5", | ||
"loose": false, | ||
"minify": { | ||
"compress": false, | ||
"mangle": { | ||
"toplevel": false, | ||
"keep_classnames": false, | ||
"keep_fnames": false, | ||
"keep_private_props": false, | ||
"ie8": false, | ||
"safari10": false | ||
} | ||
} | ||
}, | ||
"module": { | ||
"type": "commonjs" | ||
}, | ||
"minify": false, | ||
"isModule": true | ||
} |
23 changes: 23 additions & 0 deletions
23
crates/swc/tests/fixture/issues-6xxx/6345/2/input/index.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,23 @@ | ||
"use strict"; | ||
function a() { } | ||
var te = function () { | ||
var n = function n(e) { }; | ||
var t = null; | ||
return { | ||
init: function init(e) { | ||
return t = new n(e); | ||
} | ||
}; | ||
}(); | ||
var he = function () { | ||
var n = function n() { | ||
a(); | ||
}; | ||
; | ||
var t = null; | ||
return { | ||
init: function init(e) { | ||
return t; | ||
} | ||
}; | ||
}(); |
23 changes: 23 additions & 0 deletions
23
crates/swc/tests/fixture/issues-6xxx/6345/2/output/index.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,23 @@ | ||
"use strict"; | ||
function n() {} | ||
var r = function() { | ||
var n = function n(n) {}; | ||
var r = null; | ||
return { | ||
init: function t(t) { | ||
return r = new n(t); | ||
} | ||
}; | ||
}(); | ||
var t = function() { | ||
var r = function r() { | ||
n(); | ||
}; | ||
; | ||
var t = null; | ||
return { | ||
init: function n(n) { | ||
return t; | ||
} | ||
}; | ||
}(); |
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
21 changes: 21 additions & 0 deletions
21
crates/swc_ecma_minifier/tests/fixture/issues/6344/1/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,21 @@ | ||
function a() { } | ||
var te = function () { | ||
function n(e) { } | ||
var t = null; | ||
return { | ||
init: function (e) { | ||
return t = new n(e); | ||
} | ||
} | ||
}(); | ||
var he = function () { | ||
function n() { | ||
a(); | ||
}; | ||
var t = null; | ||
return { | ||
init: function (e) { | ||
return t | ||
} | ||
} | ||
}(); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/fixture/issues/6344/1/mangle.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 @@ | ||
{} |
21 changes: 21 additions & 0 deletions
21
crates/swc_ecma_minifier/tests/fixture/issues/6344/1/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,21 @@ | ||
function n() {} | ||
var t = function() { | ||
function n(n) {} | ||
var t = null; | ||
return { | ||
init: function(u) { | ||
return t = new n(u); | ||
} | ||
}; | ||
}(); | ||
var u = function() { | ||
function t() { | ||
n(); | ||
} | ||
var u = null; | ||
return { | ||
init: function(n) { | ||
return u; | ||
} | ||
}; | ||
}(); |
23 changes: 23 additions & 0 deletions
23
crates/swc_ecma_minifier/tests/fixture/issues/6344/2/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,23 @@ | ||
"use strict"; | ||
function a() { } | ||
var te = function () { | ||
var n = function n(e) { }; | ||
var t = null; | ||
return { | ||
init: function init(e) { | ||
return t = new n(e); | ||
} | ||
}; | ||
}(); | ||
var he = function () { | ||
var n = function n() { | ||
a(); | ||
}; | ||
; | ||
var t = null; | ||
return { | ||
init: function init(e) { | ||
return t; | ||
} | ||
}; | ||
}(); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_minifier/tests/fixture/issues/6344/2/mangle.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 @@ | ||
{} |
22 changes: 22 additions & 0 deletions
22
crates/swc_ecma_minifier/tests/fixture/issues/6344/2/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,22 @@ | ||
"use strict"; | ||
function n() {} | ||
var r = function() { | ||
var n = function n(n) {}; | ||
var r = null; | ||
return { | ||
init: function t(t) { | ||
return r = new n(t); | ||
} | ||
}; | ||
}(); | ||
var t = function() { | ||
var r = function r() { | ||
n(); | ||
}; | ||
var t = null; | ||
return { | ||
init: function n(n) { | ||
return t; | ||
} | ||
}; | ||
}(); |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_minifier/tests/fixture/issues/6344/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,3 @@ | ||
{ | ||
"defaults": false | ||
} |
23 changes: 23 additions & 0 deletions
23
crates/swc_ecma_minifier/tests/mangle/issue-6345/1/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,23 @@ | ||
"use strict"; | ||
function n() { } | ||
var t = function () { | ||
function n(n) { } | ||
var t = null; | ||
return { | ||
init: function (u) { | ||
return t = new n(u); | ||
} | ||
}; | ||
}(); | ||
var u = function () { | ||
function t() { | ||
n(); | ||
} | ||
; | ||
var u = null; | ||
return { | ||
init: function (n) { | ||
return u; | ||
} | ||
}; | ||
}(); |
23 changes: 23 additions & 0 deletions
23
crates/swc_ecma_minifier/tests/mangle/issue-6345/1/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,23 @@ | ||
"use strict"; | ||
function n() {} | ||
var t = function() { | ||
function n(n) {} | ||
var t = null; | ||
return { | ||
init: function(u) { | ||
return t = new n(u); | ||
} | ||
}; | ||
}(); | ||
var u = function() { | ||
function t() { | ||
n(); | ||
} | ||
; | ||
var u = null; | ||
return { | ||
init: function(n) { | ||
return u; | ||
} | ||
}; | ||
}(); |
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
8 changes: 4 additions & 4 deletions
8
crates/swc_ecma_transforms_compat/tests/block-scoping/issue-2627/1/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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
var _$a = 1; | ||
var _$b = 1; | ||
var c = 1; | ||
var _$a__4 = 1; | ||
var _$b__5 = 1; | ||
var c__1 = 1; | ||
}console.log(a); | ||
console.log(b); | ||
console.log(c); | ||
console.log(c__1); |
24 changes: 12 additions & 12 deletions
24
crates/swc_ecma_transforms_compat/tests/block-scoping/issue-3235/1/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 |
---|---|---|
@@ -1,16 +1,16 @@ | ||
var res = []; | ||
var a = 2; | ||
res.push(a === 2); | ||
var res__1 = []; | ||
var a__1 = 2; | ||
res__1.push(a__1 === 2); | ||
{ | ||
var _$b = 1; | ||
}res.push(typeof b === "undefined"); | ||
var _$b__7 = 1; | ||
}res__1.push(typeof b === "undefined"); | ||
if (true) { | ||
var _$b1 = 0; | ||
var _$b__8 = 0; | ||
} | ||
res.push(typeof b === "undefined"); | ||
for(var _$b2 = 0; _$b2 < 10; _$b2++){} | ||
res.push(typeof b === "undefined"); | ||
function test() { | ||
var _$b = 7; | ||
res__1.push(typeof b === "undefined"); | ||
for(var _$b__9 = 0; _$b__9 < 10; _$b__9++){} | ||
res__1.push(typeof b === "undefined"); | ||
function test__1() { | ||
var _$b__10 = 7; | ||
} | ||
res.push(typeof b === "undefined"); | ||
res__1.push(typeof b === "undefined"); |
Oops, something went wrong.
81a4bb3
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
347052
ns/iter (± 20512
)349986
ns/iter (± 23901
)0.99
es/full/minify/libraries/antd
1923725849
ns/iter (± 40306160
)1934789356
ns/iter (± 23070368
)0.99
es/full/minify/libraries/d3
439671932
ns/iter (± 31729477
)441425492
ns/iter (± 13334204
)1.00
es/full/minify/libraries/echarts
1643646581
ns/iter (± 58778615
)1631399893
ns/iter (± 23971596
)1.01
es/full/minify/libraries/jquery
114105698
ns/iter (± 7923322
)105250008
ns/iter (± 4197173
)1.08
es/full/minify/libraries/lodash
133984446
ns/iter (± 21300946
)121952960
ns/iter (± 5997550
)1.10
es/full/minify/libraries/moment
60560367
ns/iter (± 3894269
)64139381
ns/iter (± 2439516
)0.94
es/full/minify/libraries/react
20593417
ns/iter (± 2786835
)19524393
ns/iter (± 889560
)1.05
es/full/minify/libraries/terser
345732662
ns/iter (± 19628473
)323287095
ns/iter (± 12244757
)1.07
es/full/minify/libraries/three
582607608
ns/iter (± 29822859
)566247022
ns/iter (± 12461867
)1.03
es/full/minify/libraries/typescript
3587011200
ns/iter (± 259198665
)3404412242
ns/iter (± 59099208
)1.05
es/full/minify/libraries/victory
945429374
ns/iter (± 75184631
)828383184
ns/iter (± 16656445
)1.14
es/full/minify/libraries/vue
179476890
ns/iter (± 14293493
)156822302
ns/iter (± 9688709
)1.14
es/full/codegen/es3
35156
ns/iter (± 3929
)33282
ns/iter (± 411
)1.06
es/full/codegen/es5
34958
ns/iter (± 2512
)33198
ns/iter (± 868
)1.05
es/full/codegen/es2015
34488
ns/iter (± 1564
)33350
ns/iter (± 1023
)1.03
es/full/codegen/es2016
34127
ns/iter (± 1825
)33305
ns/iter (± 1891
)1.02
es/full/codegen/es2017
34442
ns/iter (± 3106
)33172
ns/iter (± 999
)1.04
es/full/codegen/es2018
34504
ns/iter (± 4328
)32509
ns/iter (± 1026
)1.06
es/full/codegen/es2019
34753
ns/iter (± 3736
)32420
ns/iter (± 946
)1.07
es/full/codegen/es2020
34691
ns/iter (± 5722
)33245
ns/iter (± 1702
)1.04
es/full/all/es3
232540296
ns/iter (± 30431077
)187398591
ns/iter (± 7271044
)1.24
es/full/all/es5
216932331
ns/iter (± 44851067
)178482800
ns/iter (± 7573081
)1.22
es/full/all/es2015
168650590
ns/iter (± 28210961
)142353419
ns/iter (± 6180392
)1.18
es/full/all/es2016
184085282
ns/iter (± 33544797
)141010441
ns/iter (± 5199930
)1.31
es/full/all/es2017
176378828
ns/iter (± 32859530
)141411608
ns/iter (± 5769307
)1.25
es/full/all/es2018
170432604
ns/iter (± 15447414
)138981524
ns/iter (± 4475812
)1.23
es/full/all/es2019
173107005
ns/iter (± 26194868
)138017983
ns/iter (± 7235148
)1.25
es/full/all/es2020
176772997
ns/iter (± 24962885
)133637106
ns/iter (± 5799622
)1.32
es/full/parser
793736
ns/iter (± 112062
)721147
ns/iter (± 30622
)1.10
es/full/base/fixer
30184
ns/iter (± 5813
)26438
ns/iter (± 886
)1.14
es/full/base/resolver_and_hygiene
95874
ns/iter (± 19630
)90459
ns/iter (± 4581
)1.06
serialization of ast node
221
ns/iter (± 20
)224
ns/iter (± 6
)0.99
serialization of serde
235
ns/iter (± 28
)231
ns/iter (± 7
)1.02
This comment was automatically generated by workflow using github-action-benchmark.