/** * Dep Usage Scanner * * Answers ONE question for a project: "is package X reached from production * source, or ONLY from test/dev files?" * * WHY this exists: nx derives graph edges from ALL TypeScript sources, specs * included. Without this scan, a package imported only by `*.spec.ts` looks * identical to a package imported by a controller, so the validator forces it * into `dependencies` — and `pnpm deploy --prod` then ships test machinery * (auth-bypass hooks, canned credentials, fakes) into the production image. * Splitting the scan by file kind lets `devDependencies` be the REQUIRED home * for test-only packages. * * The scan is deliberately conservative: a package is "test-only" ONLY when it * is imported by at least one test/dev file and by ZERO production files. Any * doubt (no import found at all, e.g. a runtime-only/reflection dependency) * resolves to "production", so this can never push a runtime-required package * out of `dependencies`. */ /** * Which packages a project reaches from production code vs. only from test/dev code. * Data-only: no logic lives here (see CLAUDE.md — data structures are classes). */ export declare class DepUsage { prodPackages: Set; testPackages: Set; constructor(prodPackages: Set, testPackages: Set); /** True when the package is imported by tests and by no production file. */ isTestOnly(packageName: string): boolean; /** True when we saw the package in NO file at all (kind is unknown → treat as prod). */ isUnseen(packageName: string): boolean; } export declare class DepUsageScanner { /** * Walk a project directory and record every bare import specifier, bucketed * by whether the importing file is production or test/dev. */ scan(absProjectDir: string): DepUsage; /** * Is this path a test/dev file? Path is relative to the project root and * uses either separator. */ isDevFile(relPath: string): boolean; /** * The package a bare specifier belongs to, or null for relative/absolute * paths and node: builtins. `@scope/pkg/sub` → `@scope/pkg`; `pkg/sub` → `pkg`. */ toPackageName(specifier: string): string | null; private walk; private scanFile; private extractPackageNames; private readFile; }