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

Create bugfix plugin for classes in computed keys in Firefox #16390

Merged
merged 3 commits into from Mar 31, 2024

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Mar 28, 2024

Q                       A
Fixed Issues? Fixes #16379
Patch: Bug Fix? Y
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link babel/website#2885
Any Dependency Changes?
License MIT

This PR adds a plugin to compile

class A {
  #x = 42;
  [class {}];
} 

to

class A {
  #x = 42;
  [(() => class {}).call()];
} 

in Firefox, so that it doesn't throw a syntax error.

@nicolo-ribaudo nicolo-ribaudo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Mar 28, 2024
Comment on lines +167 to +170
overwrite: {
// TODO: Once Firefox releases the fix, write the correct version here.
firefox: undefined,
},
Copy link
Member Author

Choose a reason for hiding this comment

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

For tiny browser bugs this is probably easier than having to go through compat-table.

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 28, 2024

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

async function* f() {
class A {
#x;
[(() => class {}).call()];
Copy link
Member Author

Choose a reason for hiding this comment

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

We need to add .call() here to prevent Terser from undoing the work done by this plugin: terser/terser#1514

Copy link
Member

Choose a reason for hiding this comment

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

I think this is fine, because it is possible that more than just terser will do this (or may do so in the future).

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.

Awesome.

Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

👍

@nicolo-ribaudo
Copy link
Member Author

I'm preparing a docs PR.

@nicolo-ribaudo nicolo-ribaudo merged commit 48a3e19 into babel:main Mar 31, 2024
51 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the firefox-bugfix branch March 31, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i: browser bug PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Code generated by Babel for decorated static accessors throws SyntaxError in Firefox
4 participants