./packages/app
contains acreate-react-app
-based application./packages/tools
contains a very tiny library that uses babel to transpile sources in/src
to/lib
.
In ./packages/tools/src/index.js
you will find a flow-typed method called computeSquare
that is imported used in ./packages/app/src/App.js
. Lib tools is imported via
+----------------------+ +---------------------+
| | | |
| ./packages/tools | +-----------> | ./packages/app |
| | | |
| flow | | flow |
| mathjs | | create-react-app |
+----------------------+ +---------------------+
Both project use flow for type checking.
To make flow work with yarn workspaces, I'm using flow-mono
.
yarn start-dev
buildstools
(babel) andapp
, starts the app in dev mode and watches for changes intools
andapp
.yarn flow
executesflow-mono create-symlinks
andflow
on both packagestools
andapp
.
🚩 See flow errors in app/src/index.js
when we change method definition in tools/src/index.js
without restarting flow server 🚩
-
Copy sources as
*.js.flow
files near babel-transpiled files inlib/
withflow-copy-source
. No hot reloading : flow server does not pick the new files on change.killall flow
and editing flow config are the only ways I found to make flow pick the new files so far. -
add tools/ to
[include]
in.flowconfig
. I tried this in combination with 1. works if the libs have no imports. If they have imports intools
that are not dependencies ofapp
, it fails : for exampleCannot resolve module `styled-components`. 3| import styled from 'styled-components'; ^^^^^^^^^^^^^^^^^^^
TODO : Make this fail in this project.
-
Use
flow gen-flow-files
to generate type definitions from sources. This script is experimental, and on our projects it just fails. 💀 See facebook/flow#5871.
I did not find a good way to achieve this with flow.
I can't see any way around killall flow
for now.