remove es20xx prefixes from plugins and rename folders (#6575)
This commit is contained in:
24
packages/babel-plugin-transform-function-name/src/index.js
Normal file
24
packages/babel-plugin-transform-function-name/src/index.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import nameFunction from "@babel/helper-function-name";
|
||||
|
||||
export default function() {
|
||||
return {
|
||||
visitor: {
|
||||
FunctionExpression: {
|
||||
exit(path) {
|
||||
if (path.key !== "value" && !path.parentPath.isObjectProperty()) {
|
||||
const replacement = nameFunction(path);
|
||||
if (replacement) path.replaceWith(replacement);
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
ObjectProperty(path) {
|
||||
const value = path.get("value");
|
||||
if (value.isFunction()) {
|
||||
const newNode = nameFunction(value);
|
||||
if (newNode) value.replaceWith(newNode);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user