Skip to content
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

Compress output for optional chain with multiple ?. #15740

Merged

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Jul 3, 2023

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT
  • The first commit is shared with Fix transform of delete a?.b in function params #15739.
  • The second commit optimizes transforming a?.b?.c from a == null ? void 0 : a.b == null ? void 0 : a.b.c to a == null || a.b == null ? void 0 : a.b.c, to only emit void 0 once.
  • The third commit optimizes transforming delete a?.b from a == null ? true : delete a.b to a == null || delete a.b.
  • The fourth commit optimizes transforming a()?.b?.c from var _tmp1, _tmp2; (_tmp1 == a()) == null || (_tmp2 = _tmp1.b) == null ? void 0 : _tmp2.c to var _tmp1; (_tmp1 == a()) == null || (_tmp1 = _tmp1.b) == null ? void 0 : _tmp1.c.

Terser doesn't do these optimization by itself, so this change also brings improvements to minified code.

@nicolo-ribaudo nicolo-ribaudo added Spec: Optional Chaining PR: Output optimization 🔬 A type of pull request used for our changelog categories labels Jul 3, 2023
@babel-bot
Copy link
Collaborator

babel-bot commented Jul 3, 2023

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/54764/

@nicolo-ribaudo nicolo-ribaudo force-pushed the optional-chaining-optimize branch 4 times, most recently from 6324cbb to 117cab1 Compare July 3, 2023 16:48
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

The output is much better, thank you!

@nicolo-ribaudo nicolo-ribaudo merged commit dc2cf48 into babel:main Jul 4, 2023
54 of 55 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the optional-chaining-optimize branch July 4, 2023 06:36
@nicolo-ribaudo
Copy link
Member Author

@SimenB Multiple PRs are failing with this (flaky) failure, but I fail to see how it can be Babel-related. However, it only fails for our "breaking" tests and not for the Babel 7 tests.
Do you have any idea of what might cause that unlinking error?

@SimenB
Copy link
Contributor

SimenB commented Jul 4, 2023

Hmmm, no. The test uses @babel/register tho, so there might be something to it.

I can update the test to use fs.rm with force instead - that should in theory be more tolerant to errors such as these and bubble up a better result? Or just ignore the failure if it doesn't matter.

2 times it fails to delete a file since it's not there, and once it fails to launch node since the file isn't there. Seems a bit odd... 😅

@SimenB
Copy link
Contributor

SimenB commented Jul 4, 2023

See jestjs/jest#14296

@nicolo-ribaudo
Copy link
Member Author

nicolo-ribaudo commented Jul 4, 2023

Thank you! I can test that PR in our CI to see if it makes the problem go away. Is it possible that those failure are just hiding a real error?

They started happening in #15736 🤔

@SimenB
Copy link
Contributor

SimenB commented Jul 4, 2023

I can test that PR in our CI to see if it makes the problem go away.

That'd be great 👍

Is it possible that those failure are just hiding a real error?

That's what I was thinking

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Output optimization 🔬 A type of pull request used for our changelog categories Spec: Optional Chaining
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants