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.

Make the generated app work if you flowcheck it

See original GitHub issue

It would be nice if it were possible to add flow to the default project. I tried a minimal flow setup, adding a blank .flowconfig to the root and // @flow to App.css. Four errors: screen shot 2016-07-21 at 10 06 32 pm

For the first two I might be configuring things wrong? The second two seem like flow doesn’t know how to handle the non-js imports that webpack is handling for us. I’m not sure what the right way to resolve this.

I was using flow version 0.29.0

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:45 (38 by maintainers)

github_iconTop GitHub Comments

28reactions
jamiebuildscommented, Aug 2, 2016

So there are a number of tasks that we have created in order to simplify the setup of Flow in create-react-app.

Right now the .flowconfig that you need to add to get started is a bit difficult. As @gaearon mentioned before it looks like this:

[libs]
./node_modules/fbjs/flow/lib

[options]
esproposal.class_static_fields=enable
esproposal.class_instance_fields=enable

module.name_mapper='^\(.*\)\.css$' -> 'react-scripts/config/flow/css'
module.name_mapper='^\(.*\)\.\(jpg\|png\|gif\|eot\|svg\|ttf\|woff\|woff2\|mp4\|webm\)$' -> 'react-scripts/config/flow/file'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe

There’s a couple things we want to do to get it down to zero config.

  • Ignoring node_modules by default, and have a happy path for installing flow-typed definitions. This eliminates the need to have the path in [libs] and the surpress_type’s.
  • Having sensible defaults for different file extensions. We can’t support 100% code coverage on something like css-modules but we can support the way all these files are used within create-react-app. This eliminates the module.name_mapper fields.
  • Potentially enable >= stage 2 esproposals by default.

We also want to improve the experience of Flow other than the initial setup.

  • Integrate with npm start for display type warnings like eslint does right now.
  • Hook into npm install for adding flow-typed definitions automagically without pain (or maybe some other solution than npm install, idk yet)

We discussed allowing the repo to have no .flowconfig file, but having this constraint improves the text editor experience so we’re punting on that for now.

As for enabling Flow in create-react-app projects themselves, we would be interested in seeing that happen. As for if it’s enabled on all files by default is up to the community to decide on what they want most. We don’t want to force ourselves on anyone, but adding // @flow on the top of every file is tedious.

If anyone has questions about this let me know, @gabelevi and I will be working through these.

25reactions
gaearoncommented, Jul 22, 2016

I added some instructions to the howto guide for now: https://github.com/facebookincubator/create-react-app/blob/master/template/README.md#adding-flow

Longer term, I think we should include Flow by default and Flow should have a way of extending configs like

import 'react-scripts/configs/flow'

for basic settings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make one flow check if another flow ran recently
Solved: I have built 3 flows as follows that send emails: 1.) Appointment Confirmation: This uses the trigger "When a new event is...
Read more >
Sign in to apps with your Apple ID using app-specific passwords
You use this app-specific password when the app asks you to sign in with your Apple ID. To generate and use app-specific passwords,...
Read more >
Troubleshoot Tableau Prep Builder
Using the LogShark Prep.twbx plugin, you can generate workbooks with an error and flow dashboard to help you analyze and visualize Prep issues....
Read more >
Salesforce - Amazon AppFlow - AWS Documentation
After you create a Salesforce connection in Amazon AppFlow, ... choosing Apps and then App Manager, and then selecting the connected app that...
Read more >
How to build a CI/CD pipeline with GitHub Actions in four ...
With GitHub Actions, you can trigger CI/CD workflows and pipelines of webhooks from these apps (even something simple, like a chat app ......
Read more >

github_iconTop Related Medium Post

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