简体   繁体   English

将Facebook Flow与Ionic 3一起使用?

[英]Use Facebook Flow with Ionic 3?

I am looking to use the Facebook Static Analyzer Flow with my Ionic project. 我想在我的Ionic项目中使用Facebook静态分析器流程。 I am new to the different package managers as Ionic uses Webpack. 当Ionic使用Webpack时,我对不同的软件包管理者是陌生的。 Every tutorial I see for Flow indicates to configure Babel to use it, but it does not appear that Ionic uses Babel. 我为Flow看到的每个教程都指示将Babel配置为使用它,但似乎Ionic没有使用Babel。 Is there an issue configuring Flow with Ionic 3 with Babel? 用Babel用Ionic 3配置Flow是否存在问题?

All the references I have found for Typescript use either Babel or Webpack, which is why I am not sure that the two can work together. 我为Typescript找到的所有引用都使用Babel或Webpack,这就是为什么我不确定两者能否一起使用的原因。

There are two parts to Flow, the flow binary, and the flow preset for Babel. Flow分为两部分:二进制流和Babel预设流。

You write JS with added flow type annotations, but the flow type annotations would not be acceptable to your JS interpretter (node, browser etc) - so the source files have to be transpiled to remove the Flow type information. 您使用添加的流类型注释编写JS,但是您的JS解释器(节点,浏览器等)不接受流类型注释-因此必须编译源文件以删除流类型信息。

Babel is your transpiler, with the appropriate presets and plugins. Babel是您的编译器,带有适当的预设和插件。

Webpack is used ahead of that chain to marshall other resources to get from source to build/distribution code. 在该链之前使用Webpack来编组其他资源,以从源代码获取到构建/分发代码。

Webpack can be configured with the babel-loader plugin so that Babel is run as the packing proceeds. 可以使用babel-loader插件配置Webpack,以便在打包过程中运行Babel。

The babel-preset-flow is used to transpile the type-annotated code to plain JS. babel-preset-flow用于将带类型注释的代码转换为纯JS。

So, Webpack uses Babel, Babel uses Flow preset. 因此,Webpack使用Babel,Babel使用Flow预设。

There is also a comment mode for Flow which allows you to use Flow without having to do any transpiling which might also be a solution to your problem if you can't configure the tool stack to your liking. Flow还提供了一种注释模式,模式允许您使用Flow而不必进行任何转堆,如果您无法根据自己的喜好配置工具栈,这也可能是解决问题的一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM