import { parse as babelParse } from "@babel/parser" ; import getBabelOptions , { Overrides } from "./_babel_options" ; type BabelParser = { parse : typeof babelParse ; } ; export const parser = function ( ) : BabelParser { try { return require ( "@babel/parser" ) ; } catch ( e ) { return require ( "babylon" ) ; } } ( ) ; export function parse ( source , options ? ) { const babelOptions = getBabelOptions ( options ) ; babelOptions . plugins . push ( "jsx" , "flow" ) ; return parser . parse ( source , babelOptions ) ; } ;