-
-
Notifications
You must be signed in to change notification settings - Fork 374
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
Do not inline IIFEs inside computed keys in classes that contain private fields #1514
Comments
I also tried with export class A {
#x = 1;
[/*@__NOINLINE__*/ (() => class {})()];
} but the arrow function is still inlined. |
It sounds like that bug has just been fixed in the latest Firefox nightly, so I don't know how much value there is in trying to work around it now in Terser. You may be able to prevent Terser from inlining this with the |
This is for Babel-generated code, so we cannot rely on specific Terser options (because we cannot force all users to use them). Given that terser has even an option for Safari 10, I was assuming that the goal is not only to generate code that works in the latest version of browsers but also in older ones (I don't think an option makes sense in this case, since it's a very specific edge case and Terser could unconditionally leave that code as-is). I'm willing to open a PR if it would be accepted. |
This isn't the first browser bug that pops up on computed keys, and often we don't need to optimize anything within, so I'm deoptimizing them. |
Thank you! |
Bug report or Feature request?
Bug report? Not sure
Version (complete output of
terser -V
or specific git commit)Whatever is at try.terser.org on 2024-03-28
Complete CLI command or
minify()
options usedterser
inputterser
output or errorExpected result
In all existing Firefox versions that support private fields, the original code works but the minified version throws due to a bug (https://bugzilla.mozilla.org/show_bug.cgi?id=1887677).
We received a bug report in Babel about the wrong output, so we are implementing a plugin to wrap computed keys in a IIFE if they contain a class. It would be great if terser didn't then strip the IIFE, making the code fixed by Babel break again :)
The text was updated successfully, but these errors were encountered: