flowtype


Flow takes very long to start up because it checks node_modules


I added Flow to my React/Redux/Webpack project and initially, it was great, I loved the type annotations. Over time, I noticed that the start up time of the project became really slow - around 120s; it used to be around 20s. Upon investigation, I realized that it was because Flow was scanning through all the JS files in node_modules.
I attempted to ignore node_modules in .flowconfig by adding:
[ignore]
.*node_modules/.*
The start up became fast again but Flow would complain Required module not found in places where I import external libraries from my code.
A workaround suggested in this Github issue was to flowignore the node_modules and manually add interfaces for external libraries. This seems to work but is a hassle to maintain when new libraries are added into the project.
It's frustrating to have to wait almost 2 minutes each time I start the project, are there any better ideas?
One way to avoid the Required module not found errors would be to run flow-typed install which will fetch existing libdefs for popular libraries from the flow-typed repository. It also generates stubs for the libraries that cannot be found in it. This works great for many projects but in some rare cases, the stubs for certain libraries like Immutable.js were not generated.
I eventually came up with cli command flow-scripts to automatically generate the libdef stub interfaces such that I could flowignore node_modules but not get the Required module not found errors.
Simply run
$ flow-scripts stub
in the root of the repository and the libdef stubs will be automatically generated in flow-typed directory.

Related Links

type-checking function signatures with less or more arguments
what is the right location for .js.flow in flowtype?
how to declare modules that has other modules in Flowtype?
How should a disjoint union wrapper be structured for refinement to work?
how to specify a range of folders in ignore section of Flowtype .flowconfig?
Filtering out maybe types before accessing nullable property
flowtype - higher order functions - currying
Flowtype: array of possible strings cannot be empty?
Defining an object consisting of other object types in Flow
Idiomatic way to access properties of union type
how to set the status of err to avoid flowtype check warning?
How can I get inferred type data with flowtype command?
Flow bool, boolean and Boolean
how to reuse object type definition in class definition in flowtype
flow fails on union type even with if/else
Strange error message “inconsistent use of library definitions” in flowjs

Categories

HOME
leaflet
intellij-idea
packet
abc
postsharp
arcgis
itext7
pandoc
crash
ms-application-insights
thermal-printer
sdk
google-api-oauth
subprocess
ios-universal-links
drush
chef-recipe
github-flavored-markdown
bookmarklet
owncloud
vivado-hls
wallet
printf
bug-reporting
ajaxcontroltoolkit
ps
chartist.js
jira-zephyr
scalatest
mongoose-im
scripting-language
dynamic-memory-allocation
azure-table-storage
sphinx4
pushpad
semantic-ui-react
overflow
postgresql-9.6
epub
offset
angularjs-resource
repeat
linkurious
directadmin
django-cors-headers
pyopenssl
noise
appcmd
gige-sdk
node.js-client
apache-commons-cli
scikit-image
settext
altova
jira-agile
cosign-api
hotkeys
aws-kms
jmh
pyshark
jmap
calc
ooad
wiql
webservices-client
stderr
alpha-beta-pruning
crystal-reports-7
qf-test
tigase
adabas
google-voice
ardor3d
ia-32
wpd
gwt2
gmail-imap
nx
biztalk-deployment
feincms
xcode4.6.3
diazo
stl-algorithm
idtabs
scsf
umfpack
wdm
parallel-python
xpolog
peoplepicker
windows-xp-embedded
newspeak
uccapi

Resources

Encrypt Message