Parcel: Strip away flow types

Created on 8 Aug 2018  路  4Comments  路  Source: parcel-bundler/parcel

馃悰 bug report

Parcel is currently not able to consume flow typed modules

馃帥 Configuration (.babelrc, package.json, cli command)

N/A

馃 Expected Behavior

Flow types should be stripped (perhaps configurable through babel)

馃槸 Current Behavior

Flow types cause errors

馃拋 Possible Solution

  • locally link a copy of the module that contains flow types
  • Ask the maintainer to publish the module using .flow and .js files. .flow being the typed one and .js being processed by babel to strip away the typings
  • Make parcel automagically detect and strip away flow types (in node modules only)

馃敠 Context

Issue #1799

馃捇 Code Sample

import Typography from 'typography';

cc @chiefGui

Bug Confirmed Bug

All 4 comments

So I think we can just automatically detect flow and apply the babel plugin by looking at the first line as it should say: // @flow?

Another possible solution:

If we can detect a module that contains flow types (in order to locally link it), wouldn't be less-workaroundish to make parcel apply the transform right away, exclusively against that module?

Yeah I think that'll be the best approach @chiefGui , currently doing some research on flow to make sure the annotation on the first line is really required. So I don't make assumptions of a framework I've never used

According to their website:

Don鈥檛 forget to mention @flow on top of file, otherwise flow won鈥檛 report errors.

Also from the short period of time I've worked with Flow, I also do remember that I was required to annotate my files with @flow.

Finally, seems like in the Typography's case, they're also consistently using @flow (though I know one library isn't enough to say anything.).

This is just a support to help you on your research.

Was this page helpful?
0 / 5 - 0 ratings