flow is extremely slow to init when it needs to parse node_modules. So the easiest thing to do to ignore it with
[ignore]
.*/node_modules/.*
This is fine until you want the flow definitions from third party libraries. At which point the standard seems to be to install them via flow-typed. But what if the library generates its own flow source files such as graphql?
What is the best/recommended way to approach this? Is flow supposed to parse everything and I just need to cop the slow init time because that sounds like a terrible user experience as someone who works on multiple repo's a day?
I've dealt with this personally by writing regex in my ignore .flowconfig for NOT ignoring packages I explicitly know I need, but this seems very manual as I need to know every package and whether they use flow source files, flow-typed, or nothing at all.
I would first recommend to try starting the server in one of the supported lazy modes, and you can defer flow check to CI for full analysis.
A slightly less dangerous alternative to your that might reduce the number of files parsed could be configured as something along the lines of:
[ignore]
// Ignore subdependencies.
.*/node_modules/.*/node_modules
// If you have a monorepo, you might skip your workspace packages,
// as these probably shadow packages from the project root.
<PROJECT_ROOT>/packages/.*/node_modules
Additionally, it might be possible to ignore node_modules, opt into untyped-import strict mode and creating library definitions for all the untyped packages using flow-typed create-stub <pkg>. This could potentially be used in a way to reduce the number of files you have to parse, but it is somewhat laborious and would mainly benefit those who are hard-pressed with poor I/O.
Lastly, you might want to take a look at saved state.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With