Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support flow-typed directories in yarn workspaces #5183

Open
k15a opened this issue Oct 25, 2017 · 4 comments
Open

Support flow-typed directories in yarn workspaces #5183

k15a opened this issue Oct 25, 2017 · 4 comments
Labels
declarations Issues with library definitions or .js.flow features module resolution

Comments

@k15a
Copy link

k15a commented Oct 25, 2017

This is related to an issue in flow-typed: flow-typed/flow-typed#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. #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
Copy link

any updates on this ?

@colin-han
Copy link

+1

@wewelll
Copy link

wewelll commented Dec 28, 2018

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
Copy link
Contributor

nmote commented Feb 2, 2019

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?

@goodmind goodmind added declarations Issues with library definitions or .js.flow features module resolution labels May 24, 2019
goodhoko added a commit to trezor/trezor-suite that referenced this issue Jun 17, 2021
After moving trezor-link to this monorepo (newly named as
@trezor/transport) the flow type-checking broke because flow is not
compatible with yarn workspaces we use here.
facebook/flow#5183

In particular, flow fails to resolve packages hoisted to the root
node_modules directory.

Use yarn's nohoist option to prevent hoisting of all transport's
dependencies. This might be more aggressive than needed - some packages
probably can be hoisted without breaking flow. Leave that for a later
optimization as the transport package is awaiting a big refactoring
soon.
goodhoko added a commit to trezor/trezor-suite that referenced this issue Jun 18, 2021
After moving trezor-link to this monorepo (newly named as
@trezor/transport) the flow type-checking broke because flow is not
compatible with yarn workspaces we use here.
facebook/flow#5183

In particular, flow fails to resolve packages hoisted to the root
node_modules directory.

Use yarn's nohoist option to prevent hoisting of all transport's
dependencies. This might be more aggressive than needed - some packages
probably can be hoisted without breaking flow. Leave that for a later
optimization as the transport package is awaiting a big refactoring
soon.
goodhoko added a commit to trezor/trezor-suite that referenced this issue Jun 18, 2021
After moving trezor-link to this monorepo (newly named as
@trezor/transport) the flow type-checking broke because flow is not
compatible with yarn workspaces we use here.
facebook/flow#5183

In particular, flow fails to resolve packages hoisted to the root
node_modules directory.

Use yarn's nohoist option to prevent hoisting of all transport's
dependencies. This might be more aggressive than needed - some packages
probably can be hoisted without breaking flow. Leave that for a later
optimization as the transport package is awaiting a big refactoring
soon.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
declarations Issues with library definitions or .js.flow features module resolution
Projects
None yet
Development

No branches or pull requests

6 participants