index.js 761 B

12345678910111213141516171819202122232425262728293031323334
  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-member-expression-literals",
  12. visitor: {
  13. MemberExpression: {
  14. exit({
  15. node
  16. }) {
  17. const prop = node.property;
  18. if (!node.computed && _core.types.isIdentifier(prop) && !_core.types.isValidES3Identifier(prop.name)) {
  19. node.property = _core.types.stringLiteral(prop.name);
  20. node.computed = true;
  21. }
  22. }
  23. }
  24. }
  25. };
  26. });
  27. exports.default = _default;