UNPKG

2.88 kBSource Map (JSON)View Raw
1{"version":3,"names":["_helperPluginUtils","require","_defineMap","_core","_default","exports","default","declare","api","assertVersion","name","visitor","ObjectExpression","path","node","mutatorMap","newProperties","properties","filter","prop","t","isObjectMethod","computed","kind","_mutatorMap","pushAccessor","undefined","replaceWith","callExpression","memberExpression","identifier","toDefineObject"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { type MutatorMap, pushAccessor, toDefineObject } from \"./define-map.ts\";\nimport { types as t } from \"@babel/core\";\n\nexport default declare(api => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n return {\n name: \"transform-property-mutators\",\n\n visitor: {\n ObjectExpression(path) {\n const { node } = path;\n let mutatorMap: MutatorMap | undefined;\n const newProperties = node.properties.filter(function (prop) {\n if (\n t.isObjectMethod(prop) &&\n !prop.computed &&\n (prop.kind === \"get\" || prop.kind === \"set\")\n ) {\n pushAccessor(\n (mutatorMap ??= {}),\n prop as t.ObjectMethod & { kind: \"get\" | \"set\"; computed: false },\n );\n return false;\n }\n return true;\n });\n\n if (mutatorMap === undefined) {\n return;\n }\n\n node.properties = newProperties;\n\n path.replaceWith(\n t.callExpression(\n t.memberExpression(\n t.identifier(\"Object\"),\n t.identifier(\"defineProperties\"),\n ),\n [node, toDefineObject(mutatorMap)],\n ),\n );\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAyC,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAE1B,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAAkB,CAAE,CAAC;EAEtC,OAAO;IACLC,IAAI,EAAE,6BAA6B;IAEnCC,OAAO,EAAE;MACPC,gBAAgBA,CAACC,IAAI,EAAE;QACrB,MAAM;UAAEC;QAAK,CAAC,GAAGD,IAAI;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