Skip to content

Watch mode: rebuild takes too long after adding a simple console.log to file (~2 minutes)Β #42173

Closed
@OliverJAsh

Description

@OliverJAsh

Bug Report

πŸ”Ž Search Terms

performance, tsc, watch, build, rebuild, declaration, emit, incremental

πŸ•— Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about performance.

⏯ Playground Link

Unfortunately I cannot provide a reduced test case as I can only reproduce this on our very large project.

πŸ’» Code

TypeScript 4.1.2

  1. Clone and checkout https://github.com/unsplash/unsplash-web/tree/typescript-watch-issue, branch typescript-watch-issue. This is a private repository but I believe some members of the TS team already have access from debugging previous issues. If you don't have access, please send me your email address so I can provide access (TS team members only).
  2. Run yarn to install TS
  3. Run tsc --build ./tsconfig.json --watch
  4. Wait for the first build to complete
  5. Go to file app/actions/index.ts and add this line anywhere in the file, e.g. at the very bottom: console.log('foo')
  6. Save the changes to trigger tsc to rebuild

πŸ™ Actual behavior

The rebuild takes too long. On my machine it takes over 2 minutes.

πŸ™‚ Expected behavior

I expected the rebuild to be very fast, because we're using all of the performance optimisations at our disposal: e.g. incremental and project references.


One thing I noticed that might be helpful for debugging: the generated declaration file for app/actions/index.tsβ€”target-tsc-build/app/actions/index.d.tsβ€”is fairly small after the first build (after step 4) but then for some reason it is significantly larger after the second build (after step 6). I don't understand why these declarations would change after such a simple change.

Subsequent changes to this file do not suffer from this problem, e.g. if we remove the console.log('foo') line that was added in step 5 and then save the changes to trigger another rebuild, the rebuild is very fast.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design LimitationConstraints of the existing architecture prevent this from being fixedDomain: Declaration EmitThe issue relates to the emission of d.ts filesRescheduledThis issue was previously scheduled to an earlier milestone

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions