( input: string, as: string, parserPlugins?: ParserPlugin[], )
| 5 | import { resolveParserPlugins } from './script/context' |
| 6 | |
| 7 | export function rewriteDefault( |
| 8 | input: string, |
| 9 | as: string, |
| 10 | parserPlugins?: ParserPlugin[], |
| 11 | ): string { |
| 12 | const ast = parse(input, { |
| 13 | sourceType: 'module', |
| 14 | plugins: resolveParserPlugins('js', parserPlugins), |
| 15 | }).program.body |
| 16 | const s = new MagicString(input) |
| 17 | |
| 18 | rewriteDefaultAST(ast, s, as) |
| 19 | |
| 20 | return s.toString() |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Utility for rewriting `export default` in a script block into a variable |
no test coverage detected