Fix unicode handling in generated function names (#14047)
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-compilation-targets": "workspace:^",
|
||||
"@babel/helper-function-name": "workspace:^",
|
||||
"@babel/helper-plugin-utils": "workspace:^"
|
||||
},
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import { isRequired } from "@babel/helper-compilation-targets";
|
||||
import { declare } from "@babel/helper-plugin-utils";
|
||||
import nameFunction from "@babel/helper-function-name";
|
||||
|
||||
export default declare(api => {
|
||||
api.assertVersion(7);
|
||||
const supportUnicodeId = !isRequired(
|
||||
"transform-unicode-escapes",
|
||||
api.targets(),
|
||||
);
|
||||
|
||||
return {
|
||||
name: "transform-function-name",
|
||||
@@ -20,7 +25,7 @@ export default declare(api => {
|
||||
ObjectProperty(path) {
|
||||
const value = path.get("value");
|
||||
if (value.isFunction()) {
|
||||
const newNode = nameFunction(value);
|
||||
const newNode = nameFunction(value, false, supportUnicodeId);
|
||||
if (newNode) value.replaceWith(newNode);
|
||||
}
|
||||
},
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
var o = {
|
||||
"\uD835\uDC9C"() {}
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["transform-function-name", "transform-shorthand-properties"],
|
||||
"targets": { "firefox": 52 }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
var o = {
|
||||
"\uD835\uDC9C": function () {}
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
var o = {
|
||||
"\uD835\uDC9C"() {}
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"plugins": ["transform-function-name", "transform-shorthand-properties"],
|
||||
"targets": { "firefox": 60 }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
var o = {
|
||||
"\uD835\uDC9C": function 𝒜() {}
|
||||
};
|
||||
Reference in New Issue
Block a user