Skip to content

tsc is very slow in subdirectories of larger project #36103

Closed
@bgmort

Description

@bgmort

Maybe there's something unique to my system or my project going on here, but I'm getting very slow performance from tsc when trying to compile a single file from a subdirectory inside a larger project. The larger project is being compiled with parcel and is not using a .tsconfig file right now. I can demonstrate with a trivial example, see code below.

TypeScript Version:
Version 3.8.0-dev.20200109, 3.7, 3.1 for comparison. All had the same issue.

Search Terms:
tsc, typescript compiler very slow in subdirectories, scanning files outside of root, unused files

Code

~/somepath/lib/sound echo "var s: string = 'hello';"  > hello.ts
~/somepath/lib/sound time tsc hello.ts

real	0m5.592s # <-- very slow
user	0m9.604s
sys	0m0.473s
~/somepath/lib/sound cp hello.ts /tmp/tstmp/
~/somepath/lib/sound pushd /tmp/tstmp/
/tmp/tstmp ls
hello.ts
/tmp/tstmp time tsc hello.ts

real	0m1.916s # <-- less slow
user	0m3.089s
sys	0m0.187s

Expected behavior:
Compiler should not take >5 seconds for a trivial compilation, and should only look at files referenced by the entry file.

Actual behavior:
When compiling a single trivial file (or even trying to compile a file that does not exist) from a subdirectory within a larger project, the compilation took over 5 seconds, vs <2 in a clean directory. But even the 2 seconds for a trivial compilation seems quite slow.

Related Issues:
Lots of issues refer to slow compilation, but I did not find any describing this specific problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs More InfoThe issue still hasn't been fully clarified

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions