From 69890535c94850fe64fb14b8622e7c5d30ab645c Mon Sep 17 00:00:00 2001 From: Darren Ethier Date: Tue, 13 Aug 2019 09:51:44 -0400 Subject: [PATCH] Add babel-plugin-transform-remove-prop-types Babel plugin (https://github.com/woocommerce/woocommerce-blocks/pull/839) * install transform-react-remove-prop-types babel plugin * use `@wordpress/babel-preset-default` not `@wordpress/default` (name change) * add configuration for new plugin (removing prop-types on production builds) --- plugins/woocommerce-blocks/package-lock.json | 6 ++++++ plugins/woocommerce-blocks/package.json | 1 + plugins/woocommerce-blocks/webpack.config.js | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-blocks/package-lock.json b/plugins/woocommerce-blocks/package-lock.json index 117cd78c639..671482b9615 100644 --- a/plugins/woocommerce-blocks/package-lock.json +++ b/plugins/woocommerce-blocks/package-lock.json @@ -6473,6 +6473,12 @@ "babel-runtime": "^6.22.0" } }, + "babel-plugin-transform-react-remove-prop-types": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz", + "integrity": "sha512-eqj0hVcJUR57/Ug2zE1Yswsw4LhuqqHhD+8v120T1cl3kjg76QwtyBrdIk4WVwK+lAhBJVYCd/v+4nc4y+8JsA==", + "dev": true + }, "babel-plugin-transform-regenerator": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-plugin-transform-regenerator/-/babel-plugin-transform-regenerator-6.26.0.tgz", diff --git a/plugins/woocommerce-blocks/package.json b/plugins/woocommerce-blocks/package.json index fd05d269c46..ed1439d1fc3 100644 --- a/plugins/woocommerce-blocks/package.json +++ b/plugins/woocommerce-blocks/package.json @@ -56,6 +56,7 @@ "babel-plugin-transform-async-generator-functions": "6.24.1", "babel-plugin-transform-object-rest-spread": "6.26.0", "babel-plugin-transform-react-jsx": "6.24.1", + "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "babel-plugin-transform-runtime": "6.23.0", "babel-preset-env": "1.7.0", "bundlesize": "0.18.0", diff --git a/plugins/woocommerce-blocks/webpack.config.js b/plugins/woocommerce-blocks/webpack.config.js index a638d741461..8b052d18953 100644 --- a/plugins/woocommerce-blocks/webpack.config.js +++ b/plugins/woocommerce-blocks/webpack.config.js @@ -105,7 +105,10 @@ const GutenbergBlocksConfig = { use: { loader: 'babel-loader?cacheDirectory', options: { - presets: [ '@wordpress/default' ], + presets: [ '@wordpress/babel-preset-default' ], + plugins: [ + NODE_ENV === 'production' ? require.resolve( 'babel-plugin-transform-react-remove-prop-types' ) : false, + ].filter( Boolean ), }, }, }, @@ -174,6 +177,7 @@ const BlocksFrontendConfig = { require.resolve( '@babel/plugin-transform-react-jsx' ), require.resolve( '@babel/plugin-proposal-async-generator-functions' ), require.resolve( '@babel/plugin-transform-runtime' ), + NODE_ENV === 'production' ? require.resolve( 'babel-plugin-transform-react-remove-prop-types' ) : false, ].filter( Boolean ), }, },