index.js.map 2.25 KB
{"version":3,"sources":["../src/index.js"],"names":[],"mappings":";;AAAA,OAAO,OAAP,GAAiB;AAAA,MAAE,KAAF,QAAE,KAAF;AAAA,SAAc;AAC7B,aAAS;AACP,eAAS;AACP,YADO,gBACD,IADC,EACK;AACV,cAAI,KAAK,+BAAT,EAA0C;AACxC;AACD;;AAED,cAAI,mBAAmB,KAAvB;AACA,cAAI,iBAAiB,KAArB;AACA,eAAK,GAAL,CAAS,MAAT,EAAiB,OAAjB,CAAyB,UAAC,IAAD,EAAU;AACjC,gBAAI,KAAK,0BAAL,EAAJ,EAAuC;AACrC,iCAAmB,IAAnB;AACA;AACD;;AAED,gBAAI,KAAK,wBAAL,EAAJ,EAAqC;AACnC,kBAAI,KAAK,IAAL,CAAU,UAAV,CAAqB,MAArB,KAAgC,CAAhC,IAAqC,KAAK,IAAL,CAAU,UAAV,CAAqB,CAArB,EAAwB,QAAxB,CAAiC,IAAjC,KAA0C,SAAnF,EAA8F;AAC5F,mCAAmB,IAAnB;AACD,eAFD,MAEO;AACL,iCAAiB,IAAjB;AACD;AACD;AACD;AACF,WAdD;;AAgBA,cAAI,oBAAoB,CAAC,cAAzB,EAAyC;AACvC,iBAAK,aAAL,CAAmB,MAAnB,EAA2B,CACzB,MAAM,mBAAN,CAA0B,MAAM,oBAAN,CACxB,GADwB,EAExB,MAAM,gBAAN,CAAuB,MAAM,UAAN,CAAiB,QAAjB,CAAvB,EAAmD,MAAM,UAAN,CAAiB,SAAjB,CAAnD,CAFwB,EAGxB,MAAM,gBAAN,CAAuB,MAAM,UAAN,CAAiB,SAAjB,CAAvB,EAAoD,MAAM,aAAN,CAAoB,SAApB,CAApD,EAAoF,IAApF,CAHwB,CAA1B,CADyB,CAA3B;AAOD;;AAED,eAAK,+BAAL,GAAuC,IAAvC;AACD;AAnCM;AADF;AADoB,GAAd;AAAA,CAAjB","file":"index.js","sourcesContent":["module.exports = ({types}) => ({\n  visitor: {\n    Program: {\n      exit (path) {\n        if (path.BABEL_PLUGIN_ADD_MODULE_EXPORTS) {\n          return\n        }\n\n        let hasExportDefault = false\n        let hasExportNamed = false\n        path.get('body').forEach((path) => {\n          if (path.isExportDefaultDeclaration()) {\n            hasExportDefault = true\n            return\n          }\n\n          if (path.isExportNamedDeclaration()) {\n            if (path.node.specifiers.length === 1 && path.node.specifiers[0].exported.name === 'default') {\n              hasExportDefault = true\n            } else {\n              hasExportNamed = true\n            }\n            return\n          }\n        })\n\n        if (hasExportDefault && !hasExportNamed) {\n          path.pushContainer('body', [\n            types.expressionStatement(types.assignmentExpression(\n              '=',\n              types.memberExpression(types.identifier('module'), types.identifier('exports')),\n              types.memberExpression(types.identifier('exports'), types.stringLiteral('default'), true)\n            ))\n          ])\n        }\n\n        path.BABEL_PLUGIN_ADD_MODULE_EXPORTS = true\n      }\n    }\n  }\n})\n"]}