mirror of
https://github.com/swc-project/swc.git
synced 2024-12-02 02:58:48 +03:00
69719c2acb
**Description:** Helper methods were exporting twice, `_` and it's own function name. We can map the build script to export `_` as it's own name (filename). Therefore we export only once as `_`, and map the name on the build script. ```js // helpers/_foo.js function _foo() { // ... } export { _foo as _ } ``` ```js // index.js // We know the func name will be `_foo` based on the filename. export { _ as _foo } from '_foo.js' ``` Closes #9203 --------- Co-authored-by: magic-akari <akari.ccino@gmail.com>
16 lines
406 B
JavaScript
16 lines
406 B
JavaScript
function _export_star(from, to) {
|
|
Object.keys(from).forEach(function(k) {
|
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
Object.defineProperty(to, k, {
|
|
enumerable: true,
|
|
get: function() {
|
|
return from[k];
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
return from;
|
|
}
|
|
export { _export_star as _ };
|