feat: watch the folders a check takes its files from - #334
Merged
Merged
Conversation
A file webpack never builds has no watcher of its own until it exists, so adding one changed nothing until something else did. The folders a check globs, and the ones a `tsconfig.json` `include` covers, are now handed to webpack as context dependencies, and the paths an import resolved to nothing through as missing ones — so creating the file the import names rebuilds and clears the error. Webpack rebuilds on a change anywhere under a folder it watches, so a folder is only watched when the whole of it can be: one holding `output.path` turns every build's own output into another build, and one holding what the check excludes would watch `node_modules`. Measured, a folder holding the output costs a third build for every edit. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GzZci4NQeiqwdrVfd7dGXy
This was referenced Sep 13, 2026
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.
Summary
A file webpack never builds has no watcher of its own until it exists, so adding one changed nothing until something else did — #330 watches the files a check read, and a file that is not there yet is not one of them. The folders a check globs, and the ones a
tsconfig.jsonincludecovers, now go to webpack ascontextDependencies, and the paths an import resolved to nothing through asmissingDependencies, so writing the file an import names rebuilds and clears the error. No watcher of our own: this is the same APIrequire.contextand webpack's resolver use.Webpack rebuilds on a change anywhere under a folder it watches, so a folder is watched only when the whole of it can be. Two rules, both measured:
output.pathunder a watched folder, one edit produced 3 builds instead of 2 — every build's own output is the next build's trigger.node_modulesin it cost +85 MB RSS, against +12 MB with node_modules ignored and +1 MB for asrcfolder.So
typescriptgets this from itstsconfig.json— itsincluderoots are watched whateverfilessays, which is what fork-ts-checker does — and a glob check gets it whenfilespoints at your sources rather than at the project root. Rebuild time and RSS on a 300-file project are unchanged (typescript 49 → 52 ms, 258 → 259 MB, both within the run-to-run spread).What kind of change does this PR introduce?
feat
Did you add tests for your changes?
Yes —
test/stylelint/unbuilt.test.js(a file appearing with nothing else changing),test/typescript/watch.test.js(a fileincludecovers appearing, and the path an unresolved import is watched through), andtest/stylelint/directories.test.jsfor the rules above (watched, output inside, excluded child, folder that is not there).Does this PR introduce a breaking change?
No.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
Documented in
README.mdunderfiles.Use of AI
Claude Code wrote the change, the tests and this description, and ran the measurements above; I reviewed all of it.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GzZci4NQeiqwdrVfd7dGXy
Generated by Claude Code