Flow doesn't work with Lerna when importing packages into one another
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
I have a Lerna package containing two different React apps made with Create React App (let's called them App A and App B). One of the apps imports the other one. I want to add Flow support to both apps. To do so, I've installed Flow at the global level.
Flow functions correctly when each app is used separately. However, when I import one of the apps into the other, I get the following error in App B:
Module parse failed: Unexpected token (8:5)
You may need an appropriate loader to handle this file type.
import { AppA } from 'app-a';
type Options = {
key: string,
onSuccess: function,
The way I interpret this is that Flow is not processing App A because it is a symlinked dependency (due to Lerna) inside App B. To resolve this, here is what I've tried:
* In the .flowconfig, under [options], add:
`module.name_mapper='^app-a$' -> '/../app-a/src/index.js'` where `index.js` is the entry point for App A. This solution came from: https://github.com/lerna/lerna/issues/891
* In the .flowconfig, under [include], add:
`../app-a/src/index.js`
* Rather than using Flow globally, install Flow in each app separately. Using these separate Flow instances, I ran `flow ls` inside App B and saw that both `app-b` and `app-a` were part of the file list, but still got the same error
* I've been avoiding ejecting my Create React App because I want to be able to update to newer versions without hassle. Therefore, it would be more optimal if I didn't have to use the flow strip types plugin
I copy and pasted this from my question on Stack Overflow: https://stackoverflow.com/questions/49090460/using-flow-with-lerna-and-create-react-app#
Contributor guide
Assessment
This issue has not been assessed yet.