index.js 702 B

123456789101112131415161718192021222324252627282930313233
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _helperPluginUtils = require("@babel/helper-plugin-utils");
  7. var _core = require("@babel/core");
  8. var _default = (0, _helperPluginUtils.declare)(api => {
  9. api.assertVersion(7);
  10. return {
  11. name: "transform-property-literals",
  12. visitor: {
  13. ObjectProperty: {
  14. exit({
  15. node
  16. }) {
  17. const key = node.key;
  18. if (!node.computed && _core.types.isIdentifier(key) && !_core.types.isValidES3Identifier(key.name)) {
  19. node.key = _core.types.stringLiteral(key.name);
  20. }
  21. }
  22. }
  23. }
  24. };
  25. });
  26. exports.default = _default;