Commit cb6f426
authored
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.1 parent 410912c commit cb6f426
File tree
27 files changed
+50
-147
lines changed- examples
- astro/payload
- auth
- custom-components
- custom-server
- draft-preview
- email
- live-preview
- localization
- multi-tenant
- remix/payload
- whitelabel
- scripts
- templates
- plugin/dev
- website
- with-vercel-website
- test
- admin-bar
- admin-root
- base-path
- live-preview
- prod
- plugin-ecommerce
27 files changed
+50
-147
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
173 | 174 | | |
174 | 175 | | |
175 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
0 commit comments