TypeScript
TypeScript copied to clipboard
Allow multiple tsconfig configurations for `--project` flag in cli
Suggestion
🔍 Search Terms
is:open project multiple label:Suggestion
✅ Viability Checklist
My suggestion meets these guidelines:
- [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x] This wouldn't change the runtime behavior of existing JavaScript code
- [x] This could be implemented without emitting different JS based on the types of the expressions
- [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- [x] This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion / 📃 Motivating Example
allow tsc to be invoked with multiple project configuration with --project / -p flag in cli like:
tsc --project tsconfig.dev.json tsconfig.prod.json
alternative syntax:
tsc --project tsconfig.dev.json --project tsconfig.prod.json
currently it is only possible to have 1 configuration per tsc run, so tsc has to be executed for each tsconfig like:
tsc --project tsconfig.dev.json
tsc --project tsconfig.prod.json
Note --build / -b flag allows specify multiple projects already.
💻 Use Cases
This is useful when one projects has more target configurations (e.g. for deployments / testing / user agents / devices). This is performance optimization only. The end result is already achievable by ruining tsc multiple times.
Somewhat related: #37884
This is performance optimization only.
I doubt this brings any performance, unless it internally re-uses some data structures across the project, which likely would be a massive undertaking.
Apart from pure startup time, there's not anything meaningful that can be reused between two subsequent project builds. It might actually be worse from a total time perspective because of memory pressure/fragmentation.
"Merging" config files on the command line (as linked) is something that I think is still on the table as a feature, so providing some syntax to do multiple projects today just for convenience would muddy the waters in a way that I think doesn't really pay for itself in terms of added value.
If you want to run multiple projects on a single command execution, you can use tsc --build with "solution" tsconfig files.
OK, I understand. Unfortunately with --build all files needs to be included with glob pattern to be "root", as only these are checked for modifications. The -p flag has ability to specify only the "main.ts" file and let tsc identify which files should be actually compiled to the output.
This issue has been marked as "Declined" and has seen no recent activity. It has been automatically closed for house-keeping purposes.