-
-
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/transforms/cjs): Allow mixing named exports and export stars. (#…
…2583) swc_ecma_transforms_module: - `common_js`: Fix _exportNames when exporting aliases and using `export *`s . (#2548)
- Loading branch information
1 parent
306cf98
commit 7e3fb0a
Showing
11 changed files
with
164 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"module": { | ||
"type": "commonjs" | ||
} | ||
} |
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 { default as X } from "./Z"; |
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, "X", { | ||
enumerable: true, | ||
get: function() { | ||
return _z.default; | ||
} | ||
}); | ||
var _z = _interopRequireDefault(require("./Z")); | ||
function _interopRequireDefault(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
} |
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,5 @@ | ||
{ | ||
"module": { | ||
"type": "commonjs" | ||
} | ||
} |
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,2 @@ | ||
export { default as X } from "./Z"; | ||
export * from "./Z"; |
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,48 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "X", { | ||
enumerable: true, | ||
get: function() { | ||
return _z.default; | ||
} | ||
}); | ||
var _exportNames = { | ||
X: true | ||
}; | ||
var _z = _interopRequireWildcard(require("./Z")); | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = { | ||
}; | ||
if (obj != null) { | ||
for(var key in obj){ | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : { | ||
}; | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
} | ||
Object.keys(_z).forEach(function(key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _z[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function() { | ||
return _z[key]; | ||
} | ||
}); | ||
}); |
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,5 @@ | ||
{ | ||
"module": { | ||
"type": "commonjs" | ||
} | ||
} |
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,2 @@ | ||
export { default as X, Y, X2 } from "./Z"; | ||
export * from "./Z"; |
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,62 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "X", { | ||
enumerable: true, | ||
get: function() { | ||
return _z.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "Y", { | ||
enumerable: true, | ||
get: function() { | ||
return _z.Y; | ||
} | ||
}); | ||
Object.defineProperty(exports, "X2", { | ||
enumerable: true, | ||
get: function() { | ||
return _z.X2; | ||
} | ||
}); | ||
var _exportNames = { | ||
X: true, | ||
Y: true, | ||
X2: true | ||
}; | ||
var _z = _interopRequireWildcard(require("./Z")); | ||
function _interopRequireWildcard(obj) { | ||
if (obj && obj.__esModule) { | ||
return obj; | ||
} else { | ||
var newObj = { | ||
}; | ||
if (obj != null) { | ||
for(var key in obj){ | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : { | ||
}; | ||
if (desc.get || desc.set) { | ||
Object.defineProperty(newObj, key, desc); | ||
} else { | ||
newObj[key] = obj[key]; | ||
} | ||
} | ||
} | ||
} | ||
newObj.default = obj; | ||
return newObj; | ||
} | ||
} | ||
Object.keys(_z).forEach(function(key) { | ||
if (key === "default" || key === "__esModule") return; | ||
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; | ||
if (key in exports && exports[key] === _z[key]) return; | ||
Object.defineProperty(exports, key, { | ||
enumerable: true, | ||
get: function() { | ||
return _z[key]; | ||
} | ||
}); | ||
}); |
7e3fb0a
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
base_tr_fixer
33527
ns/iter (± 4320
)23637
ns/iter (± 273
)1.42
base_tr_resolver_and_hygiene
185793
ns/iter (± 33015
)127831
ns/iter (± 9050
)1.45
codegen_es2015
64492
ns/iter (± 8349
)50716
ns/iter (± 249
)1.27
codegen_es2016
67470
ns/iter (± 6376
)50810
ns/iter (± 268
)1.33
codegen_es2017
64223
ns/iter (± 6694
)50902
ns/iter (± 329
)1.26
codegen_es2018
64585
ns/iter (± 6510
)50806
ns/iter (± 440
)1.27
codegen_es2019
65325
ns/iter (± 5806
)50792
ns/iter (± 368
)1.29
codegen_es2020
64512
ns/iter (± 5637
)50924
ns/iter (± 484
)1.27
codegen_es3
65133
ns/iter (± 7149
)51019
ns/iter (± 278
)1.28
codegen_es5
64711
ns/iter (± 6999
)50854
ns/iter (± 263
)1.27
config_for_file
19953
ns/iter (± 5847
)13393
ns/iter (± 4153
)1.49
full_es2015
223909007
ns/iter (± 15395732
)181802089
ns/iter (± 4459166
)1.23
full_es2016
172234824
ns/iter (± 19084508
)144126467
ns/iter (± 5698050
)1.20
full_es2017
190429499
ns/iter (± 11469692
)147885602
ns/iter (± 13619321
)1.29
full_es2018
184936283
ns/iter (± 14801689
)147737699
ns/iter (± 9881223
)1.25
full_es2019
184965280
ns/iter (± 12804072
)144739291
ns/iter (± 10593084
)1.28
full_es2020
182459167
ns/iter (± 13023832
)144520231
ns/iter (± 12754440
)1.26
full_es3
292555956
ns/iter (± 42002125
)209975583
ns/iter (± 21969787
)1.39
full_es5
268231801
ns/iter (± 35165635
)195794888
ns/iter (± 17827869
)1.37
parser
822745
ns/iter (± 90698
)626487
ns/iter (± 16175
)1.31
transforms_es2015
1579082
ns/iter (± 111984
)969951
ns/iter (± 31346
)1.63
transforms_es2016
924053
ns/iter (± 191852
)573229
ns/iter (± 21390
)1.61
transforms_es2017
916545
ns/iter (± 185637
)562024
ns/iter (± 29592
)1.63
transforms_es2018
907745
ns/iter (± 210743
)553656
ns/iter (± 20855
)1.64
transforms_es2019
897137
ns/iter (± 128786
)541336
ns/iter (± 17764
)1.66
transforms_es2020
905688
ns/iter (± 178610
)533421
ns/iter (± 11989
)1.70
transforms_es3
2013976
ns/iter (± 577203
)1100217
ns/iter (± 56868
)1.83
transforms_es5
1690132
ns/iter (± 385372
)966826
ns/iter (± 68467
)1.75
ser_ast_node
196
ns/iter (± 64
)148
ns/iter (± 4
)1.32
ser_serde
209
ns/iter (± 25
)165
ns/iter (± 1
)1.27
emit_colors
10438500
ns/iter (± 7631756
)14499271
ns/iter (± 18794848
)0.72
emit_large
104033094
ns/iter (± 160376738
)97192152
ns/iter (± 154513286
)1.07
base_clone
2997047
ns/iter (± 340820
)2262246
ns/iter (± 10267
)1.32
fold_span
5078887
ns/iter (± 614587
)3780464
ns/iter (± 21428
)1.34
fold_span_panic
5769081
ns/iter (± 1543502
)4001316
ns/iter (± 12108
)1.44
visit_mut_span
3614047
ns/iter (± 392296
)2772012
ns/iter (± 12413
)1.30
visit_mut_span_panic
3668768
ns/iter (± 565342
)2822342
ns/iter (± 14096
)1.30
boxing_boxed
188
ns/iter (± 14
)143
ns/iter (± 0
)1.31
boxing_boxed_clone
81
ns/iter (± 6
)68
ns/iter (± 0
)1.19
boxing_unboxed
178
ns/iter (± 8
)130
ns/iter (± 0
)1.37
boxing_unboxed_clone
79
ns/iter (± 3
)63
ns/iter (± 0
)1.25
This comment was automatically generated by workflow using github-action-benchmark.