From 25a908164c14b2ecdccff95139e8fd7a3c1ef3d5 Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Tue, 16 Jan 2018 13:09:42 -0700 Subject: [PATCH 1/3] Remove PropTypes from production build (#209) --- packages/babel-preset-react-app/index.js | 7 +++++++ packages/babel-preset-react-app/package.json | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 2bdd83b0fc4..28b3df84593 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -101,6 +101,13 @@ module.exports = function(api, opts) { regenerator: true, }, ], + isEnvProduction && [ + // Remove PropTypes from production build + require('babel-plugin-transform-react-remove-prop-types').default, + { + removeImport: true, + }, + ], // function* () { yield 42; yield 43; } !isEnvTest && [ require('@babel/plugin-transform-regenerator').default, diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 0a13c707176..296b83b8d3d 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -26,6 +26,7 @@ "@babel/preset-flow": "7.0.0-beta.37", "@babel/preset-react": "7.0.0-beta.37", "babel-plugin-macros": "2.0.0", - "babel-plugin-transform-dynamic-import": "2.0.0" + "babel-plugin-transform-dynamic-import": "2.0.0", + "babel-plugin-transform-react-remove-prop-types": "0.4.12" } } From 3734b1dfb21aa8b7e4ea327c74480c3eb2da96a4 Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Wed, 17 Jan 2018 07:51:08 -0700 Subject: [PATCH 2/3] Added react/forbid-foreign-prop-types rule to eslint config --- packages/eslint-config-react-app/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index f029f9626bf..ba810e4e994 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -187,6 +187,7 @@ module.exports = { 'import/no-webpack-loader-syntax': 'error', // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules + 'react/forbid-foreign-prop-types': 'warn', 'react/jsx-no-comment-textnodes': 'warn', 'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }], 'react/jsx-no-target-blank': 'warn', From 1bd148a80fb07acb7b9f29595e7b07ba8d181857 Mon Sep 17 00:00:00 2001 From: Ian Sutherland Date: Wed, 17 Jan 2018 10:15:27 -0700 Subject: [PATCH 3/3] Removed react/forbid-foreign-prop-types rule from eslint config --- packages/eslint-config-react-app/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index ba810e4e994..f029f9626bf 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -187,7 +187,6 @@ module.exports = { 'import/no-webpack-loader-syntax': 'error', // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules - 'react/forbid-foreign-prop-types': 'warn', 'react/jsx-no-comment-textnodes': 'warn', 'react/jsx-no-duplicate-props': ['warn', { ignoreCase: true }], 'react/jsx-no-target-blank': 'warn',