UNPKG

2.89 kBSource Map (JSON)View Raw
1{"version":3,"sources":["../../src/utils/babel-parse-to-ast.js"],"names":["parser","require","PARSER_OPTIONS","allowImportExportEverywhere","allowReturnOutsideFunction","allowSuperOutsideMethod","sourceType","sourceFilename","plugins","decoratorsBeforeExport","proposal","getBabelParserOptions","filePath","test","map","plugin","babelParseToAst","contents","parse"],"mappings":";;;;;;AACA,MAAMA,MAAM,GAAGC,OAAO,CAAE,eAAF,CAAtB;;AAEA,MAAMC,cAAc,GAAG;AACrBC,EAAAA,2BAA2B,EAAE,IADR;AAErBC,EAAAA,0BAA0B,EAAE,IAFP;AAGrBC,EAAAA,uBAAuB,EAAE,IAHJ;AAIrBC,EAAAA,UAAU,EAAG,aAJQ;AAKrBC,EAAAA,cAAc,EAAE,IALK;AAMrBC,EAAAA,OAAO,EAAE,CACN,KADM,EAEN,MAFM,EAGN,eAHM,EAIN,kBAJM,EAKP,CACG,YADH,EAEE;AACEC,IAAAA,sBAAsB,EAAE;AAD1B,GAFF,CALO,EAWN,iBAXM,EAYN,wBAZM,EAaN,qBAbM,EAcN,mBAdM,EAeN,qBAfM,EAgBN,iBAhBM,EAiBN,cAjBM,EAkBN,cAlBM,EAmBN,eAnBM,EAoBN,kBApBM,EAqBN,kBArBM,EAsBN,YAtBM,EAuBN,QAvBM,EAwBN,sBAxBM,EAyBN,kBAzBM,EA0BP,CACG,kBADH,EAEE;AACEC,IAAAA,QAAQ,EAAG;AADb,GAFF,CA1BO,EAgCN,2BAhCM;AANY,CAAvB;;AA0CO,SAASC,qBAAT,CAA+BC,QAA/B,EAAiD;AACtD;AACA,MAAI,SAASC,IAAT,CAAcD,QAAd,CAAJ,EAA6B;AAC3B,UAAM;AAAEJ,MAAAA;AAAF,QAAcN,cAApB;AACA,6BACKA,cADL;AAEEM,MAAAA,OAAO,EAAEA,OAAO,CAACM,GAAR,CAAYC,MAAM,IACzBA,MAAM,KAAM,MAAZ,GAAqB,YAArB,GAAmCA,MAD5B;AAFX;AAMD;;AACD,SAAOb,cAAP;AACD;;AAEM,SAASc,eAAT,CAAyBC,QAAzB,EAA2CL,QAA3C,EAA6D;AAClE,SAAOZ,MAAM,CAACkB,KAAP,CAAaD,QAAb,EAAuBN,qBAAqB,CAACC,QAAD,CAA5C,CAAP;AACD","sourcesContent":["/* @flow */\nconst parser = require(`@babel/parser`)\n\nconst PARSER_OPTIONS = {\n allowImportExportEverywhere: true,\n allowReturnOutsideFunction: true,\n allowSuperOutsideMethod: true,\n sourceType: `unambigious`,\n sourceFilename: true,\n plugins: [\n `jsx`,\n `flow`,\n `doExpressions`,\n `objectRestSpread`,\n [\n `decorators`,\n {\n decoratorsBeforeExport: true,\n },\n ],\n `classProperties`,\n `classPrivateProperties`,\n `classPrivateMethods`,\n `exportDefaultFrom`,\n `exportNamespaceFrom`,\n `asyncGenerators`,\n `functionBind`,\n `functionSent`,\n `dynamicImport`,\n `numericSeparator`,\n `optionalChaining`,\n `importMeta`,\n `bigInt`,\n `optionalCatchBinding`,\n `throwExpressions`,\n [\n `pipelineOperator`,\n {\n proposal: `minimal`,\n },\n ],\n `nullishCoalescingOperator`,\n ],\n}\n\nexport function getBabelParserOptions(filePath: string) {\n // Flow and TypeScript plugins can't be enabled simultaneously\n if (/\\.tsx?/.test(filePath)) {\n const { plugins } = PARSER_OPTIONS\n return {\n ...PARSER_OPTIONS,\n plugins: plugins.map(plugin =>\n plugin === `flow` ? `typescript` : plugin\n ),\n }\n }\n return PARSER_OPTIONS\n}\n\nexport function babelParseToAst(contents: string, filePath: string) {\n return parser.parse(contents, getBabelParserOptions(filePath))\n}\n"],"file":"babel-parse-to-ast.js"}
\No newline at end of file