-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Copy link
Description
💻
- Would you like to work on a fix?
How are you using Babel?
babel-loader (webpack)
Input code
switch ('what') {
default:
console.log(a())
function a() { return 1; }
}Configuration file name
No response
Configuration
{
"loose": true,
"forceAllTransforms": true,
"exclude": ["@babel/transform-function-name"]
}Current and expected behaviour
Current output which results in exceptions:
"use strict";
switch ('what') {
default:
console.log(a());
var a = function a() {
return 1;
};
}We had some problems inside IE8 according to #1087 (comment), so we excluded @babel/transform-function-name, and we got output :
"use strict";
switch ('what') {
default:
console.log(a());
var a = function () {
return 1;
};
}Expected output:
"use strict";
switch ('what') {
default:
console.log(a());
function a() {
return 1;
};
}Environment
@babel/core: 7.18.13@babel/preset-env: 7.18.10
Possible solution
Even in the switch case block, babel should analysis whether the function is called before doing the tranformation.
Additional context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels