Skip to content

chore: prevent dev server from dirtying tracked files#15826

Merged
denolfe merged 2 commits intomainfrom
chore/devex-file-resets
Mar 3, 2026
Merged

chore: prevent dev server from dirtying tracked files#15826
denolfe merged 2 commits intomainfrom
chore/devex-file-resets

Conversation

@denolfe
Copy link
Member

@denolfe denolfe commented Mar 3, 2026

Overview

Running pnpm dev <suite> modifies tsconfig.base.json and next-env.d.ts in ways that show up in git status but never belong in commits. This PR eliminates both sources of noise.

Key Changes

  • tsconfig.base.json — string replacement instead of full reparse: comment-json's stringify was reformatting the entire file (expanding single-element arrays to multi-line) just to swap the @payload-config path. Replaced with a regex that only touches the @payload-config value, leaving all other formatting untouched. A shared utility (scripts/replacePayloadConfigPath.js) is used by reset-tsconfig.js, with an inlined copy in test/testHooks.ts (the test/ tsconfig sets rootDir to test/, so it can't import from ../scripts/).

  • next-env.d.ts — gitignored and untracked: Next.js rewrites this file on every next dev, flipping between single/double quotes and adding/removing semicolons. Since it's auto-generated on first next dev or next build, it's a build artifact. Untracked all 22 copies across root, test suites, examples, and templates.

  • ESLint config: Added scripts/**/*.js to the ignore list since the typescript-eslint project service doesn't cover standalone JS scripts.

Design Decisions

The regex approach (/"@payload-config":\s*\[\s*)"[^"]*"(\s*\])/) was chosen over alternatives like json-stringify-pretty-compact or moving @payload-config resolution to a bundler alias. It's the smallest change that fully solves the problem — no new dependencies, no architecture changes, and the existing reset-tsconfig.js lint-staged hook continues to work as before.

The utility is duplicated between scripts/replacePayloadConfigPath.js and test/testHooks.ts because TypeScript's rootDir boundary prevents test/ from importing ../scripts/. Both copies are small (~10 lines) so the duplication is acceptable.

denolfe added 2 commits March 3, 2026 10:25
- Replace comment-json parse/stringify with targeted string replacement for
  @payload-config path in tsconfig.base.json (prevents array formatting expansion)
- Commit tsconfig.base.json in canonical formatted state
- Extract shared replacePayloadConfigPath utility used by both testHooks.ts
  and reset-tsconfig.js
Fixes rootDir boundary error — test/ tsconfig can't import from
../scripts/ since rootDir is scoped to test/.
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

📦 esbuild Bundle Analysis for payload

This analysis was generated by esbuild-bundle-analyzer. 🤖
This PR introduced no changes to the esbuild bundle! 🙌

@kendelljoseph kendelljoseph self-requested a review March 3, 2026 15:43
@denolfe denolfe enabled auto-merge (squash) March 3, 2026 15:44
@denolfe denolfe merged commit cb6f426 into main Mar 3, 2026
155 checks passed
@denolfe denolfe deleted the chore/devex-file-resets branch March 3, 2026 15:55
@github-actions
Copy link
Contributor

github-actions bot commented Mar 4, 2026

🚀 This is included in version v3.79.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants