-
-
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.
feat(es/modules): Support
allowTopLevelThis
(#5086)
- Loading branch information
1 parent
f5447cd
commit 9addef6
Showing
15 changed files
with
97 additions
and
1 deletion.
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
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
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
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/false/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 @@ | ||
export var v = this; |
3 changes: 3 additions & 0 deletions
3
...es/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/false/module.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 @@ | ||
{ | ||
"allowTopLevelThis": false | ||
} |
14 changes: 14 additions & 0 deletions
14
.../swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/false/output.amd.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 @@ | ||
define([ | ||
"require", | ||
"exports" | ||
], function(require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "v", { | ||
enumerable: true, | ||
get: ()=>v | ||
}); | ||
var v = void 0; | ||
}); |
9 changes: 9 additions & 0 deletions
9
crates/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/false/output.cjs
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,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "v", { | ||
enumerable: true, | ||
get: ()=>v | ||
}); | ||
var v = void 0; |
17 changes: 17 additions & 0 deletions
17
.../swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/false/output.umd.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 @@ | ||
(function(global, factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") factory(exports); | ||
else if (typeof define === "function" && define.amd) define([ | ||
"exports" | ||
], factory); | ||
else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}); | ||
})(this, function(exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "v", { | ||
enumerable: true, | ||
get: ()=>v | ||
}); | ||
var v = void 0; | ||
}); |
1 change: 1 addition & 0 deletions
1
crates/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/true/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 @@ | ||
export var v = this; |
3 changes: 3 additions & 0 deletions
3
crates/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/true/module.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 @@ | ||
{ | ||
"allowTopLevelThis": true | ||
} |
14 changes: 14 additions & 0 deletions
14
...s/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/true/output.amd.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 @@ | ||
define([ | ||
"require", | ||
"exports" | ||
], function(require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "v", { | ||
enumerable: true, | ||
get: ()=>v | ||
}); | ||
var v = this; | ||
}); |
9 changes: 9 additions & 0 deletions
9
crates/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/true/output.cjs
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,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "v", { | ||
enumerable: true, | ||
get: ()=>v | ||
}); | ||
var v = this; |
17 changes: 17 additions & 0 deletions
17
...s/swc_ecma_transforms_module/tests/fixture/common/allow-top-level-this/true/output.umd.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 @@ | ||
(function(global, factory) { | ||
if (typeof module === "object" && typeof module.exports === "object") factory(exports); | ||
else if (typeof define === "function" && define.amd) define([ | ||
"exports" | ||
], factory); | ||
else if (global = typeof globalThis !== "undefined" ? globalThis : global || self) factory(global.input = {}); | ||
})(this, function(exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "v", { | ||
enumerable: true, | ||
get: ()=>v | ||
}); | ||
var v = this; | ||
}); |
9addef6
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
1609758811
ns/iter (± 48482846
)1682544504
ns/iter (± 18401584
)0.96
es/full/minify/libraries/d3
397440411
ns/iter (± 11062720
)428288908
ns/iter (± 16907531
)0.93
es/full/minify/libraries/echarts
1598868857
ns/iter (± 39425758
)1666207164
ns/iter (± 28415077
)0.96
es/full/minify/libraries/jquery
86945313
ns/iter (± 2592982
)101490088
ns/iter (± 2221270
)0.86
es/full/minify/libraries/lodash
114619992
ns/iter (± 2166993
)137277384
ns/iter (± 4084409
)0.83
es/full/minify/libraries/moment
50009256
ns/iter (± 892108
)59985010
ns/iter (± 2043244
)0.83
es/full/minify/libraries/react
16905481
ns/iter (± 200115
)19624832
ns/iter (± 748925
)0.86
es/full/minify/libraries/terser
591655945
ns/iter (± 6507815
)624886287
ns/iter (± 15451951
)0.95
es/full/minify/libraries/three
535264799
ns/iter (± 12819630
)571977668
ns/iter (± 13269719
)0.94
es/full/minify/libraries/typescript
3409401640
ns/iter (± 73277301
)3635381810
ns/iter (± 83479854
)0.94
es/full/minify/libraries/victory
726385204
ns/iter (± 21454810
)750919610
ns/iter (± 7098079
)0.97
es/full/minify/libraries/vue
131732837
ns/iter (± 6522395
)156672133
ns/iter (± 1966904
)0.84
es/full/codegen/es3
31031
ns/iter (± 691
)32368
ns/iter (± 2096
)0.96
es/full/codegen/es5
30930
ns/iter (± 778
)32371
ns/iter (± 546
)0.96
es/full/codegen/es2015
30999
ns/iter (± 1918
)32312
ns/iter (± 377
)0.96
es/full/codegen/es2016
31031
ns/iter (± 1333
)32349
ns/iter (± 881
)0.96
es/full/codegen/es2017
30962
ns/iter (± 510
)32349
ns/iter (± 1084
)0.96
es/full/codegen/es2018
31019
ns/iter (± 925
)32348
ns/iter (± 785
)0.96
es/full/codegen/es2019
30882
ns/iter (± 319
)32436
ns/iter (± 1401
)0.95
es/full/codegen/es2020
31042
ns/iter (± 560
)32440
ns/iter (± 653
)0.96
es/full/all/es3
180450431
ns/iter (± 6307896
)208352437
ns/iter (± 8853655
)0.87
es/full/all/es5
169075960
ns/iter (± 4800643
)195573364
ns/iter (± 5861027
)0.86
es/full/all/es2015
137492339
ns/iter (± 13348598
)145850706
ns/iter (± 5393485
)0.94
es/full/all/es2016
135905385
ns/iter (± 6272957
)142547930
ns/iter (± 4348550
)0.95
es/full/all/es2017
135796918
ns/iter (± 4693552
)142214704
ns/iter (± 3728628
)0.95
es/full/all/es2018
134576335
ns/iter (± 5046942
)142444425
ns/iter (± 6576891
)0.94
es/full/all/es2019
133760807
ns/iter (± 5011875
)139519148
ns/iter (± 5732935
)0.96
es/full/all/es2020
129343346
ns/iter (± 7884150
)135919801
ns/iter (± 8711451
)0.95
es/full/parser
695726
ns/iter (± 19696
)707459
ns/iter (± 22552
)0.98
es/full/base/fixer
29120
ns/iter (± 671
)29239
ns/iter (± 699
)1.00
es/full/base/resolver_and_hygiene
86689
ns/iter (± 3505
)90434
ns/iter (± 4198
)0.96
serialization of ast node
212
ns/iter (± 2
)215
ns/iter (± 1
)0.99
serialization of serde
225
ns/iter (± 2
)226
ns/iter (± 2
)1.00
This comment was automatically generated by workflow using github-action-benchmark.