mst-gql
mst-gql copied to clipboard
Typescript compilation speed regression
This is definitely (probably?) not an issue with mst-gql itself but I thought I report that with newer versions of Typescript the compilation of mst-gql models gets slower and slower. The compilation times were always a huge pain for me but it is now getting worse.
OK, so as always I work with a Hasura generated huge graphql API for which I generate mst-gql models and it contains 1471 files
> ls -l src | wc -l
1471
src
contains only the mst-gql generated files.
I compiled it using tsc
with 3 versions of TS, and here are my results measured with unix time
:
3.7.2
real 1m47.587s
user 1m59.191s
sys 0m3.440s
3.9.7
real 2m21.898s
user 2m37.325s
sys 0m3.917s
4.1.2
real 2m59.653s
user 3m13.593s
sys 0m4.436s
The interesting thing is that 3.9 is supposed to bring up to 40% compilation speed gain. In my case, however, it was way slower than with 3.7.2.
As 4.1 is out now I also tried with that one (4.1.2) and the speed is even worse.
@chrisdrackett @RXminuS @godness84 do you think there is anything we can do on the mst-gql side to make compilation faster?
I wonder if this is worth bringing up with the Typescript team? I feel they might be more equipped to explain why mst-gql
is getting slower in particular. How long does it take to compile a codebase that consumes your models?
My current workaround is that I generate my mst-gql models in a separate module, compile using "incremental": true
setting in tsconfig.json
and import the compiled build into my main project. With this setup my React app doesn't compile the huge mst-gql models all the time, and model recompilation only happens incrementally for specific files that change.
Anyway, I will try to create an example huge graphql.schema
where the compilation speed can be demonstrated/tested.