babel-upgrade
A tool that tries to automatically update most dependencies, config files, and JavaScript files that require Babel packages directly to Babel v7 (and more in the future).
Usage
Run at the root of your git repo:
If using npm < v5.2.0, install npx globally.
npx babel-upgrade --write
npm install babel-upgrade -g
babel-upgrade --write
Without the --write
(or -w
) flag, babel-upgrade
will print a diff without writing any changes.
Optionally, add --install
as well to run yarn
or npm
after writing the upgrade.
npx babel-upgrade --write --install
Ideas from http://new.babeljs.io/docs/en/next/v7-migration.html (or modify that file if it's missing)
Todos
{
"devDependencies": {
+ "@babel/core": "7.0.0-beta.39",
+ "@babel/plugin-proposal-object-rest-spread": "7.0.0-beta.39",
+ "@babel/preset-env": "7.0.0-beta.39",
+ "babel-loader": "v8.0.0-beta.0"
- "babel-loader": "6.0.0",
- "babel-plugin-transform-object-rest-spread": "6.0.0",
- "babel-preset-env": "^1.0.0",
},
}
{
"name": "mocha-scripts-test",
"scripts": {
- "test": "mocha --compilers js:babel-register --require babel-polyfill test/*Test.js",
+ "test": "mocha --compilers js:@babel/register --require @babel/polyfill test/*Test.js",
}
}
"devDependencies": {
"@babel/core": "7.0.0-beta.39",
+ "babel-core": "7.0.0-bridge.0",
"jest": "^22.0.0"
},
"scripts": {
"test": "jest"
}
"devDependencies": {
"@babel/cli": "7.0.0-beta.39",
+ "@babel/node": "7.0.0-beta.39"
},
"scripts": {
"start": "babel-node a.js"
}
- src/
- example/
- .babelrc // now modifies these too
- test/
- .babelrc // now modifies these too
- `.babelrc`
{
"presets": [
+ "@babel/preset-env"
- "env"
]
}
{
"babel": {
"presets": [
+ "@babel/preset-env"
- "env"
]
}
}
{
"babel": {
"presets": [
"@babel/preset-env"
]
},
"env": {
"development": {
"plugins": [
- "transform-react-jsx-source",
- "babel-plugin-transform-react-jsx-self"
+ "@babel/plugin-transform-react-jsx-source",
+ "@babel/plugin-transform-react-jsx-self",
]
}
}
}
+--require @babel/register
{
- "presets": "env, react",
+ "presets": ["env", "react"],
{
"@babel/preset-react": "7.0.0-beta.39",
+ "@babel/preset-flow": "7.0.0-beta.39"
}
Philosophy
- Move this into the monorepo when somewhat ready
- Maybe move into
@babel/cli
? - Or just another package that is intended to be used via
npx/globally
- Whenever there is a breaking change in a PR we should also update this tool when possible or at least provide a warning
- What about with a regression?
- Can be used for non-major bumps too - just for updating to the latest version.
- Include mini-changelog?
- Maybe the version should just reflect the version that it targets?
Development
$ npm i
$ npm start