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

Function builtSourcesOf

src/resolution/import-resolver.ts:1686–1698  ·  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

1684 * build folder.
1685 */
1686function builtSourcesOf(target: string, packageDir: string): string[] {
1687 const prefix = packageDir === '' ? '' : packageDir + '/';
1688 if (!target.startsWith(prefix)) return [];
1689 const inPackage = target.slice(prefix.length);
1690 const root = BUILD_ROOT.exec(inPackage);
1691 if (!root) return [];
1692 const mirrored = inPackage.slice(root[0].length);
1693 const format = BUILD_FORMAT.exec(mirrored);
1694 const stems = [mirrored, ...(format ? [mirrored.slice(format[0].length)] : [])]
1695 .map((rest) => rest.replace(EMITTED_EXTENSION, ''))
1696 .filter((stem) => stem !== '' && !stem.startsWith('src/'));
1697 return [...new Set(stems)].map((stem) => `${prefix}src/${stem}`);
1698}
1699
1700/**
1701 * 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