Skip to content

dead code containing try/catch not removed when minifying #4224

@mathieudutour

Description

@mathieudutour

The following code

return "foo";
  
try { return "bar" } catch {}

is minified into

return"foo";try{return"bar"}catch{}

I would have expect it to be just return"foo".

Is there anything about try/catch blocks that make them impossible to remove?

Repro link: https://esbuild.github.io/try/#YgAwLjI1LjUAeyBtaW5pZnk6IHRydWUgfQBlAGVudHJ5LmpzAHJldHVybiAiZm9vIjsKICAKdHJ5IHsgcmV0dXJuICJiYXIiIH0gY2F0Y2gge30

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions