fix(api): resolve TS5011 in Docker build after TypeScript 6 upgrade - #2621
Conversation
The api Docker build stage copies only packages/api/src into the builder image (not migrations/ or scripts/), so the default `tsc` build using tsconfig.json's include: [src, migrations, scripts] collapses the common source dir to ./src. TypeScript 6 then requires an explicit rootDir and fails with TS5011. Point the build script at tsconfig.build.json — now src-only with an explicit rootDir, mirroring tsconfig.vercel.json — so the build matches what actually ships in the image. tsconfig.json stays broad so lint, typecheck, and ts-node continue to cover migrations/ and scripts/. Follow-up to #2617.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🔵 Tier 2 — Low RiskSmall, isolated change with no API route or data model modifications. Why this tier:
Additional context: agent branch ( Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns. Stats
|
Greptile SummaryThis PR fixes the
Confidence Score: 5/5Safe to merge — the change is a targeted build configuration fix with no runtime behavior changes. The three-file change is self-consistent: tsconfig.build.json was already being copied into the Docker builder stage before this PR, so pointing the build script at it is the natural completion. The prod image only copies the compiled build/ directory, confirming that excluding migrations/ and scripts/ from compiled output does not affect the running service. No application logic is touched. No files require special attention. Important Files Changed
Reviews (1): Last reviewed commit: "fix(api): resolve TS5011 in Docker build..." | Re-trigger Greptile |
Deep Review✅ No critical issues found. This is a config-only fix that repoints the API 🔵 P3 nitpicks (1)
Reviewers (4): ce-correctness-reviewer, ce-reliability-reviewer, ce-maintainability-reviewer, ce-project-standards-reviewer. Testing gaps:
|
E2E Test Results✅ All tests passed • 235 passed • 3 skipped • 1427s
Tests ran across 4 shards in parallel. |
…2621) ## Summary Fixes a build failure surfaced by the TypeScript 6 upgrade (#2617) when building the API Docker image: ``` tsconfig.json(8,5): error TS5011: The common source directory of 'tsconfig.json' is './src'. The 'rootDir' setting must be explicitly set to this or another path to adjust your output's file layout. ``` ## Why it happens The API Docker build stage copies only `packages/api/src` into the builder image — it does **not** copy `migrations/` or `scripts/`. The default `build` script runs a bare `tsc`, which uses `tsconfig.json` with `include: ["src", "migrations", "scripts"]`. - Locally / in CI, all three directories exist, so `tsc` infers a common source dir that spans them and doesn't complain. - In the Docker image, only `src` is present, so the `include` glob resolves to `src/**` and the common source dir collapses to `./src`. TypeScript 6 now requires that inferred `rootDir` to be explicit, and fails with `TS5011`. `migrations/` ships to the runtime image as raw source (not compiled output) and `scripts/` is dev-only, so neither belongs in the compiled `build/` output — they only need to exist for lint/typecheck. ## Fix - Point the `build` script at `tsconfig.build.json`, which is now `src`-only with an explicit `rootDir: "./src"` (mirroring the existing `tsconfig.vercel.json`). This makes the build match what actually ships in the image. - `tsconfig.json` stays broad (`include: ["src", "migrations", "scripts"]`) so lint, `tsc --noEmit` typecheck, and `ts-node` continue to cover `migrations/` and `scripts/`. - Trimmed a now-inaccurate comment in `tsconfig.json`. ## Verification - Reproduced the exact `TS5011` locally by running the old build command against a `src`-only tree (matching the Docker builder), in the same `node:22-alpine` base image. - Confirmed the new `build` command succeeds in that same `src`-only environment, with `migrations/` correctly excluded from the compiled output. - `yarn build` (full tree) and `yarn ci:lint` pass; `make ci-lint` passes across all projects. Follow-up to #2617.
Summary
Fixes a build failure surfaced by the TypeScript 6 upgrade (#2617) when building the API Docker image:
Why it happens
The API Docker build stage copies only
packages/api/srcinto the builder image — it does not copymigrations/orscripts/. The defaultbuildscript runs a baretsc, which usestsconfig.jsonwithinclude: ["src", "migrations", "scripts"].tscinfers a common source dir that spans them and doesn't complain.srcis present, so theincludeglob resolves tosrc/**and the common source dir collapses to./src. TypeScript 6 now requires that inferredrootDirto be explicit, and fails withTS5011.migrations/ships to the runtime image as raw source (not compiled output) andscripts/is dev-only, so neither belongs in the compiledbuild/output — they only need to exist for lint/typecheck.Fix
buildscript attsconfig.build.json, which is nowsrc-only with an explicitrootDir: "./src"(mirroring the existingtsconfig.vercel.json). This makes the build match what actually ships in the image.tsconfig.jsonstays broad (include: ["src", "migrations", "scripts"]) so lint,tsc --noEmittypecheck, andts-nodecontinue to covermigrations/andscripts/.tsconfig.json.Verification
TS5011locally by running the old build command against asrc-only tree (matching the Docker builder), in the samenode:22-alpinebase image.buildcommand succeeds in that samesrc-only environment, withmigrations/correctly excluded from the compiled output.yarn build(full tree) andyarn ci:lintpass;make ci-lintpasses across all projects.Follow-up to #2617.