pub fn output_entry_to_source_path(
base: &Path,
entry: &str,
source_extensions: &[&str],
is_discovered: impl Fn(&Path) -> bool,
) -> Option<PathBuf>Expand description
Map an output directory entry to its same-stem source file.
Given base=/project/packages/ui and entry=./dist/utils.js, this tries
/project/packages/ui/src/utils.<ext> for each extension in
source_extensions. A path prefix between the package root and the output
directory stays: ./modules/dist/utils.js maps to modules/src/utils.ts.
OUTPUT_DIRS decide first. A lib/ entry (MISSING_ONLY_OUTPUT_DIRS)
maps only when the entry target is absent. The target is present when the
filesystem probe finds a file and is_discovered accepts that file. Thus a
hand-written lib/ file in the analyzed file set stays the entry, and a
lib/ build output that .gitignore or ignorePatterns excludes maps to
src/.
The probe and is_discovered run only for a lib/ entry that has a
same-stem source file. Other entries never call is_discovered, so a
caller can build an expensive lookup on first use.