Skip to content

Instantly share code, notes, and snippets.

@honewatson
Last active July 27, 2018 06:54
Show Gist options
  • Select an option

  • Save honewatson/51a192c79dcaaf53683770cd4ed7193c to your computer and use it in GitHub Desktop.

Select an option

Save honewatson/51a192c79dcaaf53683770cd4ed7193c to your computer and use it in GitHub Desktop.
Remove flow types from code base
{
"plugins": ["syntax-jsx", "syntax-object-rest-spread", "transform-flow-strip-types"]
}

Babel has two common types of plugins 'syntax' plugin and 'transform' plugin.

'syntax' plugin provides support for non standard syntax like JSX or Object Rest Spread but it does not transform the syntax.

'transform' plugin transforms the syntax to the target version (ES5)

So you need the strip flow type transform plugin and any syntax plugin to keep your code base in its current state.

// run yarn or npm install with the package.json and .babelrc in a new directory
npm install
// clone your repo into your new directory
git clone <your-repo>
// strip out flow types from your source code to a directory named 'out'
./node_modules/.bin/babel --out-dir out <your-repo>/<src>
// copy your stripped code over the the top of your source
rsync -av out/ <your-repo>/<src>/
{
"name": "flow-dest",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"lib": "lib"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment