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
When the value of a switch case is hardcoded, either literally in code or through define option, esbuild does not treeshake the unreachable switch cases.
Thanks for the suggestion. I agree that this is something esbuild should be doing, as it's an easy win that could potentially lead to large size savings. This should also be added to esbuild's dead code analysis, which happens even without minification enabled (and which prunes edges in the module graph so they aren't even traversed in the first place during bundling).
When the value of a switch case is hardcoded, either literally in code or through
define
option, esbuild does not treeshake the unreachable switch cases.Reproduction
0.24.2
: https://esbuild.github.io/try/#dAAwLjI0LjIALS1taW5pZnkgAHN3aXRjaCAoImEiKSB7CiAgICBjYXNlICJhIjogewogICAgICBjb25zb2xlLmxvZygiYSIpOwogICAgfQogICAgY2FzZSAiYiI6IHsKICAgICAgY29uc29sZS5sb2coImIiKTsKICAgIH0KICB9Expected output after minification:
The text was updated successfully, but these errors were encountered: