You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The name of functions that infer their names from a variable name is being removed when babel-plugin-minify-dead-code-elimination is used with the keepFnNames option enabled.
All of these function definitions hav the name "func":
The issue seems to be coming from inlining the variable into the return of the function, losing the variable name to infer the function name from.
Additional context
I discovered this when function names were being stripped out of stack traces in error logs.
It also seems particularly problematic for React HOCs where the displayName for the wrapping component is derived from the function name for a function component, e.g.
Describe the bug
The name of functions that infer their names from a variable name is being removed when
babel-plugin-minify-dead-code-elimination
is used with thekeepFnNames
option enabled.All of these function definitions hav the name "func":
If we return these definitions from a wrapping function before logging the name, the first two will retain the name from their definitions:
However, the second two have lost their names:
To Reproduce
Minimal code to reproduce the bug
Actual Output
If there is no Error thrown,
Expected Output
Configuration
How are you using babel-minify?
babelrc.js:
Possible solution
The issue seems to be coming from inlining the variable into the return of the function, losing the variable name to infer the function name from.
Additional context
I discovered this when function names were being stripped out of stack traces in error logs.
It also seems particularly problematic for React HOCs where the
displayName
for the wrapping component is derived from the function name for a function component, e.g.The text was updated successfully, but these errors were encountered: