maybeParse.cjs.map 2.88 KB
{"version":3,"names":["babel","require","convert","getVisitorKeys","getTokLabels","extractParserOptionsPlugin","ref","extractParserOptionsConfigItem","MULTIPLE_OVERRIDES","module","exports","maybeParse","code","options","createConfigItem","dirname","__dirname","type","plugins","concat","parserOptions","parseSync","ast","err","test","message","error"],"sources":["../../src/worker/maybeParse.cjs"],"sourcesContent":["const babel = require(\"./babel-core.cjs\");\nconst convert = require(\"../convert/index.cjs\");\nconst { getVisitorKeys, getTokLabels } = require(\"./ast-info.cjs\");\nconst extractParserOptionsPlugin = require(\"./extract-parser-options-plugin.cjs\");\n\nconst ref = {};\nlet extractParserOptionsConfigItem;\n\nconst MULTIPLE_OVERRIDES = /More than one plugin attempted to override parsing/;\n\nmodule.exports = function maybeParse(code, options) {\n  if (!extractParserOptionsConfigItem) {\n    extractParserOptionsConfigItem = babel.createConfigItem(\n      [extractParserOptionsPlugin, ref],\n      { dirname: __dirname, type: \"plugin\" },\n    );\n  }\n  const { plugins } = options;\n  options.plugins = plugins.concat(extractParserOptionsConfigItem);\n\n  try {\n    return {\n      parserOptions: babel.parseSync(code, options),\n      ast: null,\n    };\n  } catch (err) {\n    if (!MULTIPLE_OVERRIDES.test(err.message)) {\n      throw err;\n    }\n  }\n\n  // There was already a parserOverride, so remove our plugin.\n  options.plugins = plugins;\n\n  let ast;\n  try {\n    ast = babel.parseSync(code, options);\n  } catch (err) {\n    throw convert.error(err);\n  }\n\n  return {\n    ast: convert.ast(ast, code, getTokLabels(), getVisitorKeys()),\n    parserOptions: null,\n  };\n};\n"],"mappings":"AAAA,MAAMA,KAAK,GAAGC,OAAO,CAAC,kBAAD,CAArB;;AACA,MAAMC,OAAO,GAAGD,OAAO,CAAC,sBAAD,CAAvB;;AACA,MAAM;EAAEE,cAAF;EAAkBC;AAAlB,IAAmCH,OAAO,CAAC,gBAAD,CAAhD;;AACA,MAAMI,0BAA0B,GAAGJ,OAAO,CAAC,qCAAD,CAA1C;;AAEA,MAAMK,GAAG,GA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