New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use function
rather than var
to compile private methods
#12990
Use function
rather than var
to compile private methods
#12990
Conversation
|
||
})); | ||
|
||
function _foo2() {} |
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.
The output on main
is
var _foo, _temp, _foo2;
console.log((_temp = (_foo = new WeakSet(), class A {
constructor() {
_foo.add(this);
}
method() {
babelHelpers.classPrivateMethodGet(this, _foo, _foo2).call(this);
}
}), _foo2 = function _foo2() {}, _temp));
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/44199/ |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 3a244cf:
|
I was working on a prototype for #12849 (comment), and I noticed this small output optimization that lets us save a few bytes for each private method.