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

mangler: --keep-classnames and --keep-fnames #9711

Open
Boshen opened this issue Mar 12, 2025 · 0 comments
Open

mangler: --keep-classnames and --keep-fnames #9711

Boshen opened this issue Mar 12, 2025 · 0 comments
Assignees

Comments

@Boshen
Copy link
Member

Boshen commented Mar 12, 2025

    --keep-classnames           Do not mangle/drop class names.
    --keep-fnames               Do not mangle/drop function names.  Useful for
                                code relying on Function.prototype.name.

I'm not sure which one is better:

class Class {
}

esbuild --minify-identifiers --keep-names:

var c = Object.defineProperty;
var a = (s, l) => c(s, "name", { value: l, configurable: true });
class Class {
  static {
    a(this, "Class");
  }
}

or just keep the name as is.

@Boshen Boshen added the C-enhancement Category - New feature or request label Mar 12, 2025
@Boshen Boshen removed the C-enhancement Category - New feature or request label Mar 12, 2025
graphite-app bot pushed a commit that referenced this issue Mar 18, 2025
Added support for `keep_names: { function: true, class: true }`.
Setting `.name` is makes it difficult to treeshake later on (evanw/esbuild#3965), so it is better to avoid if possible.

This PR only adds support for the compressor. I'll add support for the mangler later on (probably first add required information to the semantics).

refs #9711
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants