From 9ec38d59d780770a6512e99c478cc83d85cb1364 Mon Sep 17 00:00:00 2001 From: Joe Farro Date: Mon, 7 Jan 2019 11:15:31 -0500 Subject: [PATCH] Upgrade react-app-rewired to 2.0.1 Avoid issue https://github.com/yarnpkg/yarn/issues/6300 Signed-off-by: Joe Farro --- package.json | 5 +-- packages/jaeger-ui/config-overrides.js | 36 ++++++---------------- packages/jaeger-ui/jest-babel-transform.js | 23 -------------- packages/jaeger-ui/package.json | 3 +- yarn.lock | 28 +++++++++++------ 5 files changed, 34 insertions(+), 61 deletions(-) delete mode 100644 packages/jaeger-ui/jest-babel-transform.js diff --git a/package.json b/package.json index e1c92f1404..6373ed4a97 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,11 @@ "flow": "glow", "lint": "yarn run prettier-lint && yarn run eslint && yarn run flow && yarn run check-license", "prepare": "lerna run --stream --sort prepublishOnly", + "prettier-comment": "https://github.com/yarnpkg/yarn/issues/6300", "prettier": - "prettier --write '{.,scripts}/*.{js,json,md}' 'packages/*/{src,demo/src}/**/!(react-vis).{css,js,json,md}' 'packages/*/*.{css,js,json,md}'", + "./node_modules/prettier/bin-prettier.js --write '{.,scripts}/*.{js,json,md}' 'packages/*/{src,demo/src}/**/!(react-vis).{css,js,json,md}' 'packages/*/*.{css,js,json,md}'", "prettier-lint": - "prettier --list-different '{.,scripts}/*.{js,json,md}' 'packages/*/{src,demo/src}/**/!(react-vis).{css,js,json,md}' 'packages/*/*.{css,js,json,md}'", + "./node_modules/prettier/bin-prettier.js --list-different '{.,scripts}/*.{js,json,md}' 'packages/*/{src,demo/src}/**/!(react-vis).{css,js,json,md}' 'packages/*/*.{css,js,json,md}'", "test": "lerna run test", "start": "cd packages/jaeger-ui && yarn start" }, diff --git a/packages/jaeger-ui/config-overrides.js b/packages/jaeger-ui/config-overrides.js index 50cf514573..150b60aa95 100644 --- a/packages/jaeger-ui/config-overrides.js +++ b/packages/jaeger-ui/config-overrides.js @@ -14,14 +14,9 @@ /* eslint-disable import/no-extraneous-dependencies */ const fs = require('fs'); -const { injectBabelPlugin } = require('react-app-rewired'); -const rewireLess = require('react-app-rewire-less'); +const { addBabelPlugin, addLessLoader } = require('customize-cra'); const lessToJs = require('less-vars-to-js'); -// Convert less vars to JS -const loadedVarOverrides = fs.readFileSync('config-overrides-antd-vars.less', 'utf8'); -const modifyVars = lessToJs(loadedVarOverrides); - function useEslintRc(config) { const { rules } = config.module; const preRule = rules.find(rule => rule.enforce === 'pre'); @@ -40,30 +35,19 @@ function useEslintRc(config) { return config; } -function webpack(_config, env) { +// Convert less vars to JS +const loadedVarOverrides = fs.readFileSync('config-overrides-antd-vars.less', 'utf8'); +const modifyVars = lessToJs(loadedVarOverrides); + +function webpack(_config) { let config = _config; - config = rewireLess.withLoaderOptions({ + config = addLessLoader({ modifyVars, javascriptEnabled: true, - })(config, env); - config = injectBabelPlugin( - ['import', { libraryName: 'antd', style: true, libraryDirectory: 'lib' }], - config - ); + })(config); + config = addBabelPlugin(['import', { libraryName: 'antd', style: true, libraryDirectory: 'lib' }])(config); useEslintRc(config); return config; } -// Don't use react-app-rewired/scripts/utils/babelTransform.js for the jest -// transform - it has an issue with automatically loading decorators. -function jest(config) { - const _config = config; - Object.keys(_config.transform).forEach(key => { - if (_config.transform[key].endsWith('babelTransform.js')) { - _config.transform[key] = require.resolve('./jest-babel-transform.js'); - } - }); - return config; -} - -module.exports = { jest, webpack }; +module.exports = { webpack }; diff --git a/packages/jaeger-ui/jest-babel-transform.js b/packages/jaeger-ui/jest-babel-transform.js deleted file mode 100644 index 4af1128597..0000000000 --- a/packages/jaeger-ui/jest-babel-transform.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2019 Uber Technologies, Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// eslint-disable-next-line import/no-extraneous-dependencies -const babelJest = require('babel-jest'); - -// Derived from react-app-rewired/scripts/utils/babelTransform.js -module.exports = babelJest.createTransformer({ - presets: [require.resolve('babel-preset-react-app')], - plugins: [], - babelrc: true, -}); diff --git a/packages/jaeger-ui/package.json b/packages/jaeger-ui/package.json index 1efa6d4430..bc3380c040 100644 --- a/packages/jaeger-ui/package.json +++ b/packages/jaeger-ui/package.json @@ -8,13 +8,14 @@ "devDependencies": { "babel-plugin-import": "1.11.0", "bluebird": "^3.5.0", + "customize-cra": "0.2.9", "enzyme": "^3.2.0", "enzyme-adapter-react-16": "^1.1.0", "enzyme-to-json": "^3.3.0", "http-proxy-middleware": "^0.19.1", "less-vars-to-js": "^1.2.1", "react-app-rewire-less": "2.1.3", - "react-app-rewired": "2.0.2-next.0", + "react-app-rewired": "2.0.1", "react-scripts": "2.1.2", "react-test-renderer": "^15.6.1", "sinon": "^3.2.1", diff --git a/yarn.lock b/yarn.lock index bd5db6e7c8..a8aedd3604 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4312,6 +4312,12 @@ custom-event@~1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" +customize-cra@0.2.9: + version "0.2.9" + resolved "https://registry.yarnpkg.com/customize-cra/-/customize-cra-0.2.9.tgz#9a6694c1d8671b548369e273945d6831816e5a78" + dependencies: + lodash.flow "^3.5.0" + cyclist@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-0.2.2.tgz#1b33792e11e914a2fd6d6ed6447464444e5fa640" @@ -4965,14 +4971,14 @@ dotenv@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.0.0.tgz#24e37c041741c5f4b25324958ebbc34bca965935" -dotenv@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d" - dotenv@^5.0.1: version "5.0.1" resolved "http://registry.npmjs.org/dotenv/-/dotenv-5.0.1.tgz#a5317459bd3d79ab88cff6e44057a6a3fbb1fcef" +dotenv@^6.2.0: + version "6.2.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064" + double-ended-queue@^2.1.0-0: version "2.1.0-0" resolved "https://registry.yarnpkg.com/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz#103d3527fd31528f40188130c841efdd78264e5c" @@ -9054,6 +9060,10 @@ lodash.flattendeep@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2" +lodash.flow@^3.5.0: + version "3.5.0" + resolved "https://registry.yarnpkg.com/lodash.flow/-/lodash.flow-3.5.0.tgz#87bf40292b8cf83e4e8ce1a3ae4209e20071675a" + lodash.isarguments@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" @@ -12503,12 +12513,12 @@ react-app-rewire-less@2.1.3: less-loader "^4.1.0" npm "^6.4.1" -react-app-rewired@2.0.2-next.0: - version "2.0.2-next.0" - resolved "https://registry.yarnpkg.com/react-app-rewired/-/react-app-rewired-2.0.2-next.0.tgz#111711df73742a703f1f9dccc14f4cd263440a6d" +react-app-rewired@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/react-app-rewired/-/react-app-rewired-2.0.1.tgz#5c4902e68e78aa8851ef84a03579418b6f891e0b" dependencies: - cross-spawn "^5.1.0" - dotenv "^4.0.0" + cross-spawn "^6.0.5" + dotenv "^6.2.0" semver "^5.6.0" react-copy-to-clipboard@^5.0.1: