-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Repl
Input code
Current and expected behavior
In the linked REPL, the n on line 6 should resolve to the n from the Ki function signature on line 3. However at the very bottom of the transpiled output, the n is turned into _react.useLayoutEffect which is incorrect. The function-scoped n should shadow the module-scoped n
Environment
See repl link
Targets >0.01%, not ie 11, not ie_mob 11
Modules commonjs
The rest left as default (v7.28.4)
Possible solution
The function n() {} on line 5 is necessary for this bug to happen. So it seems like that line is somehow confusing babel about the scope of the final n
This also only happens when modules is set to commonjs and targets is >0.01%
Additional context
We experienced this in the wild when testing our pre-minified library in codesandbox and narrowed it down to the code you see in the linked repl