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

Removing unused catch params breaks JS on older Apple devices #540

Closed
kamermans opened this issue Nov 1, 2022 · 3 comments
Closed

Removing unused catch params breaks JS on older Apple devices #540

kamermans opened this issue Nov 1, 2022 · 3 comments

Comments

@kamermans
Copy link

Hi, thanks for all your hard work!

I noticed you recently removed try/catch params if there are no parameter bindings: 2e77ff3

This produces statements like this:

try {
   1/0
} catch {
   console.log('Oops!')
}

This code is valid in most browsers, but not in older Apple devices (Safari on desktop or iPhones / iPads). So far this is the only incompatibility I've noticed when minifying JS for these platforms, and my only workaround is to explicitly reference the parameter so the minifier doesn't drop the param.

Here's what it looks like in a Safari console:
image

I'm not sure what level of compatibility you're aiming for, but if we could put this behind a flag or handle it differently, that would be great!

I am a Go developer, so if you'd like a PR, just let me know what path you'd like to go down.

@kamermans
Copy link
Author

kamermans commented Nov 1, 2022

This problem might be more widespread than I first thought. According to the sites I've checked, Optional Catch Binding was introduced in ES10 in 2019.

image
https://caniuse.com/mdn-javascript_statements_try_catch_optional_catch_binding

@tdewolff
Copy link
Owner

tdewolff commented Nov 3, 2022

Thanks for the issue, this should now be fixed by passing the Version = 2018 option to the JS minifier.

@kamermans
Copy link
Author

Awesome, thanks @tdewolff!

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

No branches or pull requests

2 participants