Skip to content

fix(api): resolve TS5011 in Docker build after TypeScript 6 upgrade - #2621

Merged
kodiakhq[bot] merged 1 commit into
mainfrom
claude/fix-api-docker-build-ts5011
Jul 10, 2026
Merged

fix(api): resolve TS5011 in Docker build after TypeScript 6 upgrade#2621
kodiakhq[bot] merged 1 commit into
mainfrom
claude/fix-api-docker-build-ts5011

Conversation

@brandon-pereira

Copy link
Copy Markdown
Member

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.

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.
@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ad00e1f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Jul 10, 2026 5:39pm
hyperdx-storybook Ready Ready Preview, Comment Jul 10, 2026 5:39pm

Request Review

@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Additional context: agent branch (claude/fix-api-docker-build-ts5011) — change small enough to qualify for Tier 2

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 3
  • Production lines changed: 21
  • Branch: claude/fix-api-docker-build-ts5011
  • Author: brandon-pereira

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@greptile-apps

greptile-apps Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes the TS5011 TypeScript 6 error that breaks the Docker API build by pointing the build script at a new tsconfig.build.json that includes only src/ with an explicit rootDir: \"./src\". The root cause is that the Docker builder stage copies only packages/api/src (not migrations/ or scripts/), so TypeScript's inferred common source root collapsed to ./src, and TypeScript 6 now requires that to be declared explicitly.

  • package.json: build script changed from bare tsc to tsc -p tsconfig.build.json (and tsc-alias -p tsconfig.build.json), matching the pattern already used by build:vercel.
  • tsconfig.build.json: Repurposed from a broad include (src + migrations + scripts) to a src-only config with explicit rootDir: \"./src\", matching the Docker builder's available file tree. The Dockerfile was already copying this file to the builder stage.
  • tsconfig.json: Minor comment cleanup; include: [\"src\", \"migrations\", \"scripts\"] is preserved so lint and tsc --noEmit still cover migration and script files.

Confidence Score: 5/5

Safe 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

Filename Overview
packages/api/package.json Updated build script to pass -p tsconfig.build.json to both tsc and tsc-alias, pointing the build at the new src-only config
packages/api/tsconfig.build.json Restructured to include only src/ with an explicit rootDir: ./src, mirroring tsconfig.vercel.json and fixing the TS5011 error in the Docker builder which has no migrations/ or scripts/
packages/api/tsconfig.json Minor comment cleanup only; the broad include: [src, migrations, scripts] is intentionally preserved for lint/typecheck coverage

Reviews (1): Last reviewed commit: "fix(api): resolve TS5011 in Docker build..." | Re-trigger Greptile

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found.

This is a config-only fix that repoints the API build script at a src-only tsconfig.build.json with an explicit rootDir. Correctness and reliability reviewers independently verified that dropping migrations/ and scripts/ from the compiled build/ output introduces no runtime or CI regression: packages/api/bin/hyperdx only executes build/index.js and build/tasks/index.js, no src/ file imports from migrations/ or scripts/, prod images copy only build/ and bin/, and Mongo migrations run via ts-node on source (never from build/). ci:lint still typechecks the full tree via tsconfig.json, so type coverage of migrations/ and scripts/ is preserved. The change mirrors the already-working build:vercel / tsconfig.vercel.json pattern.

🔵 P3 nitpicks (1)
  • packages/api/tsconfig.build.json:1 — after this change tsconfig.build.json is functionally identical to the pre-existing tsconfig.vercel.json, leaving two src-only build configs that can silently drift.
    • Fix: collapse the duplication so the src-only rootDir/include/exclude settings live in one file, e.g. have tsconfig.vercel.json extend tsconfig.build.json and add only outDir.
    • ce-maintainability-reviewer, ce-project-standards-reviewer

Reviewers (4): ce-correctness-reviewer, ce-reliability-reviewer, ce-maintainability-reviewer, ce-project-standards-reviewer.

Testing gaps:

  • No CI job runs yarn build for packages/api outside the Docker image build, so the src-only compile path this PR fixes is exercised only when the Docker builder stage runs; a lightweight smoke check that build/index.js and build/tasks/index.js exist after build would catch future regressions where a needed directory is dropped from output.

@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Results

All tests passed • 235 passed • 3 skipped • 1427s

Status Count
✅ Passed 235
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

@kodiakhq
kodiakhq Bot merged commit bd2083b into main Jul 10, 2026
22 checks passed
@kodiakhq
kodiakhq Bot deleted the claude/fix-api-docker-build-ts5011 branch July 10, 2026 17:49
jordan-simonovski pushed a commit that referenced this pull request Jul 13, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants