build(server): omit tests from production compilation (#19383)

Use a separate production TypeScript configuration that excludes colocated tests while retaining every runtime source input and keeping tests in source typechecking. Verify the real compiler input sets and bound compiler-list capture for the larger source graph.

Validation: focused compiler-input regression passes; fresh CI has 61 passing checks and three optional skips on 181ad8d; Greptile Apex is 5/5 with no unresolved comments.

Co-Authored-By: Scott Goodson <scottgoodson@gmail.com>
Co-Authored-By: Devin Foley <devin@paperclip.ing>
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
authored and GitHub committed 2026-11-20 20:02:21 -08:00
1 parent fec961b580
commit 6b9952525d
4 files changed
+46 -3

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
import { spawnSync } from "node:child_process";
import { readFileSync } from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { expect, it } from "vitest";
const serverRoot = fileURLToPath(new URL("../", import.meta.url));
function compilerInputs(args) {
const result = spawnSync(process.execPath, ["../scripts/run-tsc.mjs", ...args, "--listFilesOnly"], {
cwd: serverRoot,
encoding: "utf8",
maxBuffer: 8 * 1024 * 1024,
timeout: 30_000,
});
if (result.error) throw result.error;
expect(result.status, result.stderr || result.stdout).toBe(0);
return result.stdout.split(/\r?\n/).filter((file) => file.startsWith(path.join(serverRoot, "src", path.sep)));
}
it("omits co-located tests from the build while retaining source typecheck coverage", () => {
const { scripts } = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
const command = scripts.build.split("&&").map((part) => part.trim())
.find((part) => part.startsWith("node ../scripts/run-tsc.mjs"));
expect(command).toBeDefined();
const production = compilerInputs(command.split(/\s+/).slice(2));
const source = compilerInputs(["-p", "tsconfig.json"]);
const isTest = (file) => /\.test\.tsx?$/.test(file);
expect(source.filter(isTest).length).toBeGreaterThan(0);
expect(production.filter(isTest)).toEqual([]);
const productionFiles = new Set(production);
const testTree = path.join(serverRoot, "src", "__tests__", path.sep);
expect(source.filter((file) => !isTest(file) && !file.startsWith(testTree) && !productionFiles.has(file))).toEqual([]);
}, 60_000);