chore: prevent dev server from dirtying tracked files#15826
Merged
Conversation
- 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/.
PatrikKozak
approved these changes
Mar 3, 2026
Contributor
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖 |
kendelljoseph
approved these changes
Mar 3, 2026
Contributor
|
🚀 This is included in version v3.79.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Running
pnpm dev <suite>modifiestsconfig.base.jsonandnext-env.d.tsin ways that show up ingit statusbut never belong in commits. This PR eliminates both sources of noise.Key Changes
tsconfig.base.json— string replacement instead of full reparse:comment-json'sstringifywas reformatting the entire file (expanding single-element arrays to multi-line) just to swap the@payload-configpath. Replaced with a regex that only touches the@payload-configvalue, leaving all other formatting untouched. A shared utility (scripts/replacePayloadConfigPath.js) is used byreset-tsconfig.js, with an inlined copy intest/testHooks.ts(thetest/tsconfig setsrootDirtotest/, so it can't import from../scripts/).next-env.d.ts— gitignored and untracked: Next.js rewrites this file on everynext dev, flipping between single/double quotes and adding/removing semicolons. Since it's auto-generated on firstnext devornext build, it's a build artifact. Untracked all 22 copies across root, test suites, examples, and templates.ESLint config: Added
scripts/**/*.jsto 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 likejson-stringify-pretty-compactor moving@payload-configresolution to a bundler alias. It's the smallest change that fully solves the problem — no new dependencies, no architecture changes, and the existingreset-tsconfig.jslint-staged hook continues to work as before.The utility is duplicated between
scripts/replacePayloadConfigPath.jsandtest/testHooks.tsbecause TypeScript'srootDirboundary preventstest/from importing../scripts/. Both copies are small (~10 lines) so the duplication is acceptable.