Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flow - am I supposed to ignore node_modules?

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.

like image 781
Brianzchen Avatar asked Jan 01 '26 02:01

Brianzchen


1 Answers

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.

like image 113
Filip Dupanović Avatar answered Jan 06 '26 10:01

Filip Dupanović



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!