facebook / flow

Adds static typing to JavaScript to improve developer productivity and code quality.
https://flow.org/
MIT License
22.07k stars 1.85k forks source link

Support flow-typed directories in yarn workspaces #5183

Open k15a opened 6 years ago

k15a commented 6 years ago

This is related to an issue in flow-typed: https://github.com/flowtype/flow-typed/issues/1391

Yarn has a feature called workspaces which is quite good for monorepos.

The problem is that they are not working good with flow and flow-typed. There are two options to use flow in a monorepo:

Use a single flow in the root

The problem is that flow will only use the flow-typed folder in the root so all typings installed in the individual package folders are ignored.

Flow-typed could install all typings into the root and check for the workspaces key in the package.json for individual packages. (This will probably be an issue when package A depends on a different version of an npm package than package B)

Use one flow per package

The problem here is that yarn will hoist some packages into the root of the project and flow can't find them there. This is a problem with flow because it seems that they use a different module resolution algorithm then node does. https://github.com/facebook/flow/issues/5107

For the first approach (one flow in the root) it would be great if you could search for typings (flow-typed directory) in the specific workspace directory and then in the root.

alzalabany commented 6 years ago

any updates on this ?

colin-han commented 5 years ago

+1

wewelll commented 5 years ago

flow-mono-cli is a good option, but an official support would be better !

Here is small article I wrote on the topic : https://medium.com/inato/how-to-use-flow-in-a-mono-repo-8947d43d50fb 😉

nmote commented 5 years ago

Does it work to specify each flow-typed folder in the package folders under the [libs] section of the .flowconfig? Is the issue basically that doing so is unpalatable, and it would be easier if Flow just recursively looked for flow-typed folders, or is there something else going on?