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

Minifier should use optional catch binding #8966

Closed
NotWearingPants opened this issue May 21, 2024 · 1 comment · Fixed by #9657
Closed

Minifier should use optional catch binding #8966

NotWearingPants opened this issue May 21, 2024 · 1 comment · Fixed by #9657
Milestone

Comments

@NotWearingPants
Copy link

Describe the feature

Input:

try {
    console.log("hello");
} catch (e) {}

Output:

try{console.log("hello")}catch(e){}

Expected output (more minified):

try{console.log("hello")}catch{}

I turned on minify & compress, and set the target to ES2022, so the target supports optional catch binding and the minifier can take advantage of it and remove the catch binding (e).

Babel plugin or link to the feature description

No response

Additional context

No response

@kdy1 kdy1 self-assigned this May 23, 2024
@kdy1 kdy1 added this to the Planned milestone May 23, 2024
@kdy1 kdy1 removed their assignment Jul 29, 2024
kdy1 pushed a commit that referenced this issue Oct 20, 2024
**Description:**

I think removing `!v.declared_as_catch_param` is safe, since I can't think of a bad case:
1. for the vars in the params of catch-clause, we prevent the removal if `self.options.ecma < EsVersion::Es2019 || !self.options.unused` is not satisfied.
2. for the usages or re-declarations with the same var name in the body of catch-clause, I think it's safe to remove them.


**Related issue:**

 - Closes #8966
@kdy1 kdy1 modified the milestones: Planned, v1.7.37 Oct 21, 2024
@swc-bot
Copy link
Collaborator

swc-bot commented Nov 20, 2024

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

3 participants