• Stars
    star
    1,309
  • Rank 35,952 (Top 0.8 %)
  • Language
    JavaScript
  • Created almost 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

⬆️ A tool for upgrading Babel versions (to v7): `npx babel-upgrade`

babel-upgrade

A tool that tries to automatically update most dependencies, config files, and JavaScript files that require Babel packages directly to Babel 7 (and more in the future).

Usage

Requires nodejs 8 or newer

Run at the root of your git repo:

If using npm < v5.2.0, install npx globally.

# npx lets you run babel-upgrade without installing it locally
npx babel-upgrade --write

# or install globally and run
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 (or -i) 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

  • Works on Node >= 8 (anything lower isn't supported in v7) (#16)
  • Run npm/yarn after updating dependencies (use --install) (#18)
  • Update package.json: dependencies and devDependencies to the "latest supported" version.
    • all package renames
      • babel-loader for webpack >=1 (#34)
      • rollup-plugin-babel (#36)
    • Upgrading the same package to the latest version
    • add @babel/core peerDep (7c34cd)
{
  "devDependencies": {
+   "@babel/core": "^7.0.0",
+   "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
+   "@babel/preset-env": "^7.0.0",
+   "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",
  },
}
  • modify scripts for mocha + @babel/register (e81cf7)
{
  "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",
  }
}
  • use "babel-core": "^7.0.0-bridge-0" if jest or jest-cli is a dependency (#14)
"devDependencies": {
  "@babel/core": "^7.0.0",
+ "babel-core": "7.0.0-bridge.0",
  "jest": "^22.0.0"
},
"scripts": {
  "test": "jest"
}
  • add new @babel/node package if babel-node is used (#14)
"devDependencies": {
  "@babel/cli": "^7.0.0",
+ "@babel/node": "^7.0.0"
},
"scripts": {
  "start": "babel-node a.js"
}
  • Handle all nested .babelrc (#14)
- src/
- example/
  - .babelrc // now modifies these too
- test/
  - .babelrc // now modifies these too
- `.babelrc`
  • rename config files to swap shorthand form to long form
{
  "presets": [
+   "@babel/preset-env"
-   "env"
  ]
}
  • package.json babel key (d123ad)
{
  "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
+--require @babel/register
  • Convert comma separated presets/plugins into an array (#37)
{
-  "presets": "env, react",
+  "presets": ["@babel/preset-env", "@babel/preset-react"],
  • handle react + flow preset being split. Read if .flowconfig and add it? (#21)
{
  "@babel/preset-react": "^7.0.0",
+  "@babel/preset-flow": "^7.0.0"
}
  • Replace Stage presets with individual proposal plugins (#69)
{
-  "presets": ["@babel/preset-stage-3"],
+  "presets": [],
+  "plugins": [
+    "@babel/plugin-syntax-dynamic-import",
+    "@babel/plugin-syntax-import-meta",
+    "@babel/plugin-proposal-class-properties",
+    "@babel/plugin-proposal-json-strings"
+  ]
}
{
-    "@babel/preset-stage-3": "^7.0.0"
+    "@babel/plugin-proposal-class-properties": "^7.0.0",
+    "@babel/plugin-proposal-json-strings": "^7.0.0",
+    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
+    "@babel/plugin-syntax-import-meta": "^7.0.0"
}
  • Log when replacing out preset-es2015,16,17,latest as FYI
  • Figure out how to change nested .babelrcs into using "overrides" instead
  • Monorepo support
  • .babelrc.js and other js files with a config like presets, webpack.config.js
  • convert only/ignore if necessary
  • remove typeof-symbol if using @babel/preset-env + loose
  • Update test files that use babel directly (babel-types -> @babel/types, babel-core)
    • Update all requires/imports
    • Update the use of the Babel API (plugins, integrations)
  • Modify other config files as we go
  • Add to the upgrade guide which parts are autofixable and the command (if we care enough to make this individually runnable too infrastructure wise)
  • May need to add a warning on any 3rd party plugins since they might not be compatible
  • Handle the differences in plugins in v7 for default/loose/spec
  • Should certain parts be generic (replace the string babel-register with @babel/register)? Could be in a Makefile or somewhere else, but it's just find replace.

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 install
npm start

More Repositories

1

babel

🐠 Babel is a compiler for writing next generation JavaScript.
TypeScript
43,141
star
2

babel-loader

📦 Babel loader for webpack
JavaScript
4,824
star
3

minify

✂️ An ES6+ aware minifier based on the Babel toolchain (beta)
JavaScript
4,391
star
4

babel-preset-env

PSA: this repo has been moved into babel/babel -->
JavaScript
3,500
star
5

babel-sublime

Syntax definitions for ES6 JavaScript with React JSX extensions.
JavaScript
3,256
star
6

babel-eslint

🗼 A wrapper for Babel's parser used for ESLint (renamed to @babel/eslint-parser)
JavaScript
2,963
star
7

example-node-server

Example Node Server w/ Babel
JavaScript
2,844
star
8

babylon

PSA: moved into babel/babel as @babel/parser -->
JavaScript
1,714
star
9

babelify

Browserify transform for Babel
JavaScript
1,680
star
10

gulp-babel

Gulp plugin for Babel
JavaScript
1,320
star
11

awesome-babel

😎A list of awesome Babel plugins, presets, etc.
864
star
12

babel-standalone

🎮 Now located in the Babel repo! Standalone build of Babel for use in non-Node.js environments, including browsers.
JavaScript
819
star
13

website

🌐 The Babel documentation website
TypeScript
749
star
14

preset-modules

A Babel preset that targets modern browsers by fixing engine bugs (will be merged into preset-env eventually)
JavaScript
739
star
15

kneden

Transpile ES2017 async/await to vanilla ES6 Promise chains: a Babel plugin
JavaScript
514
star
16

grunt-babel

Grunt plugin for Babel
JavaScript
437
star
17

proposals

✍️ Tracking the status of Babel's implementation of TC39 proposals (may be out of date)
432
star
18

eslint-plugin-babel

An ESlint rule plugin companion to babel-eslint
JavaScript
389
star
19

generator-babel-boilerplate

A Yeoman generator to author libraries in ES2015 (and beyond!) for Node and the browser.
JavaScript
381
star
20

babel-time-travel

Time travel through babel transformations one by one (implemented in the Babel REPL now)
JavaScript
344
star
21

babel-polyfills

A set of Babel plugins that enable injecting different polyfills with different strategies in your compiled code.
TypeScript
330
star
22

babel-sublime-snippets

Next generation JavaScript and React snippets for Sublime
263
star
23

karma-babel-preprocessor

Karma plugin for Babel
JavaScript
167
star
24

ruby-babel-transpiler

Ruby Babel is a bridge to the JS Babel transpiler.
Ruby
159
star
25

babel-jest

Jest plugin for Babel (moved) ->
138
star
26

notes

♬ Notes from the @Babel Team (discuss in PRs)
122
star
27

generator-babel-plugin

Babel Plugin generator for Yeoman
JavaScript
118
star
28

babel-bridge

A placeholder package that bridges babel-core to @babel/core.
JavaScript
94
star
29

babel-bot

🤖 A helpful bot to automate common tasks on Babel Issues/PRs
JavaScript
75
star
30

babel-brunch

Brunch plugin for Babel
JavaScript
68
star
31

broccoli-babel-transpiler

Broccoli plugin for Babel
JavaScript
57
star
32

jade-babel

Jade plugin for Babel
JavaScript
40
star
33

sandboxes

Babel repl-like codesandbox: check out link =>
JavaScript
39
star
34

jekyll-babel

A Babel converter for Jekyll.
Ruby
34
star
35

acorn-to-esprima

(unmaintained) Converts acorn tokens to esprima tokens
JavaScript
33
star
36

babel-connect

Connect plugin for Babel
JavaScript
27
star
37

podcast.babeljs.io

The Babel Podcast site!
JavaScript
25
star
38

phabricator-to-github

A tool to migrate phabricator issues to github
JavaScript
24
star
39

actions

Babel specific github actions 🤖
JavaScript
24
star
40

rfcs

RFCs for changes to Babel
21
star
41

metalsmith-babel

A Metalsmith plugin to compile JavaScript with Babel
JavaScript
20
star
42

babel-configuration-examples

WIP
JavaScript
18
star
43

logo

Babel logo
15
star
44

duo-babel

Duo plugin for Babel
JavaScript
15
star
45

parser_performance

JavaScript
13
star
46

eslint-config-babel

ESLint config for all Babel repos
JavaScript
10
star
47

gobble-babel

Gobble plugin for Babel
JavaScript
9
star
48

babel-standalone-bower

Bower build of babel-standalone. See https://github.com/Daniel15/babel-standalone
JavaScript
9
star
49

eslint-plugin-babel-plugin

A set of eslint rules to enforce best practices in the development of Babel plugins.
JavaScript
8
star
50

babel-plugin-proposal-private-property-in-object

@babel/plugin-proposal-private-property-in-object, with an added warning for when depending on this package without explicitly listing it in dependencies or devDependencies
JavaScript
8
star
51

babel-archive

🗑 Packages that are deprecated or don't need to be updated
JavaScript
7
star
52

.github

Community health files for the Babel organization
7
star
53

flavortown

what else?
6
star
54

babel-test262-runner

Run test262 tests on Node 0.10 using Babel 7 and `core-js@3`.
JavaScript
6
star
55

babel-plugin-transform-async-functions

https://github.com/MatAtBread/fast-async/issues/46
4
star
56

phabricator-redirects

↩️ Redirects for old phabricator urls
HTML
2
star
57

slack-invite-link

Source of slack.babeljs.io
1
star