unjs / hookable

🪝 Awaitable Hooks
MIT License
665 stars 26 forks source link

Uncaught SyntaxError: Unexpected token { #95

Closed denghui1010 closed 5 months ago

denghui1010 commented 5 months ago

Environment

Android 8 iOS 13.3

Reproduction

no

Describe the bug

in some low version webview, like andorid 8

try {
} catch {}

is wrong

image

this should be

try {
} catch (err) {}

Additional context

No response

Logs

Uncaught SyntaxError: Unexpected token {
NozomuIkuta commented 5 months ago

Final decision will be made by the author, but IMHO, optional catch binding is old enough to be available in most environments.

While adding argument is just a one-line fix, the action means that maintainers will continue to support legacy environments, and we have to make a decision to drop legacy environments at some point in future after all.

That's because otherwise we could not keep packages valuable for users for foture (e.g. transpiling TS to old version JS would weigh the package size due to patch code / Vue dropped IE support to use Proxy). By the way, at the moment, hookable is CI-tested with Node.js 16 , whose support was already ended last year.

Although I do know supporting legacy environments is important in some context (I used to do the job in the past!), I am also for that OSS should be open for future enhancement, as one of OSS maintainers.

In this time, while waiting for the authors decision, I provide some information by which you could overcome the situation without upstream changes.

Transpiling dependency

Although I don't know details of your development tooling, you might be able to let bundler transpile your dependency on build by setting some options.

Patching package

Another approach is to patch dependency.

Whichever the author fixes the code or you modify your code, I hope my comment help you resolve the issue somewhat 🙌

pi0 commented 5 months ago

Nothing to add on top of what @NozomuIkuta said 💯 Still if you are in a situation that locked in (for example a framework that uses older version of Webpack without syntax support, please mention so we can follow this up here or there.)