Skip to content

fix(build): build a new program in -b --watch when a referenced config changed - #1036

Merged
camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/build-watch-referenced-config
Nov 19, 2026
Merged

camc314 merged 1 commit into
oxc-project:mainfrom
magurotuna:fix/build-watch-referenced-config

Conversation

@magurotuna

Copy link
Copy Markdown
Member

In -b --watch mode, project b references project a. After a/tsconfig.json becomes invalid or sets "composite": false, an edit of b/b.ts did not report TS6306 (Referenced project ... must have setting "composite": true), as tsgo does. tsrs reported TS2322 for b/b.ts instead.

For a one-file edit, the tsrs-only reuse_watch_program reuses the previous program, so the references are not checked again. Go builds a new program in every build, which runs verifyProjectReferences. tsrs now builds a new program when the host returns a different config for a reference of the previous program, including a transitive one.

Tests: watch_b_stale_reference_config (an invalid config, and "composite": false). Both fail without the fix.

AI assistance: written with Claude Code.

…g changed

`tsc -b --watch` reused the previous program of a downstream project for a
one-file edit (`reuse_watch_program`, a tsrs-only optimization), even after
the `tsconfig.json` of a referenced project changed. `reuse_program` keeps the
resolved references and the program diagnostics of the previous program, and
it does not run `verify_project_references` again. So after a referenced
config became invalid or turned off `composite`, an edit of a downstream file
gave the old references: no TS6306, and the program read the old outputs of
the referenced project.

Go builds a new program in each build (`compileAndEmit` calls
`compiler.NewProgram`, `buildtask.go:252`), which runs
`verifyProjectReferences` against the current config of each reference
(`program.go:1431`).

Keep the optimization, and fall back to a full build when any resolved
reference of the previous program (also the transitive ones) differs from the
config that the host returns now. The host cache keeps the same parsed config
across cycles until `reset_config` deletes it or a new file list replaces it,
so an edit that leaves every referenced config unchanged still reuses the
program.

Tests: `watch_b_stale_reference_config` in the tsrs_cli integration tests
(the referenced config becomes invalid, or sets `composite: false`, and then
a downstream file changes).

AI assistance: written with Claude Code.
@codspeed

codspeed Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 8 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing magurotuna:fix/build-watch-referenced-config (5902e2c) with main (eba9b2b)2

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (b84ddb4) during the generation of this report, so eba9b2b was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@camc314
camc314 added this pull request to the merge queue Nov 19, 2026
Merged via the queue into oxc-project:main with commit b597f58 Nov 19, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants