Repository navigation
perf: skip importers on a file's first edit too, and in projects with allowJs - #393
Conversation
…ad TypeScript files in an allowJs project The importers of a file changed while webpack watches are linted again only when what it shows them changes, but that could be told only from a file's second change on: what it showed before its first was never read. What each file a check reading across files covers holds is now kept once the first build of a watch is over, and its first change is told from it. A file written after webpack started reading the file system for that build is not kept, and its first change reaches every importer, as before. What a file shows was read under the project's own compiler options, so in a project setting allowJs, or a rootDir a file is outside of, TypeScript refused to read any file and every edit reached every importer. It is now read under no project option, and only for TypeScript files: a JavaScript file's exports are written as any without a word, so a change to them would not show. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01App18sYbe6Vf6HDCjCXbvf
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via: Supported
Alternatively, if the co-author should not be included, remove the Please update your commit message(s) by doing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #393 +/- ##
========================================
Coverage 99.68% 99.68%
========================================
Files 21 21
Lines 6319 6450 +131
========================================
+ Hits 6299 6430 +131
Misses 20 20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review.
|
There was a problem hiding this comment.
Actionable comments posted: 1

Review info
-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Organization UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d224e73b-c44c-4e06-b229-3eb400b523d6
Files selected for processing: 6-
.changeset/first-edit-face.mdREADME.mdsrc/import-graph.jssrc/index.jstest/import-graph.test.jstest/incremental.test.js
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
-
A rebuild that lints every file, because a file that changed declares something global or a config file changed, stopped before reading the other files that changed, so what each of them held or showed before stayed in the graph. An edit putting one of them back as it was then left its importers be, though they were last linted against what it held in between. What the files that changed held is now forgotten on both paths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01App18sYbe6Vf6HDCjCXbvf
While webpack watches, a check that reads across files (typed linting, for example) only re-lints a changed file's importers when what the file shows them changes: its declarations and its imports. That had two gaps. This PR closes both, with no new option.
1. The first edit of a file re-linted every importer
The comparison needs what the file showed before the edit. That was only recorded after the file's first change, so the first edit of every file in a session fell back to re-linting everything that imports it.
Now, once the first build of a watch is over, the plugin keeps the text of every file such a check covers. A file's first edit is compared against that text.
An edit that does change an export still re-lints every importer and reports the error, as before.
compiler.fsStartTime) is not kept, because what's on disk may already be the change. Its first edit re-lints every importer, as today.2. In a project with
allowJs, no TypeScript file was ever comparedA file's exported shape was read with
transpileDeclarationunder the project's own compiler options. WithallowJs, or arootDira file sits outside of, TypeScript refuses to read the file at all:In any project with
allowJsset, which is common for mixed JS/TS code, every edit to any file re-linted all its importers.removeComments: falseandstripInternal: falsestill keep what an importer's rules read..tsxfiles read the same with or withoutjsx.transpileDeclarationwritesanywith no error, which would hide real changes. Before, theallowJsin the options only excluded them by accident.Tests
test/import-graph.test.js: a first edit after the texts are kept:declare globalreaches every file;Plus a project with
allowJsand arootDir.test/incremental.test.js: the first body-only edit to a.tsfile in watch mode re-lints only that file. It fails onmain.Locally: lint and the full suite (363 tests) pass.
Generated by Claude Code
Summary by CodeRabbit