Suggestion
π Search Terms
isolatedModules, tsc, worker, parallel
β
Viability Checklist
My suggestion meets these guidelines:
β Suggestion
For projects that have both isolatedModules: true and verbatimModuleSyntax: true, it is feasible to save end-to-end compile time by, after identifying changed source files, fork the transpilation part of the compilation into a worker (WebWorker on web, 'node:worker_threads' on NodeJs) so that it can be run in parallel with the type checker on the main thread (which gets declarationOnly: true injected into its config before emit).
I've prototyped this in the RC version of Heft here: microsoft/rushstack#4120
However, it seems like a straightforward enough feature with enough of a performance benefit that it would be useful to have as part of core TypeScript.
π Motivating Example
With isolatedModules: true and verbatimModuleSyntax: true, the time calculations are thus:
T_Transpile = Transform_js + Emit_js
T_Declaration = Check + Transform_dts + Emit_dts
T_Worker_Overhead = Parse + Bind
T_Startup = Resolve + Parse + Bind
T_Worker = T_Worker_Overhead + T_Transpile
T_Original = T_Startup + T_Transpile + T_Declaration
T_WithWorker = T_Startup + max(T_Declaration, T_Worker)
Testing on a modestly large local project (816 source files) has
T_Original = 19.7 s
T_Declaration = 10.0 s
T_Worker = 8.1 s
T_Worker_Overhead = 1.9 s
Resulting in a net end-to-end savings of 6.2 s out of 19.7 s = 31% with no change to the output.
π» Use Cases
Granted, custom build tools can do this, but a lot of developers prefer to use tsc directly, and by making this a core feature, it incentivizes improvements to the duplication that occurs in the implmentation (namely Parse + Bind).
Suggestion
π Search Terms
isolatedModules, tsc, worker, parallel
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
For projects that have both
isolatedModules: trueandverbatimModuleSyntax: true, it is feasible to save end-to-end compile time by, after identifying changed source files, fork the transpilation part of the compilation into a worker (WebWorker on web, 'node:worker_threads' on NodeJs) so that it can be run in parallel with the type checker on the main thread (which getsdeclarationOnly: trueinjected into its config before emit).I've prototyped this in the RC version of Heft here: microsoft/rushstack#4120
However, it seems like a straightforward enough feature with enough of a performance benefit that it would be useful to have as part of core TypeScript.
π Motivating Example
With
isolatedModules: trueandverbatimModuleSyntax: true, the time calculations are thus:T_Transpile = Transform_js + Emit_jsT_Declaration = Check + Transform_dts + Emit_dtsT_Worker_Overhead = Parse + BindT_Startup = Resolve + Parse + BindT_Worker = T_Worker_Overhead + T_TranspileT_Original = T_Startup + T_Transpile + T_DeclarationT_WithWorker = T_Startup + max(T_Declaration, T_Worker)Testing on a modestly large local project (816 source files) has
T_Original = 19.7 sT_Declaration = 10.0 sT_Worker = 8.1 sT_Worker_Overhead = 1.9 sResulting in a net end-to-end savings of
6.2 sout of19.7 s=31%with no change to the output.π» Use Cases
Granted, custom build tools can do this, but a lot of developers prefer to use
tscdirectly, and by making this a core feature, it incentivizes improvements to the duplication that occurs in the implmentation (namely Parse + Bind).