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
optimize optional chain when expression will be cast to boolean #12291
optimize optional chain when expression will be cast to boolean #12291
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/32610/ |
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 9b38e9c:
|
3f3a41c
to
645910b
Compare
645910b
to
d51cf4b
Compare
}, { | ||
key: "testConditional", | ||
value: function testConditional(o) { | ||
return (o === null || o === void 0 ? void 0 : babelHelpers.classPrivateFieldLooseBase(o, _a)[_a].b)?.c.d ? true : false; |
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 here is not ideal because willPathCastToBoolean
stops at the optional chain ?.c.d
. I think such cases are rare and we could iterate later.
d51cf4b
to
d89d30e
Compare
packages/babel-helper-member-expression-to-functions/src/index.js
Outdated
Show resolved
Hide resolved
d89d30e
to
1dce17e
Compare
]; | ||
|
||
describe("default parser options", () => { | ||
test.each(positiveCases.map(x => [x]))( |
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.
What is the .map(x => [x])
needed for?
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.
Ahh Jest will internally map 1-D array to 2-D: https://jestjs.io/docs/en/api#1-testeachtablename-fn-timeout
will update later.
…er-expression-to-functions
ebbbfbf
to
9b38e9c
Compare
In the last commit we use rollup on The local build results looks good to me Rollup build:
|
This PR is inspired from #10004 but fixes the violation to spec.
You can see here the output difference
Input
Output (before this PR)
Terser output (before this PR): 168 Byte
Output (after this PR)
Terser output (after this PR): 146 Byte
Todo:
packages/babel-helper-member-expression-to-functions/src/index.js