WIP - add extractor, generate snippet_data
This commit is contained in:
41
node_modules/babel-plugin-add-module-exports/lib/index.js
generated
vendored
Normal file
41
node_modules/babel-plugin-add-module-exports/lib/index.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (_ref) {
|
||||
var types = _ref.types;
|
||||
return {
|
||||
visitor: {
|
||||
Program: {
|
||||
exit: function exit(path) {
|
||||
if (path.BABEL_PLUGIN_ADD_MODULE_EXPORTS) {
|
||||
return;
|
||||
}
|
||||
|
||||
var hasExportDefault = false;
|
||||
var hasExportNamed = false;
|
||||
path.get('body').forEach(function (path) {
|
||||
if (path.isExportDefaultDeclaration()) {
|
||||
hasExportDefault = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (path.isExportNamedDeclaration()) {
|
||||
if (path.node.specifiers.length === 1 && path.node.specifiers[0].exported.name === 'default') {
|
||||
hasExportDefault = true;
|
||||
} else {
|
||||
hasExportNamed = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
if (hasExportDefault && !hasExportNamed) {
|
||||
path.pushContainer('body', [types.expressionStatement(types.assignmentExpression('=', types.memberExpression(types.identifier('module'), types.identifier('exports')), types.memberExpression(types.identifier('exports'), types.stringLiteral('default'), true)))]);
|
||||
}
|
||||
|
||||
path.BABEL_PLUGIN_ADD_MODULE_EXPORTS = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/babel-plugin-add-module-exports/lib/index.js.map
generated
vendored
Normal file
1
node_modules/babel-plugin-add-module-exports/lib/index.js.map
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
{"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"]}
|
||||
Reference in New Issue
Block a user