| 41 | import {transformFromAstSync} from '@babel/core'; |
| 42 | |
| 43 | function parseInput( |
| 44 | input: string, |
| 45 | language: 'flow' | 'typescript', |
| 46 | ): ParseResult<t.File> { |
| 47 | // Extract the first line to quickly check for custom test directives |
| 48 | if (language === 'flow') { |
| 49 | return HermesParser.parse(input, { |
| 50 | babel: true, |
| 51 | flow: 'all', |
| 52 | sourceType: 'module', |
| 53 | enableExperimentalComponentSyntax: true, |
| 54 | }); |
| 55 | } else { |
| 56 | return babelParse(input, { |
| 57 | plugins: ['typescript', 'jsx'], |
| 58 | sourceType: 'module', |
| 59 | }) as ParseResult<t.File>; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | function invokeCompiler( |
| 64 | source: string, |