Skip to content

Commit

Permalink
deps: update extractErrors Babel plugins to Babel 7
Browse files Browse the repository at this point in the history
- this was using Babel 6's Babylon and babel-traverse, which meant two
  different versions of Babel were being used and a lot of unnecessary
  deps were in the tree
  - now there should no longer be any Babel 6 deps in the tree
  - also transformErrorMessages was already using Babel 7
    (`@babel/helper-module-imports`) while extractErrors was on Babel 6
    just for extra inconsistency 😬
    - these two files seemed to be updated at the same time to Babel 7
      as far as I can tell though 🤨

- `@babel/parser` ships its own typings now, so no need to use the
  `declare module` workaround for it anymore
  - but did have to add a type-cast as its usage doesn't entirely fit
    the type 😕

- this also helps remove an old version of core-js v2, the addition of
  which would give a deprecation warning on install:
  - "npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3."
  • Loading branch information
agilgur5 committed Sep 21, 2020
1 parent 2d0f279 commit 33a6bde
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 90 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@
"dependencies": {
"@babel/core": "^7.4.4",
"@babel/helper-module-imports": "^7.0.0",
"@babel/parser": "^7.11.5",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.11.0",
"@babel/traverse": "^7.11.5",
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-commonjs": "^11.0.0",
"@rollup/plugin-json": "^4.0.0",
Expand All @@ -61,8 +63,6 @@
"babel-plugin-macros": "^2.6.1",
"babel-plugin-polyfill-regenerator": "^0.0.4",
"babel-plugin-transform-rename-import": "^2.3.0",
"babel-traverse": "^6.26.0",
"babylon": "^6.18.0",
"camelcase": "^6.0.0",
"chalk": "^4.0.0",
"enquirer": "^2.3.4",
Expand Down
3 changes: 1 addition & 2 deletions src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ declare module '@babel/core' {

// Rollup plugins
declare module 'rollup-plugin-terser';
declare module 'babel-traverse';
declare module 'babylon';
declare module '@babel/traverse';
declare module '@babel/helper-module-imports';

declare module 'lodash.merge';
12 changes: 6 additions & 6 deletions src/errors/extractErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import * as babylon from 'babylon';
import traverse from 'babel-traverse';
import { parse, ParserOptions } from '@babel/parser';
import traverse from '@babel/traverse';
import { invertObject } from './invertObject';
import { evalToString } from './evalToString';
import { paths } from '../constants';
import { safeVariableName } from '../utils';
import { pascalCase } from 'pascal-case';

const babylonOptions = {
const babelParserOptions: ParserOptions = {
sourceType: 'module',
// As a parser, babylon has its own options and we can't directly
// As a parser, @babel/parser has its own options and we can't directly
// import/require a babel preset. It should be kept **the same** as
// the `babel-plugin-syntax-*` ones specified in
// https://github.com/facebook/fbjs/blob/master/packages/babel-preset-fbjs/configure.js
Expand All @@ -27,7 +27,7 @@ const babylonOptions = {
'trailingFunctionCommas',
'objectRestSpread',
],
};
} as ParserOptions; // workaround for trailingFunctionCommas syntax

export async function extractErrors(opts: any) {
if (!opts || !('errorMapFilePath' in opts)) {
Expand Down Expand Up @@ -65,7 +65,7 @@ export async function extractErrors(opts: any) {
existingErrorMap = invertObject(existingErrorMap);

function transform(source: string) {
const ast = babylon.parse(source, babylonOptions);
const ast = parse(source, babelParserOptions);

traverse(ast, {
CallExpression: {
Expand Down
81 changes: 1 addition & 80 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1808,15 +1808,6 @@ axobject-query@^2.0.2:
"@babel/runtime" "^7.7.4"
"@babel/runtime-corejs3" "^7.7.4"

babel-code-frame@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"
integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=
dependencies:
chalk "^1.1.3"
esutils "^2.0.2"
js-tokens "^3.0.2"

babel-eslint@^10.0.3:
version "10.0.3"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.3.tgz#81a2c669be0f205e19462fed2482d33e4687a88a"
Expand All @@ -1842,13 +1833,6 @@ babel-jest@^25.3.0:
chalk "^3.0.0"
slash "^3.0.0"

babel-messages@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e"
integrity sha1-8830cDhYA1sqKVHG7F7fbGLyYw4=
dependencies:
babel-runtime "^6.22.0"

babel-plugin-annotate-pure-calls@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/babel-plugin-annotate-pure-calls/-/babel-plugin-annotate-pure-calls-0.4.0.tgz#78aa00fd878c4fcde4d49f3da397fcf5defbcce8"
Expand Down Expand Up @@ -1949,44 +1933,6 @@ babel-preset-jest@^25.3.0:
babel-plugin-jest-hoist "^25.2.6"
babel-preset-current-node-syntax "^0.1.2"

babel-runtime@^6.22.0, babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4=
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.11.0"

babel-traverse@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee"
integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4=
dependencies:
babel-code-frame "^6.26.0"
babel-messages "^6.23.0"
babel-runtime "^6.26.0"
babel-types "^6.26.0"
babylon "^6.18.0"
debug "^2.6.8"
globals "^9.18.0"
invariant "^2.2.2"
lodash "^4.17.4"

babel-types@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497"
integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc=
dependencies:
babel-runtime "^6.26.0"
esutils "^2.0.2"
lodash "^4.17.4"
to-fast-properties "^1.0.3"

babylon@^6.18.0:
version "6.18.0"
resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3"
integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ==

bail@^1.0.0:
version "1.0.4"
resolved "https://registry.yarnpkg.com/bail/-/bail-1.0.4.tgz#7181b66d508aa3055d3f6c13f0a0c720641dde9b"
Expand Down Expand Up @@ -2559,11 +2505,6 @@ core-js-pure@^3.0.0:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.4.7.tgz#c998e1892da9949200c7452cbd33c0df95be9f54"
integrity sha512-Am3uRS8WCdTFA3lP7LtKR0PxgqYzjAMGKXaZKSNSC/8sqU0Wfq8R/YzoRs2rqtOVEunfgH+0q3O0BKOg0AvjPw==

core-js@^2.4.0:
version "2.6.10"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.10.tgz#8a5b8391f8cc7013da703411ce5b585706300d7f"
integrity sha512-I39t74+4t+zau64EN1fE5v2W31Adtc/REhzWN+gWRRXg6WH5qAsZm62DHpQ1+Yhe4047T55jvzz7MUqF/dBBlA==

core-util-is@1.0.2, core-util-is@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
Expand Down Expand Up @@ -3818,11 +3759,6 @@ globals@^12.1.0:
dependencies:
type-fest "^0.8.1"

globals@^9.18.0:
version "9.18.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"
integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ==

globalyzer@^0.1.0:
version "0.1.4"
resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f"
Expand Down Expand Up @@ -5056,11 +4992,6 @@ jpjs@^1.2.1:
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499"
integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==

js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls=

js-yaml@^3.13.1:
version "3.13.1"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.13.1.tgz#aff151b30bfdfa8e49e05da22e7415e9dfa37847"
Expand Down Expand Up @@ -5402,7 +5333,7 @@ lodash.zip@^4.2.0:
resolved "https://registry.yarnpkg.com/lodash.zip/-/lodash.zip-4.2.0.tgz#ec6662e4896408ed4ab6c542a3990b72cc080020"
integrity sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=

lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.4:
lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.19:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
Expand Down Expand Up @@ -6967,11 +6898,6 @@ regenerate@^1.4.0:
resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.4.0.tgz#4a856ec4b56e4077c557589cae85e7a4c8869a11"
integrity sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==

regenerator-runtime@^0.11.0:
version "0.11.1"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9"
integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==

regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.4, regenerator-runtime@^0.13.7:
version "0.13.7"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
Expand Down Expand Up @@ -8033,11 +7959,6 @@ tmpl@1.0.x:
resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"
integrity sha1-I2QN17QtAEM5ERQIIOXPRA5SHdE=

to-fast-properties@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47"
integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc=

to-fast-properties@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e"
Expand Down

0 comments on commit 33a6bde

Please sign in to comment.