// Pass 1 of `audit --graph`: stream every discovered file, parse it, extract a // compact FileGraphNode, and DISCARD the AST/Doc — so only O(file count) small // records are ever held, never whole-repo source. Then assemble the DepGraph. import { readText, ext } from "../util.js"; import { GRAPH_ONLY_EXT } from "../glob.js"; import { detectKind, splitAstroFrontmatter, parseSource, parseSourceWithAst } from "../parse/source.js"; import { parseJsxAst } from "../parse/jsx-ast.js"; import type { Doc } from "../parse/html.js"; import { dirname } from "node:path"; import { extractGraphNode, type FileGraphNode } from "./imports.js"; import { buildGraph, type DepGraph } from "./graph.js"; import { readTsAliases } from "./tsconfig.js"; const GRAPH_ONLY = new Set(GRAPH_ONLY_EXT); // A plain TS/JS module has no markup — an empty Doc keeps extractGraphNode from // reading nothing but its (non-existent) elements, while still handing the real // source's AST to the import/export extraction below. Never fed through `parseHtml` // on the real TS/JS text: generics like `Array` would look like tags to it. function emptyDoc(file: string, source: string): Doc { return { file, source, lossy: false, kind: "html", roots: [], elements: [], byId: new Map(), lineStarts: [0] }; } // .vue/.svelte's own block — the only part of an // SFC that's real JS/TS. Astro's frontmatter fence is handled separately (it isn't // a