当我使用 tsconfig.json 文件时,Typescript 编译非常慢

Jer*_*ink 7 typescript

当我使用项目文件 (tsconfig.json) 运行 tsc 时,需要很长时间(> 1 分钟)才能完成。当我在命令行或参数文件中指定相同的参数时,它会在几秒钟内完成。这发生在带有 typescript 2.7.2 的 Mac OS 上

这是我使用的 tsconfig.json:

{
  "compilerOptions": {
    "target": "es2017",
    "module": "commonjs",
    "outDir": "dist", 
    "rootDir": "src",  
    "sourceMap": true
  }
}
Run Code Online (Sandbox Code Playgroud)

当我使用 time 命令计时时,我得到以下结果:

> time tsc --diagnostics -p tsconfig.json

Files:           38
Lines:        34429
Nodes:       157429
Identifiers:  52565
Symbols:      50844
Types:        12929
Memory used: 86147K
I/O read:     0.02s
I/O write:    0.01s
Parse time:   0.64s
Bind time:    0.44s
Check time:   1.91s
Emit time:    0.19s
Total time:   3.19s

real    2m20.611s
user    0m34.914s
sys     1m11.042s
Run Code Online (Sandbox Code Playgroud)

需要2分钟以上。

当我创建一个如下所示的参数文件时:

--target es2017 --module commonjs --outDir dist --sourcemap
Run Code Online (Sandbox Code Playgroud)

并计时命令:

> time tsc --diagnostics @args src/*

Files:           38
Lines:        34429
Nodes:       157429
Identifiers:  52565
Symbols:      50844
Types:        12929
Memory used: 83773K
I/O read:     0.00s
I/O write:    0.00s
Parse time:   0.52s
Bind time:    0.24s
Check time:   1.10s
Emit time:    0.09s
Total time:   1.96s

real    0m2.259s
user    0m3.568s
sys     0m0.133s
Run Code Online (Sandbox Code Playgroud)

现在只需要 2 秒,但我不希望看到显着差异,因为我使用完全相同的选项运行 typescript。我是否忽略了什么?

Dhr*_*esh -2

如果你有一个下一个目录结构,它应该是src/**/*而不是src/*

或使用tsc @args --sourceRoot src