question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

flow types fail compilation in monorepo with CRA next.66cc7a90

See original GitHub issue

Is 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

  1. Create a CRA project from scratch
  2. Add flow annotations as above
  3. yarn; yarn start
  4. See it working
  5. Move the code into an existing monorepo with yarn workspaces enabled
  6. yarn; yarn start
  7. See it failing

Expected Behavior

Should just work.

Actual Behavior

Compilation failure per above error.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:12

github_iconTop GitHub Comments

1reaction
bugzpoddercommented, Dec 8, 2018

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.

0reactions
stale[bot]commented, Jan 18, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found