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 Yarn Workspaces #1391

Closed
k15a opened this issue Oct 23, 2017 · 14 comments
Closed

Support Yarn Workspaces #1391

k15a opened this issue Oct 23, 2017 · 14 comments
Assignees
Labels
cli Related to CLI tool enhancement An addition to an existing component

Comments

@k15a
Copy link

k15a commented Oct 23, 2017

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. facebook/flow#5107

@Inkdpixels
Copy link
Contributor

Inkdpixels commented Dec 20, 2017

@k15a FYI there is a CLI called flow-mono-cli which solves most of the issues when working with flow in a mono-repo. Check it out, if you have any additional feature requests or feedback I am more than happy to hear from you! :)

@k15a
Copy link
Author

k15a commented Dec 20, 2017

@Inkdpixels I've already seen that and tried it at work. Unfortunately, it's only working with node 8 and if you use yarn will not even install because of some dependency.

@Inkdpixels
Copy link
Contributor

@k15a That is unfortunate! We do require Node 8 of course since it is the current LTS and advise anyone to upgrade as soon as possible, but the dependency error sounds a bit weird, can you elaborate what exactly is causing an error there so I can reproduce it / fix it? That would be super cool! Thanks in advance :)

@AugustinLF
Copy link
Contributor

@Inkdpixels and what suggestion do you have when using a single flow at the root? That's the approach I took, but flow-typed now doesn't know how to install the definitions :/

@Inkdpixels
Copy link
Contributor

@AugustinLF We embrace having flow setup for each package, while it sounds like overhead in the first place we found that flow just works better, faster and leads to less headaches if you extract packages from your mono-repo in the future.

The CLI we built guides you on how to properly set up a mono-repo without much hassle and support's you as much as possible, if you have any feedback we are more than open for suggestions!

FYI we also support root flow-typed definitions, but, as stated before, we need flow-typed and flow in each package. :-)

@gantoine gantoine added the cli Related to CLI tool label Mar 21, 2018
@josh08h
Copy link

josh08h commented May 15, 2018

Is any action to be taken regarding this?

@AndrewSouthpaw
Copy link
Contributor

I haven't seen anything in the past couple months to my recollection.

@rcalabro
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 😉

@11111000000
Copy link

any progress here?

@gantoine gantoine self-assigned this Feb 3, 2020
@jeremyblalock
Copy link

@11111000000 this stackoverflow answer might be helpful: https://stackoverflow.com/a/57017179/2150422

To fix it need update .flowconfig:

[include]
../../node_modules/

FS struct:

/project_root
--/node_modules
--/packages
----/module1
------.flowconfig>

@AndrewSouthpaw
Copy link
Contributor

Thanks for sharing @jeremyblalock ! If anyone is feeling motivated, I'm sure an addition to the README for this repo would be welcome to explain how to add support for yarn workspaces.

@Brianzchen
Copy link
Member

This seems solved from #4140.

@AndrewSouthpaw or anyone else, do you see any reason to keep this issue open? Are there anymore challenges that should be solved by flow-typed? I believe if you choose to run a different .flowconfig in each package in a monorepo that has no extra functionality need from flow-typed

@AndrewSouthpaw
Copy link
Contributor

Seems reasonable to me! I think a note in the README would still be a valid addition, but I think this is fine to close. Thanks @Brianzchen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to CLI tool enhancement An addition to an existing component
Projects
None yet
Development

No branches or pull requests