Skip to content

fix(typescript): recover watch builds with noEmitOnError - #2034

Open
Boulea7 wants to merge 1 commit into
rollup:masterfrom
Boulea7:fix/typescript-watch-no-emit-on-error
Open

Boulea7 wants to merge 1 commit into
rollup:masterfrom
Boulea7:fix/typescript-watch-no-emit-on-error

Conversation

@Boulea7

@Boulea7 Boulea7 commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Rollup Plugin Name: typescript

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Related to #2023 (watch recovery).

Description

With noEmitOnError: true, another edit that still has a type error can throw from TypeScript's watch callback and terminate the watcher. Fixing an error after the initial failed build can also leave Rollup waiting without producing a bundle.

Report these diagnostics from buildStart after the compilation finishes, and register the program's source files before an error can stop Rollup from loading its module graph. The same watcher then recovers across invalid → still-invalid → valid edits, including edits to imported and type-only dependencies. Failed builds neither create a bundle nor overwrite the content or mtime of an earlier successful bundle.

The five regression tests cover initial failure, failure after a successful build, imported and excluded type-only dependencies, and the existing warning behavior with noEmitOnError: false.

Validation:

  • TypeScript package build and full package test suite: 96 passed, 2 existing tests skipped. From packages/typescript: node node_modules/rollup/dist/bin/rollup -c, then node ../../node_modules/vitest/vitest.mjs --config ../../.config/vitest.config.mts run --maxWorkers=1 --fileParallelism=false.
  • Root pnpm lint: passed (0 errors; 46 existing warnings in unchanged files).
  • ESLint with --max-warnings=0 and Prettier checks on the three changed files: passed.

@Boulea7
Boulea7 requested a review from shellscape as a code owner October 26, 2026 14:35
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues were found.

Diagram

sequenceDiagram
  participant R as Rollup
  participant P as TypeScript plugin
  participant T as TypeScript compiler
  R->>P: buildStart
  P->>T: Create program or wait for update
  T->>P: Collect source files and diagnostics
  P->>R: Register compiler inputs to watch
  alt Compilation has errors
    P->>R: Report error from buildStart
  else Compilation succeeds
    R->>P: load
    P->>R: Return emitted JavaScript
  end
Loading

Reviews (1) · Last reviewed commit: "fix(typescript): recover watch builds af..." · Reviewed by Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant