Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/assets-named-by-typescript.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"diagnostics-webpack-plugin": patch
---

Tell an asset import from a script one by the extensions TypeScript itself reads, rather than by a list of asset kinds: an import of any other kind of file (`./data.toml`, say) no longer makes every rebuild lint every file again.
5 changes: 5 additions & 0 deletions .changeset/cli-checks-one-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"diagnostics-webpack-plugin": patch
---

Hand Biome and oxlint every file at once when webpack is done building them, rather than in batches while it builds: each batch was a process of its own reading the configuration, and for Biome the project, again.
5 changes: 5 additions & 0 deletions .changeset/import-graph-typescript-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"diagnostics-webpack-plugin": patch
---

Lint every file again, rather than fail, where a project's TypeScript is the native TypeScript 7, which has no API to read what a file imports through: a check reading across files failed with `Cannot read properties of undefined (reading 'readFile')`.
5 changes: 5 additions & 0 deletions .changeset/ts-share-program-across-compilers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"diagnostics-webpack-plugin": minor
---

Share the TypeScript check's worker, and the program it holds, between the compilers of a `MultiCompiler` whose TypeScript checks are configured alike. Before, each compiler built and kept its own program. Over 600 files, two compilers building one after the other went through a watch with one rebuild in 5.6–5.8 s, 9.8–10.4 CPU-seconds and 467–483 MB, against 9.7–10.3 s, 18.7–20.0 CPU-seconds and 803–853 MB. Under TypeScript 7 the native compiler's process is shared the same way.
5 changes: 5 additions & 0 deletions .changeset/typescript-7.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"diagnostics-webpack-plugin": minor
---

Support TypeScript 7 in the TypeScript check, from 7.1. TypeScript 7 has no compiler API in JavaScript, so the check failed to load it at all. The check now runs the native compiler through the API TypeScript ships, `typescript/async`, in a process of its own that stays open while webpack watches and is told which files webpack saw change, and prints diagnostics with TypeScript's own formatter. `build`, a writing `mode`, and compiler options written in the plugin are reported as unsupported under TypeScript 7. TypeScript 7.0, which shipped that API only as an unstable preview, is reported as having no API to check with. Over 600 files, a one-shot build took 1.2–1.3 s on TypeScript 7.1, against 3.8 s on TypeScript 6 without its saved state.
4 changes: 1 addition & 3 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
"stylelint's",
"stylelintcache",
"stylelintignore",
"stylelintrc",
"pcss",
"styl"
"stylelintrc"
],
"ignorePaths": [
"**/__snapshots__/**",
Expand Down
36 changes: 33 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,12 @@ pool of workers — so the option means the same thing whatever is being checked
and a check added later gets it for nothing. ESLint threads its own work from
9.34.0 under flat config; Stylelint threads none of its own, so it is pooled.
TypeScript reads a program whole rather than a file at a time, so it is run on
one worker: what a thread buys it is webpack's own thread back.
one worker: what a thread buys it is webpack's own thread back. The compilers of
a `MultiCompiler` whose TypeScript checks are configured alike share that worker
and the program it holds, rather than each building and keeping one of their
own. Over 600 files, two compilers built one after the other (`parallelism: 1`)
went through a watch with one rebuild in 5.6–5.8 s and 9.8–10.4 s of CPU at
467–483 MB, against 9.7–10.3 s, 18.7–20.0 s and 803–853 MB with a worker each.

Prefer `"auto"` over a count. A check sizes `"auto"` against the machine, where a
fixed number can end up competing with webpack for the same cores: over three
Expand Down Expand Up @@ -383,7 +388,8 @@ drops it before webpack sees it — and this holds for every check, whatever too
it runs. A change that could reach files some other way — a declaration file
nothing imports, a `declare global`, a config file, an import that resolves to
nothing (a stylesheet, an image or another asset webpack bundles aside) — lints
every file again, as does a project without TypeScript. There,
every file again, as does a project without TypeScript, or with TypeScript 7,
whose native compiler has no JavaScript API to read imports through. There,
an ESLint check with `cache: true` written down keeps ESLint's own cache, which
answers for a file whose import changed from before the change.

Expand Down Expand Up @@ -784,6 +790,10 @@ new DiagnosticsPlugin({ checks: ["biome"] });
Like the oxlint check this runs a binary and reads the JSON it answers with,
which Biome calls an experimental reporter — a release of its own may move the
shape, and it is the only reporter carrying the severities this check needs.
A build hands it every file at once when webpack is done building them, rather
than in batches while webpack builds: each run reads the configuration and the
project again. Over 1,500 files that took the CPU of
the processes from 2.9 s to 2.2 s, and for oxlint from 1.2–1.7 s to 0.3 s.

Biome's project and types rules — `noImportCycles`, `noFloatingPromises` —
answer for a file from the files it imports, and which rules those are is not
Expand Down Expand Up @@ -844,7 +854,8 @@ Not `--reporter`: the check asks for JSON and formats the results itself.

## TypeScript

Run with `{ use: "typescript" }`, and requires `typescript >= 5`. It type checks
Run with `{ use: "typescript" }`, and requires `typescript >= 5` (see
[TypeScript 7](#typescript-7) for the native compiler). It type checks
the program a `tsconfig.json` describes, so every file that config includes is
checked whether or not webpack built it, and a type error in a module nothing
imports yet is still reported. Emit is forced off: webpack writes the output.
Expand Down Expand Up @@ -906,6 +917,25 @@ new DiagnosticsPlugin({
});
```

### TypeScript 7

TypeScript 7 is a native compiler with no compiler API in JavaScript, so the
check talks to it through the API it ships instead, `typescript/async`, from
TypeScript 7.1. TypeScript 7.0 shipped that API only as an unstable preview,
which the check does not use. The compiler runs in a process of its own, which
takes the place of [`threads`](#threads), and is kept open while webpack
watches: a rebuild tells it which files webpack saw change. Diagnostics are
printed by TypeScript's own formatter, as `tsc --pretty` prints them.

It checks the project as its config file describes it, so [`build`](#build), a
[`mode`](#mode) that writes, and compiler options written in the plugin are
reported as unsupported rather than ignored. Compiler options belong in the
`tsconfig.json` instead; `build` and a writing `mode` have no TypeScript 7
counterpart.

Over 600 files, a one-shot build with the check took 1.2–1.3 s on TypeScript
7.1, against 3.8 s on TypeScript 6 without its saved state and 2.0–2.1 s with it.

### `typescriptPath`

- Type:
Expand Down
Loading
Loading