index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _helperCompilationTargets = require("@babel/helper-compilation-targets");
  7. var _helperPluginUtils = require("@babel/helper-plugin-utils");
  8. var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
  9. api.assertVersion(7);
  10. const supportUnicodeId = !(0, _helperCompilationTargets.isRequired)("transform-unicode-escapes", api.targets());
  11. return {
  12. name: "transform-function-name",
  13. visitor: {
  14. FunctionExpression: {
  15. exit(path) {
  16. if (path.key !== "value" && !path.parentPath.isObjectProperty()) {
  17. {
  18. var _path$ensureFunctionN;
  19. (_path$ensureFunctionN = path.ensureFunctionName) != null ? _path$ensureFunctionN : path.ensureFunctionName = require("@babel/traverse").NodePath.prototype.ensureFunctionName;
  20. }
  21. path.ensureFunctionName(supportUnicodeId);
  22. }
  23. }
  24. },
  25. ObjectProperty(path) {
  26. const value = path.get("value");
  27. if (value.isFunction()) {
  28. {
  29. var _value$ensureFunction;
  30. (_value$ensureFunction = value.ensureFunctionName) != null ? _value$ensureFunction : value.ensureFunctionName = require("@babel/traverse").NodePath.prototype.ensureFunctionName;
  31. }
  32. value.ensureFunctionName(supportUnicodeId);
  33. }
  34. }
  35. }
  36. };
  37. });
  38. //# sourceMappingURL=index.js.map