(files: readonly SourceFileInfo[]): (SourceFileInfo & { dependents?: readonly string[] | undefined; })[] Compute bidirectional dependencies from source files.
This function ensures that if file A has file B in its dependencies,
then file B will have file A in its dependents. This provides consistent
output regardless of whether callers provide one-directional or bidirectional
dependency information.
Returns new SourceFileInfo objects when computed dependents exist or when
paths needed posixification; otherwise the original input objects flow
through ===-equal (fast path for session callers, who already pass POSIX
paths and may have no inferable dependents for a given file).
files
source files with optional dependency information
readonly SourceFileInfo[]returns
(SourceFileInfo & { dependents?: readonly string[] | undefined; })[] new array with bidirectional dependencies computed
examples
// Input: Calculator.svelte has dependencies: [math.ts]
// Output: Calculator.svelte has dependencies: [math.ts]
// math.ts has dependents: [Calculator.svelte]
const filesWithBidirectional = computeDependents(files);