MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / builtSourcesOf

Function builtSourcesOf

src/resolution/import-resolver.ts:1625–1637  ·  view source on GitHub ↗

* The source files a package's build output may be built from, * extension-less, most literal first: the build folder mirrored under * `src/` (vite's `dist/node/index.js` → `src/node/index`), then without a * format subfolder (`dist/esm/index.mjs`, `dist/types/index.d.ts` → * `src/index`). The c

(target: string, packageDir: string)

Source from the content-addressed store, hash-verified

1623 * build folder.
1624 */
1625function builtSourcesOf(target: string, packageDir: string): string[] {
1626 const prefix = packageDir === '' ? '' : packageDir + '/';
1627 if (!target.startsWith(prefix)) return [];
1628 const inPackage = target.slice(prefix.length);
1629 const root = BUILD_ROOT.exec(inPackage);
1630 if (!root) return [];
1631 const mirrored = inPackage.slice(root[0].length);
1632 const format = BUILD_FORMAT.exec(mirrored);
1633 const stems = [mirrored, ...(format ? [mirrored.slice(format[0].length)] : [])]
1634 .map((rest) => rest.replace(EMITTED_EXTENSION, ''))
1635 .filter((stem) => stem !== '' && !stem.startsWith('src/'));
1636 return [...new Set(stems)].map((stem) => `${prefix}src/${stem}`);
1637}
1638
1639/**
1640 * A bare specifier `isExternalImport` takes for a package, resolved through

Callers 1

builtSourceOfFunction · 0.85

Calls 2

mapMethod · 0.80
execMethod · 0.65

Tested by

no test coverage detected