-
-
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/modules): Handle top level this, really (#5160)
- Loading branch information
1 parent
6f8529e
commit 2555d71
Showing
5 changed files
with
78 additions
and
3 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
8 changes: 8 additions & 0 deletions
8
crates/swc_ecma_transforms_module/tests/fixture/common/issue-5157/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,8 @@ | ||
export const foo = { | ||
get [this]() { | ||
return this; | ||
}, | ||
set [this](v = this.y) { | ||
this.x = v; | ||
}, | ||
}; |
21 changes: 21 additions & 0 deletions
21
crates/swc_ecma_transforms_module/tests/fixture/common/issue-5157/2/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,21 @@ | ||
define([ | ||
"require", | ||
"exports" | ||
], function(require, exports) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "foo", { | ||
enumerable: true, | ||
get: ()=>foo | ||
}); | ||
const foo = { | ||
get [void 0] () { | ||
return this; | ||
}, | ||
set [void 0] (v = this.y){ | ||
this.x = v; | ||
} | ||
}; | ||
}); |
16 changes: 16 additions & 0 deletions
16
crates/swc_ecma_transforms_module/tests/fixture/common/issue-5157/2/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,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "foo", { | ||
enumerable: true, | ||
get: ()=>foo | ||
}); | ||
const foo = { | ||
get [void 0] () { | ||
return this; | ||
}, | ||
set [void 0] (v = this.y){ | ||
this.x = v; | ||
} | ||
}; |
24 changes: 24 additions & 0 deletions
24
crates/swc_ecma_transforms_module/tests/fixture/common/issue-5157/2/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,24 @@ | ||
(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, "foo", { | ||
enumerable: true, | ||
get: ()=>foo | ||
}); | ||
const foo = { | ||
get [void 0] () { | ||
return this; | ||
}, | ||
set [void 0] (v = this.y){ | ||
this.x = v; | ||
} | ||
}; | ||
}); |
2555d71
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
1716747685
ns/iter (± 26697517
)1710091932
ns/iter (± 75516506
)1.00
es/full/minify/libraries/d3
448610419
ns/iter (± 11919727
)442339932
ns/iter (± 25305547
)1.01
es/full/minify/libraries/echarts
1740734034
ns/iter (± 33840814
)1742948905
ns/iter (± 77912735
)1.00
es/full/minify/libraries/jquery
109379436
ns/iter (± 8189111
)98662168
ns/iter (± 5283943
)1.11
es/full/minify/libraries/lodash
131348875
ns/iter (± 9527892
)139930318
ns/iter (± 21331159
)0.94
es/full/minify/libraries/moment
60183425
ns/iter (± 1710585
)58339059
ns/iter (± 11428758
)1.03
es/full/minify/libraries/react
18322353
ns/iter (± 607532
)18377969
ns/iter (± 994217
)1.00
es/full/minify/libraries/terser
604291509
ns/iter (± 14379620
)624364241
ns/iter (± 12655938
)0.97
es/full/minify/libraries/three
570608916
ns/iter (± 16385515
)563927623
ns/iter (± 12711971
)1.01
es/full/minify/libraries/typescript
3509079399
ns/iter (± 90163885
)3522385148
ns/iter (± 101205389
)1.00
es/full/minify/libraries/victory
754954868
ns/iter (± 16473415
)746780654
ns/iter (± 22454101
)1.01
es/full/minify/libraries/vue
154907841
ns/iter (± 14741887
)153863458
ns/iter (± 6489850
)1.01
es/full/codegen/es3
32545
ns/iter (± 405
)33152
ns/iter (± 1118
)0.98
es/full/codegen/es5
32585
ns/iter (± 608
)33249
ns/iter (± 2767
)0.98
es/full/codegen/es2015
32600
ns/iter (± 928
)33173
ns/iter (± 421
)0.98
es/full/codegen/es2016
32546
ns/iter (± 942
)33186
ns/iter (± 308
)0.98
es/full/codegen/es2017
32584
ns/iter (± 410
)33184
ns/iter (± 587
)0.98
es/full/codegen/es2018
32543
ns/iter (± 439
)33196
ns/iter (± 622
)0.98
es/full/codegen/es2019
32534
ns/iter (± 4015
)33221
ns/iter (± 1742
)0.98
es/full/codegen/es2020
32646
ns/iter (± 572
)33163
ns/iter (± 1489
)0.98
es/full/all/es3
182944355
ns/iter (± 8059277
)189386907
ns/iter (± 8958250
)0.97
es/full/all/es5
176990011
ns/iter (± 28991110
)178039349
ns/iter (± 7848031
)0.99
es/full/all/es2015
141874315
ns/iter (± 6167021
)139973396
ns/iter (± 3922284
)1.01
es/full/all/es2016
139896908
ns/iter (± 4494561
)139029680
ns/iter (± 6482299
)1.01
es/full/all/es2017
138009650
ns/iter (± 3921144
)137621535
ns/iter (± 3080156
)1.00
es/full/all/es2018
137108855
ns/iter (± 4846439
)140642734
ns/iter (± 6766412
)0.97
es/full/all/es2019
135262991
ns/iter (± 4540141
)139250775
ns/iter (± 5767166
)0.97
es/full/all/es2020
130183760
ns/iter (± 3609510
)134522694
ns/iter (± 9773606
)0.97
es/full/parser
697649
ns/iter (± 61173
)708978
ns/iter (± 17717
)0.98
es/full/base/fixer
29373
ns/iter (± 274
)29895
ns/iter (± 837
)0.98
es/full/base/resolver_and_hygiene
87721
ns/iter (± 1942
)87630
ns/iter (± 3815
)1.00
serialization of ast node
211
ns/iter (± 3
)216
ns/iter (± 3
)0.98
serialization of serde
229
ns/iter (± 1
)227
ns/iter (± 2
)1.01
This comment was automatically generated by workflow using github-action-benchmark.