GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Compress output for optional chain with multiple `?.` by nicolo-ribaudo · Pull Request #15740 · babel/babel

Conversation

@nicolo-ribaudo

@nicolo-ribaudo nicolo-ribaudo commented Jul 3, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JLHwung reacted with rocket emoji
All reactions
  • 🚀 1 reaction
@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

babel-bot commented Jul 3, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@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
JLHwung
JLHwung approved these changes Jul 3, 2023
View reviewed changes

@JLHwung JLHwung left a comment

Copy link
Copy Markdown
Contributor

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 is much better, thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

liuxingbaoyu reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
liuxingbaoyu
liuxingbaoyu approved these changes Jul 3, 2023
View reviewed changes
nicolo-ribaudo added 3 commits July 4, 2023 07:22
@nicolo-ribaudo
Compress output for optional chain with multiple ?.
e888168
@nicolo-ribaudo
Shorter output for optional delete
2933366
@nicolo-ribaudo
Use a single temp variable per optional chain
f4bf0ba
@nicolo-ribaudo
nicolo-ribaudo force-pushed the optional-chaining-optimize branch from 117cab1 to f4bf0ba Compare July 4, 2023 05:24
@nicolo-ribaudo
nicolo-ribaudo merged commit dc2cf48 into babel:main Jul 4, 2023
@nicolo-ribaudo
nicolo-ribaudo deleted the optional-chaining-optimize branch July 4, 2023 06:36
@nicolo-ribaudo

nicolo-ribaudo commented Jul 4, 2023

Copy link
Copy Markdown
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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SimenB

SimenB commented Jul 4, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

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... 😅

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SimenB SimenB mentioned this pull request Jul 4, 2023
chore: use fs.rm instead of fs.unlink in test jestjs/jest#14296
Merged
@SimenB

SimenB commented Jul 4, 2023

Copy link
Copy Markdown
Contributor

See jestjs/jest#14296

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicolo-ribaudo

nicolo-ribaudo commented Jul 4, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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 🤔

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@SimenB

SimenB commented Jul 4, 2023

Copy link
Copy Markdown
Contributor

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicolo-ribaudo nicolo-ribaudo mentioned this pull request Aug 17, 2023
Simplify ?. output when chain result is ignored #15871
Merged
@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.

Reviewers

@JLHwung JLHwung JLHwung approved these changes
@liuxingbaoyu liuxingbaoyu liuxingbaoyu approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

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

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@nicolo-ribaudo @babel-bot @SimenB @JLHwung @liuxingbaoyu
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.