evanw / esbuild

An extremely fast bundler for the web
https://esbuild.github.io/
MIT License
37.59k stars 1.11k forks source link

Destructuring bug in Safari when renamed parameter property is identical to the function name #3786

Open kripod opened 1 month ago

kripod commented 1 month ago

Trying swc in debug mode with env.targets set to browserslist("defaults") and env.bugfixes enabled, I noticed the transform ‘bugfix/transform-safari-id-destructuring-collision-in-function-expression’ being applied.

Looking up the corresponding docs of Babel, I figured the following snippet throws a SyntaxError up until Safari 16.2 as per this bug report:

let b = function a({ test: a }) { console.log(a); };

Running esbuild on the code, it appears the project doesn’t apply a fix like Babel or swc does.

Please consider implementing a workaround as applied by Babel:

let b = function a({ test: _a }) { console.log(_a); };

Thank you in advance!