Skip to content

Commit

Permalink
feat(es/utils): Use more unique names for aliases (#6399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Austaras committed Nov 11, 2022
1 parent c39380d commit 574502a
Show file tree
Hide file tree
Showing 312 changed files with 1,532 additions and 1,519 deletions.
@@ -1,6 +1,6 @@
import _to_consumable_array from "@swc/helpers/src/_to_consumable_array.mjs";
function a(param) {
var _b = param.b, b = _b === void 0 ? [] : _b;
var _param_b = param.b, b = _param_b === void 0 ? [] : _param_b;
var t = useMemo(function() {
return(// Cmt1
_to_consumable_array(a.slice(0, 1)).concat(// Cmt2
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-1xxx/1107/1/output/index.js
@@ -1,13 +1,13 @@
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
export var Class1 = function Class1(param) {
"use strict";
var _name = param.name, name = _name === void 0 ? "" : _name;
var _param_name = param.name, name = _param_name === void 0 ? "" : _param_name;
_class_call_check(this, Class1);
console.log(name);
};
export var Class2 = function Class2(param) {
"use strict";
var _name = param.name, name = _name === void 0 ? "" : _name;
var _param_name = param.name, name = _param_name === void 0 ? "" : _param_name;
_class_call_check(this, Class2);
console.log(name);
};
Expand Up @@ -271,9 +271,9 @@ class Shard extends _utils.Emitter {
* Called whenever the websocket opens.
* @private
*/ _open() {
var ref;
var _class_private_field_get;
this.status = _utils.Status.HANDSHAKING;
this._debug(`Connected. ${(ref = _classPrivateFieldGet(this, _ws1)) === null || ref === void 0 ? void 0 : ref.url} in ${Date.now() - this.connectedAt}`);
this._debug(`Connected. ${(_class_private_field_get = _classPrivateFieldGet(this, _ws1)) === null || _class_private_field_get === void 0 ? void 0 : _class_private_field_get.url} in ${Date.now() - this.connectedAt}`);
if (_classPrivateFieldGet(this, _queue).length) {
this._debug(`${_classPrivateFieldGet(this, _queue).length} packets waiting... sending all now.`);
while(_classPrivateFieldGet(this, _queue).length){
Expand All @@ -300,8 +300,8 @@ class Shard extends _utils.Emitter {
* @param {WebSocket.CloseEvent} evt
* @private
*/ _close(evt) {
var ref;
const reason = (ref = evt.reason || _utils.GatewayCloseCode[evt.code]) !== null && ref !== void 0 ? ref : "unknown";
var _ref;
const reason = (_ref = evt.reason || _utils.GatewayCloseCode[evt.code]) !== null && _ref !== void 0 ? _ref : "unknown";
this._debug(`Closed; Code = ${evt.code}, Clean? = ${evt.wasClean}, Reason = ${reason}`);
if (_classPrivateFieldGet(this, _seq) !== -1) {
_classPrivateFieldSet(this, _closingSeq, _classPrivateFieldGet(this, _seq));
Expand Down
Expand Up @@ -59,8 +59,8 @@ class RequestHandler {
].includes(p) ? match : `/${p}/:id`).replace(/\/reactions\/[^/]+/g, "/reactions/:id").replace(/\/webhooks\/(\d+)\/[\w-]{64,}/, "webhooks/$1/:token").replace(/\?.*$/, "");
let ending = ";";
if (method === "delete" && route.endsWith("/message/:id")) {
var ref;
const id = (ref = /\d{16,19}$/.exec(route)) === null || ref === void 0 ? void 0 : ref[0];
var _exec;
const id = (_exec = /\d{16,19}$/.exec(route)) === null || _exec === void 0 ? void 0 : _exec[0];
const snowflake = _utils.Snowflake.deconstruct(id);
if (Date.now() - snowflake.timestamp > 1000 * 60 * 60 * 24 * 14) {
ending += "deletes-old";
Expand All @@ -73,8 +73,8 @@ class RequestHandler {
* @param {Response} res
* @return {* | Promise<any>}
*/ static async parseResponse(res) {
var ref;
if ((ref = res.headers.get("Content-Type")) === null || ref === void 0 ? void 0 : ref.startsWith("application/json")) {
var _res_headers_get;
if ((_res_headers_get = res.headers.get("Content-Type")) === null || _res_headers_get === void 0 ? void 0 : _res_headers_get.startsWith("application/json")) {
return await res.json();
}
return res.buffer();
Expand Down
Expand Up @@ -6,9 +6,9 @@ function foo() {
}
function _foo() {
_foo = _async_to_generator(function() {
var tmp, ref, ref;
var tmp, _ref, _ref;
return _ts_generator(this, function(_state) {
tmp = baz.bar, ref = tmp === void 0 ? {} : tmp, ref = ref !== null ? ref : _throw(new TypeError("Cannot destructure undefined"));
tmp = baz.bar, _ref = tmp === void 0 ? {} : tmp, _ref = _ref !== null ? _ref : _throw(new TypeError("Cannot destructure undefined"));
return [
2
];
Expand Down
Expand Up @@ -6,9 +6,9 @@ function f(a, b) {
}
function _f() {
_f = _async_to_generator(function(a, b) {
var ref, ref1, tmp, a_;
var _JSON_parse, _JSON_parse_, tmp, a_;
return _ts_generator(this, function(_state) {
ref = _sliced_to_array(JSON.parse(b), 1), ref1 = ref[0], tmp = ref1.a, a_ = tmp === void 0 ? 1 : tmp;
_JSON_parse = _sliced_to_array(JSON.parse(b), 1), _JSON_parse_ = _JSON_parse[0], tmp = _JSON_parse_.a, a_ = tmp === void 0 ? 1 : tmp;
return [
2
];
Expand Down
@@ -1,6 +1,6 @@
import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs";
function Bar() {
var ref = _sliced_to_array(useState(0), 2), foo = ref[0], setFoo = ref[1];
var _useState = _sliced_to_array(useState(0), 2), foo = _useState[0], setFoo = _useState[1];
// @refresh reset
React.useEffect(function() {});
return /*#__PURE__*/ React.createElement("h1", null, foo, " ");
Expand Down
4 changes: 2 additions & 2 deletions crates/swc/tests/fixture/issues-2xxx/2063/output/index.js
@@ -1,7 +1,7 @@
var _value, ref;
var _myVar_target_value, _myVar_target_value_toLowerCase;
var myVar = {
target: {
value: "ABC"
}
};
console.log((ref = (_value = myVar.target.value).toLowerCase) === null || ref === void 0 ? void 0 : ref.call(_value));
console.log((_myVar_target_value_toLowerCase = (_myVar_target_value = myVar.target.value).toLowerCase) === null || _myVar_target_value_toLowerCase === void 0 ? void 0 : _myVar_target_value_toLowerCase.call(_myVar_target_value));
6 changes: 3 additions & 3 deletions crates/swc/tests/fixture/issues-2xxx/2139/output/index.tsx
Expand Up @@ -8,7 +8,7 @@ class ReusablePayments extends PureComponent {
}
}
setDefaultReusablePayment(skipPaymentSource) {
var _props = this.props, reusablePaymentSources = _props.reusablePaymentSources, selectedReusablePayment = _props.selectedReusablePayment, onChange = _props.onChange;
var _this_props = this.props, reusablePaymentSources = _this_props.reusablePaymentSources, selectedReusablePayment = _this_props.selectedReusablePayment, onChange = _this_props.onChange;
var validReusablePaymentSources = reusablePaymentSources.filter((ps)=>ps.__typename === "StripePaymentSource" && ps !== skipPaymentSource);
if (selectedReusablePayment === null) {
return;
Expand All @@ -25,7 +25,7 @@ class ReusablePayments extends PureComponent {
onChange(ps || validReusablePaymentSources[0]);
}
render() {
var _props = this.props, selectedReusablePayment = _props.selectedReusablePayment, reusablePaymentSources = _props.reusablePaymentSources;
var _this_props = this.props, selectedReusablePayment = _this_props.selectedReusablePayment, reusablePaymentSources = _this_props.reusablePaymentSources;
var stripePaymentSources = reusablePaymentSources.filter((ps)=>ps.__typename === "StripePaymentSource");
if (!stripePaymentSources.length) {
return null;
Expand Down Expand Up @@ -85,7 +85,7 @@ class ReusablePayments extends PureComponent {
return this.props.onChange(selected);
};
this.handleDeletePaymentSource = (id, deletePaymentSource)=>{
var _props = this.props, selectedReusablePayment = _props.selectedReusablePayment, onChange = _props.onChange;
var _this_props = this.props, selectedReusablePayment = _this_props.selectedReusablePayment, onChange = _this_props.onChange;
if (onChange && selectedReusablePayment && selectedReusablePayment.id === id) {
this.setDefaultReusablePayment(selectedReusablePayment);
}
Expand Down
Expand Up @@ -13,9 +13,9 @@ var Foo = /*#__PURE__*/ function() {
key: "sendSomeMessage",
value: function sendSomeMessage(_parent, _param, _param1) {
return _async_to_generator(function() {
var _input, toNumber, messageBody, all, dataSources;
var _param_input, toNumber, messageBody, all, dataSources;
return _ts_generator(this, function(_state) {
_input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _object_without_properties(_param.input, [
_param_input = _param.input, toNumber = _param_input.toNumber, messageBody = _param_input.messageBody, all = _object_without_properties(_param.input, [
"toNumber",
"messageBody"
]), dataSources = _param1.dataSources;
Expand Down
Expand Up @@ -4,9 +4,9 @@ import _ts_generator from "@swc/helpers/src/_ts_generator.mjs";
var resolver = {
sendSomeMessage: function sendSomeMessage(_parent, _param, _param1) {
return _async_to_generator(function() {
var _input, toNumber, messageBody, all, dataSources;
var _param_input, toNumber, messageBody, all, dataSources;
return _ts_generator(this, function(_state) {
_input = _param.input, toNumber = _input.toNumber, messageBody = _input.messageBody, all = _object_without_properties(_param.input, [
_param_input = _param.input, toNumber = _param_input.toNumber, messageBody = _param_input.messageBody, all = _object_without_properties(_param.input, [
"toNumber",
"messageBody"
]), dataSources = _param1.dataSources;
Expand Down
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-2xxx/2336/output/input.tsx
@@ -1,5 +1,5 @@
import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs";
var ref = _sliced_to_array(createQuery(), 2);
export var useQuery = ref[0], query = ref[1].query;
var ref1 = _sliced_to_array(createMutation(), 2);
export var useMutation = ref1[0], mutate = ref1[1].mutate;
var _createQuery = _sliced_to_array(createQuery(), 2);
export var useQuery = _createQuery[0], query = _createQuery[1].query;
var _createMutation = _sliced_to_array(createMutation(), 2);
export var useMutation = _createMutation[0], mutate = _createMutation[1].mutate;
Expand Up @@ -2,7 +2,7 @@ export function App() {
return React.createElement(Form, null);
}
export function Form(param) {
var _onChange = param.onChange, onChange = _onChange === void 0 ? function() {} : _onChange;
var _param_onChange = param.onChange, onChange = _param_onChange === void 0 ? function() {} : _param_onChange;
return React.createElement("input", {
onChange: function onChange1() {
onChange();
Expand Down
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-2xxx/2858/1/output/index.js
@@ -1,9 +1,9 @@
var ref = {
var _ref = {
a: 1,
b: 2
}, a1 = ref.a, b1 = ref.b;
var ref1 = {
}, a1 = _ref.a, b1 = _ref.b;
var _ref1 = {
a: 1,
b: 2
};
export var a2 = ref1.a, b2 = ref1.b;
export var a2 = _ref1.a, b2 = _ref1.b;
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-2xxx/2858/2/output/index.js
Expand Up @@ -16,12 +16,12 @@ _export(exports, {
return b2;
}
});
var ref = {
var _ref = {
a: 1,
b: 2
}, a1 = ref.a, b1 = ref.b;
var ref1 = {
}, a1 = _ref.a, b1 = _ref.b;
var _ref1 = {
a: 1,
b: 2
};
var a2 = ref1.a, b2 = ref1.b;
var a2 = _ref1.a, b2 = _ref1.b;
8 changes: 4 additions & 4 deletions crates/swc/tests/fixture/issues-4xxx/4108/1/output/index.ts
Expand Up @@ -484,7 +484,7 @@ export var sendTransaction = function() {
}();
export var sendTransactionWithRetry = function() {
var _ref = _async_to_generator(function(connection, wallet, instructions, signers) {
var commitment, includesFeePayer, block, beforeSend, transaction, _tmp, _transaction, _transaction1, _transaction2, ref, txid, slot;
var commitment, includesFeePayer, block, beforeSend, transaction, _tmp, _transaction, _transaction1, _transaction2, _ref, txid, slot;
var _arguments = arguments;
return _ts_generator(this, function(_state) {
switch(_state.label){
Expand Down Expand Up @@ -550,7 +550,7 @@ export var sendTransactionWithRetry = function() {
})
];
case 5:
ref = _state.sent(), txid = ref.txid, slot = ref.slot;
_ref = _state.sent(), txid = _ref.txid, slot = _ref.slot;
return [
2,
{
Expand All @@ -574,11 +574,11 @@ export function sendSignedTransaction(_) {
}
function _sendSignedTransaction() {
_sendSignedTransaction = _async_to_generator(function(param) {
var signedTransaction, connection, _timeout, timeout, rawTransaction, startTime, slot, txid, done, confirmation, err, simulateResult, e, i, line;
var signedTransaction, connection, _param_timeout, timeout, rawTransaction, startTime, slot, txid, done, confirmation, err, simulateResult, e, i, line;
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
signedTransaction = param.signedTransaction, connection = param.connection, _timeout = param.timeout, timeout = _timeout === void 0 ? DEFAULT_TIMEOUT : _timeout;
signedTransaction = param.signedTransaction, connection = param.connection, _param_timeout = param.timeout, timeout = _param_timeout === void 0 ? DEFAULT_TIMEOUT : _param_timeout;
rawTransaction = signedTransaction.serialize();
startTime = getUnixTs();
slot = 0;
Expand Down
22 changes: 11 additions & 11 deletions crates/swc/tests/fixture/issues-5xxx/5102/output/index.js
Expand Up @@ -4,22 +4,22 @@ var a = function a() {
"use strict";
_class_call_check(this, a);
};
var ref = [
var _ref = [
function _class() {
"use strict";
_class_call_check(this, _class);
}
], b = ref[0];
var ref1 = [], tmp = ref1[0], c = tmp === void 0 ? function c() {
], b = _ref[0];
var _ref1 = [], tmp = _ref1[0], c = tmp === void 0 ? function c() {
"use strict";
_class_call_check(this, c);
} : tmp;
var ref2 = [
var _ref2 = [
function _class() {
"use strict";
_class_call_check(this, _class);
}
], tmp1 = ref2[0], d = tmp1 === void 0 ? function d() {
], tmp1 = _ref2[0], d = tmp1 === void 0 ? function d() {
"use strict";
_class_call_check(this, d);
} : tmp1;
Expand All @@ -29,20 +29,20 @@ var e = {
_class_call_check(this, e);
}
}.e;
var ref3 = {}, _f = ref3.f, f = _f === void 0 ? function f() {
var _ref3 = {}, _ref_f = _ref3.f, f = _ref_f === void 0 ? function f() {
"use strict";
_class_call_check(this, f);
} : _f;
var ref4 = {
} : _ref_f;
var _ref4 = {
g: function g() {
"use strict";
_class_call_check(this, g);
}
}, _g = ref4.g, g = _g === void 0 ? function g() {
}, _ref_g = _ref4.g, g = _ref_g === void 0 ? function g() {
"use strict";
_class_call_check(this, g);
} : _g;
var ref5 = {}, tmp2 = ref5._, h = tmp2 === void 0 ? function h() {
} : _ref_g;
var _ref5 = {}, tmp2 = _ref5._, h = tmp2 === void 0 ? function h() {
"use strict";
_class_call_check(this, h);
} : tmp2;
Expand Down

1 comment on commit 574502a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 574502a Previous: 6e443d4 Ratio
es/full/bugs-1 342849 ns/iter (± 41711) 361939 ns/iter (± 22921) 0.95
es/full/minify/libraries/antd 1849686838 ns/iter (± 49179473) 1879049147 ns/iter (± 51778573) 0.98
es/full/minify/libraries/d3 423679509 ns/iter (± 23543023) 426887056 ns/iter (± 20217225) 0.99
es/full/minify/libraries/echarts 1550138874 ns/iter (± 69677661) 1628766252 ns/iter (± 64129017) 0.95
es/full/minify/libraries/jquery 101225832 ns/iter (± 1652205) 112470524 ns/iter (± 4836731) 0.90
es/full/minify/libraries/lodash 115895899 ns/iter (± 3760431) 122023835 ns/iter (± 3464950) 0.95
es/full/minify/libraries/moment 58812675 ns/iter (± 4418008) 62514744 ns/iter (± 2397199) 0.94
es/full/minify/libraries/react 19846156 ns/iter (± 428110) 28398882 ns/iter (± 3773869) 0.70
es/full/minify/libraries/terser 291308614 ns/iter (± 11540782) 320548862 ns/iter (± 15336117) 0.91
es/full/minify/libraries/three 537158095 ns/iter (± 5535730) 573034588 ns/iter (± 27757312) 0.94
es/full/minify/libraries/typescript 3297559709 ns/iter (± 27349424) 3414593614 ns/iter (± 103699721) 0.97
es/full/minify/libraries/victory 810724383 ns/iter (± 20774533) 809359567 ns/iter (± 20924197) 1.00
es/full/minify/libraries/vue 154261987 ns/iter (± 3503762) 150967955 ns/iter (± 8592983) 1.02
es/full/codegen/es3 32799 ns/iter (± 614) 33895 ns/iter (± 692) 0.97
es/full/codegen/es5 32861 ns/iter (± 896) 34523 ns/iter (± 1315) 0.95
es/full/codegen/es2015 32944 ns/iter (± 1024) 34616 ns/iter (± 1807) 0.95
es/full/codegen/es2016 33042 ns/iter (± 1493) 34252 ns/iter (± 841) 0.96
es/full/codegen/es2017 32856 ns/iter (± 493) 34931 ns/iter (± 1378) 0.94
es/full/codegen/es2018 32961 ns/iter (± 659) 34608 ns/iter (± 1568) 0.95
es/full/codegen/es2019 32829 ns/iter (± 833) 34578 ns/iter (± 1773) 0.95
es/full/codegen/es2020 32866 ns/iter (± 900) 34751 ns/iter (± 2853) 0.95
es/full/all/es3 189071197 ns/iter (± 11157902) 202913778 ns/iter (± 21095357) 0.93
es/full/all/es5 178319800 ns/iter (± 6482341) 191862860 ns/iter (± 14595776) 0.93
es/full/all/es2015 145170523 ns/iter (± 6618842) 152727360 ns/iter (± 27407229) 0.95
es/full/all/es2016 144029821 ns/iter (± 5628687) 149661576 ns/iter (± 12083063) 0.96
es/full/all/es2017 144696980 ns/iter (± 9172301) 153947292 ns/iter (± 15416343) 0.94
es/full/all/es2018 139067163 ns/iter (± 6894041) 144371346 ns/iter (± 9603016) 0.96
es/full/all/es2019 140477494 ns/iter (± 7344222) 150073870 ns/iter (± 10104309) 0.94
es/full/all/es2020 135078652 ns/iter (± 4366346) 147140016 ns/iter (± 10946679) 0.92
es/full/parser 714607 ns/iter (± 41380) 711098 ns/iter (± 34668) 1.00
es/full/base/fixer 26594 ns/iter (± 1643) 26760 ns/iter (± 1901) 0.99
es/full/base/resolver_and_hygiene 91512 ns/iter (± 4012) 94266 ns/iter (± 7924) 0.97
serialization of ast node 215 ns/iter (± 2) 218 ns/iter (± 9) 0.99
serialization of serde 211 ns/iter (± 3) 218 ns/iter (± 19) 0.97

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.