( source: string, filename: string, parseScriptFn: ScriptParseFn )
| 239 | } |
| 240 | |
| 241 | export function parseFile( |
| 242 | source: string, |
| 243 | filename: string, |
| 244 | parseScriptFn: ScriptParseFn |
| 245 | ): void { |
| 246 | const ast = parse(source, {modern: true, filename}) |
| 247 | |
| 248 | // Walk the template fragment |
| 249 | walkFragment(ast.fragment as unknown as SvelteNode, source, parseScriptFn) |
| 250 | |
| 251 | // Process <script> block |
| 252 | if (ast.instance) { |
| 253 | const program = ast.instance.content as unknown as SvelteNode |
| 254 | parseScriptFn(source.slice(program.start, program.end)) |
| 255 | } |
| 256 | |
| 257 | // Process <script context="module"> / <script module> block |
| 258 | if (ast.module) { |
| 259 | const program = ast.module.content as unknown as SvelteNode |
| 260 | parseScriptFn(source.slice(program.start, program.end)) |
| 261 | } |
| 262 | } |
no test coverage detected