Skip to content

chore: stop tracking next-env.d.ts, which every build rewrites - #862

Merged
blove merged 1 commit into
mainfrom
blove/untrack-next-env
Aug 30, 2026
Merged

chore: stop tracking next-env.d.ts, which every build rewrites#862
blove merged 1 commit into
mainfrom
blove/untrack-next-env

Conversation

@blove

@blove blove commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

apps/website/next-env.d.ts and apps/cockpit/next-env.d.ts are generated by Next, and their contents differ by command:

-import "./.next/dev/types/routes.d.ts";              # next dev
+import "./../../dist/apps/website/.next/types/routes.d.ts";   # next build

So every build or dev run dirties the working tree, and the file flips back and forth depending on which ran last. I reverted that churn three times in a single session before treating it as a problem rather than noise.

There was already a workaround

apps/website/scripts/run-e2e-with-next-env-restore.ts exists solely to rewrite this file to hardcoded canonical content after e2e — evidence the churn has bitten before.

Kept, deliberately. With the file ignored the git churn is gone, but the script still does something useful: it stops e2e from leaving behind a reference to a dev path that no longer exists, which a later typecheck in the same tree would trip over. Ignoring the file solves the VCS problem; the script solves the stale-content problem. Different problems.

Verified from a simulated fresh clone

The real risk is that both tsconfig.json files list next-env.d.ts in include, so a checkout without it could break before any build runs. I tested that directly — removed both files and ran the exact CI sequences:

Job Result
Website: nx lintnx testnx build 0 / 0 / 0
Cockpit: nx buildnx test 0 / 0

Both builds regenerate the file, so nothing downstream needs it committed.

One thing I ruled out along the way

Mid-investigation nx build cockpit failed, and it would have been easy to blame the deletion. It reproduces with the file restored — a Turbopack path error (leaves the filesystem root) caused by this worktree's depth inside the main repo, and only after a website build has populated dist/. Unrelated to this change, and it doesn't occur on a clean build.

🤖 Generated with Claude Code

Both apps/website/next-env.d.ts and apps/cockpit/next-env.d.ts are
generated by Next, and their contents differ by command: `next dev` writes
an import of ./.next/dev/types/routes.d.ts, `next build` writes the Nx dist
path. Tracking them means every build or dev run dirties the working tree,
and the file flips back and forth depending on what ran last. I reverted
that churn three times in one session before treating it as a problem.

There is already a workaround for it —
apps/website/scripts/run-e2e-with-next-env-restore.ts rewrites the file to
hardcoded canonical content after e2e. Kept: with the file ignored the git
churn is gone, but the script still prevents a stale dev-path reference
from being left behind for a later typecheck in the same tree.

Verified from a simulated fresh clone (both files absent, as they will be
after this change):
  Website job:  nx lint 0, nx test 0, nx build 0
  Cockpit job:  nx build 0, nx test 0
Both builds regenerate the file, so nothing downstream needs it committed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
threadplane Ready Ready Preview Aug 30, 2026 1:37am

Request Review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval: this PR received an intelligent (AI) code review. See the review comments on this PR.

@blove
blove enabled auto-merge (squash) August 30, 2026 01:33
@github-actions

github-actions Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Claude finished @blove's task in 0s —— View job


I'll analyze this and get back to you.

@blove
blove merged commit 779b008 into main Aug 30, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant