You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
keep_classnames doesn't work with var MyClass = class {} when using toplevel: true #1484
We are using terser to minify a library meant to be used by other developers.
The fact that terser mangles the class names in the demonstrated manner makes so that users of our library will see minified classnames when inspecting objects in the dev inspector in chrome, for example. Chrome (and node, and others probably too) use the var name to assign a name to the class.
The demonstrated mangling breaks that. I would expect keep_classnames to prevent this, just as it does in the direct class definition (Foo). These statements (var X = class {}) are generated by esbuild during bundling, so we don't have much control over that.
This is very inconsistent with keep_fnames which works as you expect.
The second case is definitely valid as well, and should apply to keep_fnames too. With keep_fnames/keep_classnames, moving a class/function should either retain its .name property or not happen at all.
Activity
janv commentedon Jan 4, 2024
I have discovered an additional bug, that I'm not sure is related to this one.
If it's not, please let me know and I'll open a new issue.
With this config:
And this input:
The output I get is
The name
Yis mangled/dropped, even though it's on thereservedlist andkeep_classnamesis on.The issue disappears if I change the syntax of the default output:
fabiosantoscode commentedon Jan 16, 2024
This is very inconsistent with
keep_fnameswhich works as you expect.The second case is definitely valid as well, and should apply to
keep_fnamestoo. Withkeep_fnames/keep_classnames, moving a class/function should either retain its.nameproperty or not happen at all.