flow-remove-types
flow-remove-types 是一个小型 CLI 工具,用于从文件中剥离 Flow 类型注释。对于不需要 Babel 提供的一切的项目来说,它是 Babel 的轻量级替代品。
¥flow-remove-types is a small
CLI tool for stripping Flow type annotations from files. It's a lighter-weight
alternative to Babel for projects that don't need everything Babel provides.
首先安装 flow-remove-types 和 Yarn 或 npm。
¥First install flow-remove-types with either
Yarn or npm.
yarn add --dev flow-remove-types
# or
npm install --save-dev flow-remove-types
如果你将所有源文件放在 src 目录中,则可以通过运行以下命令将它们编译到另一个目录:
¥If you then put all your source files in a src directory you can compile them
to another directory by running:
yarn run flow-remove-types src/ -d lib/
你可以轻松地将其添加到 package.json 脚本中。
¥You can add this to your package.json scripts easily.
{
"name": "my-project",
"main": "lib/index.js",
"scripts": {
"build": "flow-remove-types src/ -d lib/",
"prepublish": "yarn run build"
}
}
注意:你可能还需要添加一个运行此转换的
prepublish脚本,以便它在将代码发布到 npm 注册表之前运行。¥Note: You'll probably want to add a
prepublishscript that runs this transform as well, so that it runs before you publish your code to the npm registry.