esbuild
esbuild copied to clipboard
[Feature Request]: Provide a way to selectively keep class / function names
The "keep names" option is sometimes necessary for certain use cases; however, it might significantly increase the bundle size in large projects, even if all one needs is to keep the names of a few classes. (my use case)
Would it be possible to add a way to specify a list of directories in which to keep the names? Or, perhaps even better, specify a regular expression for the name and/or add a special comment that would apply the rule to the class/function. I looked through the documentation and couldn't find such an option.
You can do this by yourself:
class A {}
Object.defineProperty(A, "name", { value: "A", configurable: true })
Interesting solution, but quite cumbersome and error-prone, in my opinion. Could something similar be implemented for classes extending a base class? Obviously, I can't use A.name
in the expression 😕