-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
When using tsc
without tsconfig.json, i.e. passing compiler options via command line, subsequent incremental builds don't seem to speed up at all.
Unless I'm missing something about what exactly --incremental
is supposed to do, this seems wrong. The command I'm running looks something like tsc --incremental --tsBuildInfoFile abc.json --outDir xyz path/to/input.ts
. See below for exact repro.
TypeScript Version: 3.7.0-dev.20190928 (also 3.6.2, and likely earlier versions too)
Search Terms:
tsc, incremental, tsBuildInfoFile
Code
Here's a full repro you can run with bash, which installs dependencies, writes example code and runs tsc a few times (I'm using node 10.16.0, npm 6.9.0, MacOS):
mkdir tsc-incremental-bug-repro
cd $_
npm init -y
npm i typescript@3.7.0-dev.20190928 # what I got today from npm i typescript@next
mkdir -p packages/logger/src
cd packages/logger
npm init -y
npm i winston@3.2.1 @types/winston@2.4.4
echo "import * as winston from 'winston'" >> src/index.ts
echo "export const mylogger = winston" >> src/index.ts
cd ../..
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
Each call to time npx tsc ...
gave a similar overall time, about 5s on my machine. This seems very slow given it's compiling one tiny file. It'd be not-too-bad if it was only on the first build. As far as I can tell nothing is changing in the tsBuildInfoFile
.
Note - this example is using a pseudo-monorepo structure since that's the way I found it IRL, but here there's only one package, so that may not be relevant. Conceivably the source code having a different node_modules
than where tsc
lives could make a difference?
Expected behavior:
After the first run, tsc
uses tsBuildInfoFile
to determine that packages/logger/src/index.ts
is unchanged since the previous run, and finishes near-instantly.
Actual behavior:
It takes a full five seconds every time.
Some more info from using --diagnostics
and --extendedDiagnostics
:
Full command + output:
$ time npx tsc --incremental --diagnostics --extendedDiagnostics --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
Files: 94
Lines: 55069
Nodes: 242144
Identifiers: 91394
Symbols: 165716
Types: 32500
Memory used: 163085K
Assignability cache size: 37419
Identity cache size: 174
Subtype cache size: 0
I/O Read time: 0.02s
Parse time: 0.44s
Program time: 0.55s
Bind time: 0.35s
Check time: 1.58s
printTime time: 0.04s
Emit time: 0.04s
transformTime time: 0.01s
commentTime time: 0.00s
I/O Write time: 0.00s
Total time: 2.52s
real 0m2.884s
user 0m5.057s
sys 0m0.287s
Just for comparison, and to make sure it's not time
or npx
doing something bad:
$ time npx tsc --version
Version 3.7.0-dev.20190928
real 0m0.254s
user 0m0.209s
sys 0m0.041s
Playground Link:
N/A
Related Issues:
Maybe #30457