diff --git a/scripts/__tests__/helpers/build-program.ts b/scripts/__tests__/helpers/build-program.ts new file mode 100644 index 000000000..9196489da --- /dev/null +++ b/scripts/__tests__/helpers/build-program.ts @@ -0,0 +1,374 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { outOfPackageProgramFiles } from './config-program'; +import { + invocationForCommand, + outOfPackageFilesFor, + type TscInvocation, +} from './tsc-program'; +import { rel, repoRoot, type WorkspacePackage } from './turbo-inputs'; + +/** + * Derives a workspace package's **build program** — the set of files the tools + * its `build` script drives read in order to know what to produce. + * + * The fourth instance of the objectui#3514 class (objectui#4185), and the one + * with the widest blast radius: `build` declared no `inputs` at all, and `build` + * is the task whose `dist/` every other task consumes through + * `dependsOn: ["^build"]`. A build replayed from a cache key that ignored a + * `strict` flip in the root `tsconfig.json` hands stale `dist/` to everything + * downstream. + * + * ## Why this derivation is a union rather than one walk + * + * `type-check` scripts are all tsc and `test` scripts are all Vitest, so each of + * those guards derives one kind of program. `build` scripts are not uniform — + * they are `&&` chains over five tools: + * + * tsc 14 packages the tsc program (./tsc-program.ts) + * vite build 22 packages the Vite config program + * tsup 4 packages the tsup config program + its tsconfig + * next build 1 app the Next config program + its tsconfig + * node