flow types fail compilation in monorepo with CRA next.66cc7a90
See original GitHub issueIs this a bug report?
yes.
It’s a project with flow annotations. Lines like these appear to trigger the issue:
import type { Props, ComponentState } from './MyComponent.type'
The error is:
Failed to compile.
./src/components/MyComponent.js
Module build failed: TypeError: Cannot read property 'type' of undefined
at Array.forEach (<anonymous>)
at Array.forEach (<anonymous>)
Moving the code outside the monorepo and yarn; yarn start
: works.
Keep it inside and remove all flow annotations: works.
Did you try recovering your dependencies?
Yes.
In fact, adding a package.json
declaration of
"nohoist": [
"**/react-scripts", "**/react-scripts/**"
]
works around the issue.
Which terms did you search for in User Guide?
flow, monorepo, workspaces
Environment
Environment:
OS: macOS High Sierra 10.13.4
Node: 8.9.1
Yarn: 1.6.0
npm: 6.0.1
Watchman: 4.9.0
Xcode: Xcode 9.3.1 Build version 9E501
Android Studio: Not Found
Packages: (wanted => installed)
(paste the output of the command here)
Steps to Reproduce
- Create a CRA project from scratch
- Add flow annotations as above
yarn; yarn start
- See it working
- Move the code into an existing monorepo with yarn workspaces enabled
yarn; yarn start
- See it failing
Expected Behavior
Should just work.
Actual Behavior
Compilation failure per above error.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:12
Top Results From Across the Web
Create React App + Typescript In monorepo code sharing
I have some TS code in common I want to use in web , but it seems that CRA does not support compiling...
Read more >Guide — The Multi CRA Lerna Monorepo - ITNEXT
Guide — The Multi CRA Lerna Monorepo. In this guide you will learn how to scaffold a Monorepo to manage multiple Create React...
Read more >eslint-config-react-app: Versions - Openbase
Full version history for eslint-config-react-app including change logs.
Read more >How to setup React Monorepo (Lerna, CRA, Typescript, Craco ...
Learn how to setup a monorepo project with Lerna, React, Typescript and code sharing between packages. We use Create React App with ...
Read more >How to Create a React Typescript Monorepo with Git ...
Another big benefit is the ability to import and share code and modules between projects. Sharing types between the back-end and front-end is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The reason is that create-react-app won’t process libraries from using non-standard features such as flow and other js features and proposals that are not currently finalized, in order to avoid defragmentation of the js landscape. What you are doing however is just sharing source code between different apps, so its a different use case that create-react-app isn’t supporting right now but will in the future.
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.