d4rekanguok/gatsby-typescript

On build errors the output file can be wiped

Opened this issue · 1 comments

When working on files while gatsby develop is running, sometimes a change causes the plugin to regenerate the output and it does almost seem like it nukes the file, before writing new output.
I checked the code, it's not what it's actually happening. I guess the codegen phase fails when the process is triggered while working on the code and there are build errors which is probably causing empty output being written.

Whilst working code generation tools in the past, it has sometimes proven to be helpful to only write, only after checking that the new output is different and only then actually touching the file - as build tools sometimes trigger rebuilds / invalidate caches just based on file modification times. I am not quite sure, if Gatsby would do that or not.

Obviously just keeping the existing file as it is, is somewhat misleading / undeterministic, as it might not be in sync with the present types in that moment, but it does seem like it could be at least a helpful option to improve developer ergonomics what this is all about in the end.

@mrackwitz ah this is good feedback and I've experienced the same issue. If I recall correctly, I think this occurs specifically happens when there are type errors (but it could be other things that cause the build to fail as well).

If you have some time, I'm sure @d4rekanguok would be accepting solutions to this. If I have some time this week, I can also try to figure something out.