SIGN IN SIGN UP
payloadcms / payload UNCLAIMED

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.

0 0 16 TypeScript

chore: prevent dev server from dirtying tracked files (#15826)

# 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.
E
Elliot DeNolf committed
cb6f426af02f01f150693c2733ba24896fd4c546
Parent: 410912c
Committed by GitHub <noreply@github.com> on 3/3/2026, 3:55:53 PM