Skip to content

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

Closed
@bebbi

Description

@bebbi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions