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

Classes with constant computed property names aren't three-shaken #3940

Open
unilynx opened this issue Oct 9, 2024 · 0 comments
Open

Classes with constant computed property names aren't three-shaken #3940

unilynx opened this issue Oct 9, 2024 · 0 comments

Comments

@unilynx
Copy link

unilynx commented Oct 9, 2024

The following code is not being tree shaken awy:

const prop = "prop";

class Money {
  [prop] = true;

  constructor() {
  }
}

.bin/esbuild test.ts --minify --bundle --format=esm --target=esnext returns: var c="prop",r=class{[c]=!0;constructor(){}}; - I'd expect nothing

Setting the prop to a Symbol() or Symbol.for(...) (which is what I was actually trying to do) doesn't work either

If I replace prop with a constant it does work:

class Money {
  ["prop"] = true;

  constructor() {
  }
}

(no output)

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

No branches or pull requests

2 participants