{"id":13527030,"url":"https://github.com/babel/babel-upgrade","last_synced_at":"2025-05-15T01:06:42.261Z","repository":{"id":29306315,"uuid":"121311248","full_name":"babel/babel-upgrade","owner":"babel","description":"⬆️ A tool for upgrading Babel versions (to v7): `npx babel-upgrade`","archived":false,"fork":false,"pushed_at":"2023-07-08T11:36:45.000Z","size":837,"stargazers_count":1311,"open_issues_count":38,"forks_count":54,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-03T14:25:07.210Z","etag":null,"topics":["babel","babel-upgrade"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babel.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["babel"],"open_collective":"babel","custom":"https://gitcoin.co/grants/2906/babel-compiler-for-next-generation-javascript"}},"created_at":"2018-02-12T22:36:46.000Z","updated_at":"2025-04-28T07:07:03.000Z","dependencies_parsed_at":"2023-01-14T14:45:23.551Z","dependency_job_id":null,"html_url":"https://github.com/babel/babel-upgrade","commit_stats":{"total_commits":153,"total_committers":23,"mean_commits":"6.6521739130434785","dds":0.542483660130719,"last_synced_commit":"67fbae8603601de832dee943567890cf34b710d6"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-upgrade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-upgrade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-upgrade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babel%2Fbabel-upgrade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babel","download_url":"https://codeload.github.com/babel/babel-upgrade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252446621,"owners_count":21749272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","babel-upgrade"],"created_at":"2024-08-01T06:01:39.584Z","updated_at":"2025-05-15T01:06:37.221Z","avatar_url":"https://github.com/babel.png","language":"JavaScript","readme":"# babel-upgrade\n\n\u003e A tool that tries to automatically update most dependencies, config files, and JavaScript files that require Babel packages directly to [Babel 7](http://babeljs.io/docs/en/v7-migration.html) (and more in the future).\n\n## Usage\n\n**Requires nodejs 8 or newer**\n\nRun at the root of your git repo:\n\n\u003e If using npm \u003c v5.2.0, install [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) globally.\n\n```bash\n# npx lets you run babel-upgrade without installing it locally\nnpx babel-upgrade --write\n\n# or install globally and run\nnpm install babel-upgrade -g\nbabel-upgrade --write\n```\n\nWithout the `--write` (or `-w`) flag, `babel-upgrade` will print a diff without writing any changes.\n\nOptionally, add `--install` (or `-i`) as well to run `yarn` or `npm` after writing the upgrade.\n\n```bash\nnpx babel-upgrade --write --install\n```\n\n\u003e Ideas from http://new.babeljs.io/docs/en/next/v7-migration.html (or modify that file if it's missing)\n\n## Todos\n\n- [x] Works on Node \u003e= 8 (anything lower isn't supported in v7) ([#16](https://github.com/babel/babel-upgrade/pull/16))\n- [x] Run npm/yarn after updating dependencies (use `--install`) ([#18](https://github.com/babel/babel-upgrade/pull/18))\n- [x] Update `package.json`: `dependencies` and `devDependencies` to the \"latest supported\" version.\n  - [x] all package renames\n    - [x] `babel-loader` for webpack \u003e=1 ([#34](https://github.com/babel/babel-upgrade/pull/34))\n    - [x] `rollup-plugin-babel` ([#36](https://github.com/babel/babel-upgrade/pull/36))\n  - [x] Upgrading the same package to the latest version\n  - [x] add `@babel/core` peerDep ([7c34cd](https://github.com/babel/babel-upgrade/commit/7c34cdf318ecbb8a916e7a8ee5c2cfbad7d8d8d0))\n\n```diff\n{\n  \"devDependencies\": {\n+   \"@babel/core\": \"^7.0.0\",\n+   \"@babel/plugin-proposal-object-rest-spread\": \"^7.0.0\",\n+   \"@babel/preset-env\": \"^7.0.0\",\n+   \"babel-loader\": \"v8.0.0-beta.0\"\n-   \"babel-loader\": \"6.0.0\",\n-   \"babel-plugin-transform-object-rest-spread\": \"6.0.0\",\n-   \"babel-preset-env\": \"^1.0.0\",\n  },\n}\n```\n\n- [x] modify scripts for mocha + `@babel/register` ([e81cf7](https://github.com/babel/babel-upgrade/commit/e81cf7c16860d424967a254cd700a88c33d2b56a))\n\n```diff\n{\n  \"name\": \"mocha-scripts-test\",\n  \"scripts\": {\n-    \"test\": \"mocha --compilers js:babel-register --require babel-polyfill test/*Test.js\",\n+    \"test\": \"mocha --compilers js:@babel/register --require @babel/polyfill test/*Test.js\",\n  }\n}\n```\n\n- [x] use `\"babel-core\": \"^7.0.0-bridge-0\"` if jest or jest-cli is a dependency ([#14](https://github.com/babel/babel-upgrade/pull/14))\n\n```diff\n\"devDependencies\": {\n  \"@babel/core\": \"^7.0.0\",\n+ \"babel-core\": \"7.0.0-bridge.0\",\n  \"jest\": \"^22.0.0\"\n},\n\"scripts\": {\n  \"test\": \"jest\"\n}\n```\n\n- [x] add new `@babel/node` package if `babel-node` is used ([#14](https://github.com/babel/babel-upgrade/pull/14))\n\n```diff\n\"devDependencies\": {\n  \"@babel/cli\": \"^7.0.0\",\n+ \"@babel/node\": \"^7.0.0\"\n},\n\"scripts\": {\n  \"start\": \"babel-node a.js\"\n}\n```\n\n\n- [x] Handle all nested `.babelrc` ([#14](https://github.com/babel/babel-upgrade/pull/14))\n\n```txt\n- src/\n- example/\n  - .babelrc // now modifies these too\n- test/\n  - .babelrc // now modifies these too\n- `.babelrc`\n```\n- [x] rename config files to swap shorthand form to long form\n\n```diff\n{\n  \"presets\": [\n+   \"@babel/preset-env\"\n-   \"env\"\n  ]\n}\n```\n\n- [x] `package.json babel key` ([d123ad](https://github.com/babel/babel-upgrade/commit/d123ad72fba25c9118847b36ae950d99c1a152d0))\n\n```diff\n{\n  \"babel\": {\n    \"presets\": [\n+     \"@babel/preset-env\"\n-     \"env\"\n    ]\n  }\n}\n```\n\n- [x] handle `env` ([e9fc42](https://github.com/babel/babel-upgrade/commit/e9fc42203d6c5928d85c12438efa42398d2d6a2a))\n\n```diff\n{\n  \"babel\": {\n    \"presets\": [\n      \"@babel/preset-env\"\n    ]\n  },\n  \"env\": {\n    \"development\": {\n      \"plugins\": [\n-       \"transform-react-jsx-source\",\n-       \"babel-plugin-transform-react-jsx-self\"\n+       \"@babel/plugin-transform-react-jsx-source\",\n+       \"@babel/plugin-transform-react-jsx-self\",\n      ]\n    }\n  }\n}\n\n\n```\n- [x] Modify `mocha.opts` ([e81cf7](https://github.com/babel/babel-upgrade/commit/e81cf7c16860d424967a254cd700a88c33d2b56a))\n\n```diff\n---require babel-register\n+--require @babel/register\n```\n\n- [x] Convert comma separated presets/plugins into an array ([#37](https://github.com/babel/babel-upgrade/pull/37))\n\n```diff\n{\n-  \"presets\": \"env, react\",\n+  \"presets\": [\"@babel/preset-env\", \"@babel/preset-react\"],\n```\n\n- [x] handle react + flow preset being split. Read if `.flowconfig` and add it? ([#21](https://github.com/babel/babel-upgrade/pull/21))\n\n```diff\n{\n  \"@babel/preset-react\": \"^7.0.0\",\n+  \"@babel/preset-flow\": \"^7.0.0\"\n}\n```\n- [x] Replace Stage presets with individual proposal plugins ([#69](https://github.com/babel/babel-upgrade/pull/69))\n\n```diff\n{\n-  \"presets\": [\"@babel/preset-stage-3\"],\n+  \"presets\": [],\n+  \"plugins\": [\n+    \"@babel/plugin-syntax-dynamic-import\",\n+    \"@babel/plugin-syntax-import-meta\",\n+    \"@babel/plugin-proposal-class-properties\",\n+    \"@babel/plugin-proposal-json-strings\"\n+  ]\n}\n```\n\n```diff\n{\n-    \"@babel/preset-stage-3\": \"^7.0.0\"\n+    \"@babel/plugin-proposal-class-properties\": \"^7.0.0\",\n+    \"@babel/plugin-proposal-json-strings\": \"^7.0.0\",\n+    \"@babel/plugin-syntax-dynamic-import\": \"^7.0.0\",\n+    \"@babel/plugin-syntax-import-meta\": \"^7.0.0\"\n}\n```\n\n- [ ] Log when replacing out preset-es2015,16,17,latest as FYI\n- [ ] Figure out how to change nested .babelrcs into using \"overrides\" instead\n- [ ] Monorepo support\n- [ ] `.babelrc.js` and other js files with a config like presets, `webpack.config.js`\n- [ ] convert `only`/`ignore` if necessary\n- [ ] remove `typeof-symbol` if using `@babel/preset-env` + loose\n- [ ] Update test files that use babel directly (`babel-types` -\u003e `@babel/types`, `babel-core`)\n  - [ ] Update all requires/imports\n  - [ ] Update the use of the Babel API (plugins, integrations)\n- [ ] Modify other config files as we go\n- [ ] Add to the upgrade guide which parts are autofixable and the command (if we care enough to make this individually runnable too infrastructure wise)\n- [ ] May need to add a warning on any 3rd party plugins since they might not be compatible\n- [ ] Handle the differences in plugins in v7 for default/loose/spec\n- [ ] 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.\n\n## Philosophy\n\n- Move this into the monorepo when somewhat ready\n  - Maybe move into `@babel/cli`?\n  - Or just another package that is intended to be used via `npx/globally`\n- Whenever there is a breaking change in a PR we should also update this tool when possible or at least provide a warning\n  - What about with a regression?\n- Can be used for non-major bumps too - just for updating to the latest version.\n- Include mini-changelog?\n- Maybe the version should just reflect the version that it targets?\n\n## Development\n```Shell\nnpm install\nnpm start\n```\n","funding_links":["https://github.com/sponsors/babel","https://opencollective.com/babel","https://gitcoin.co/grants/2906/babel-compiler-for-next-generation-javascript"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel%2Fbabel-upgrade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabel%2Fbabel-upgrade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabel%2Fbabel-upgrade/lists"}