fix: Stop matching every file when `includes` is not specified

Merged
PA
2mo ago
+367-11

What

There's a bug that when you don't specify anincludes in a tsconfig.json it will always match against all files in the entire repo.

The correct behaviour is to match aginst everything within the given workspace. i.e. **/*

Proof of tsc behaviour:
I could find anything in the official spec that says the default includes value but if you just run TypeScript against a an empty tsconfig.json it tells you the default

cat '{}' > tsconfig.json

yarn tsc -b

error TS18003: No inputs were found in config file '/Users/pshaw/atlassian/canvas/example/tsconfig.json'. Specified 'include' paths were '["**/*"]' and 'exclude' paths were '[]'.

Found 1 error.

Why

We have a large repo where the vast majority of tsconfig.json files do not specify an includes field. I did not attempt running a benchmark tool like hyperfine or be careful to remove existing caches but even with testing a single run, results are pretty clear:

Before:

┌─ Pipeline Performance ─────────────────────────────
│  discover files:      148.0ms  (17649 files)
│  workspaces:           75.1ms  (840 workspaces)
│  plugins:             503.6ms
│  script analysis:      12.3ms
│  parse/extract:       657.8ms  (17649 modules)  (parallel: ~5065ms CPU)
│  cache update:        666.6ms
│  entry points:        469.3ms  (10632 entries)
│  resolve imports:  494868.0ms
│  build graph:         504.4ms
│  analyze:           16577.7ms
│  (other):               0.0ms
│  ────────────────────────────────────────────────
│  TOTAL:            513061.9ms
└───────────────────────────────────────────────────

After:

┌─ Pipeline Performance ─────────────────────────────
│  discover files:      160.4ms  (17649 files)
│  workspaces:           81.7ms  (840 workspaces)
│  plugins:             635.2ms
│  script analysis:      12.0ms
│  parse/extract:       626.1ms  (17649 modules, 17649 cached, 0 parsed)
│  cache update:         56.7ms
│  entry points:        442.8ms  (10632 entries)
│  resolve imports:   12492.7ms
│  build graph:         454.0ms
│  analyze:           15665.7ms
│  (other):               0.0ms
│  ────────────────────────────────────────────────
│  TOTAL:             29960.6ms
└───────────────────────────────────────────────────

Noticed this while investigating #2444

Test plan

Ran cargo build --release and ran fallow against our monorepo