MCPcopy Index your code
hub / github.com/formatjs/formatjs / parseFile

Function parseFile

packages/cli-lib/svelte_extractor.ts:241–262  ·  view source on GitHub ↗
(
  source: string,
  filename: string,
  parseScriptFn: ScriptParseFn
)

Source from the content-addressed store, hash-verified

239}
240
241export 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}

Callers 1

Calls 2

walkFragmentFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected