From a0791ff48f84cdedb9d27c05ad5941d62d54edbd Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 19 Apr 2023 16:30:41 +0100 Subject: [PATCH] Strip data-testid in production builds (#25152) --- babel.config.js | 12 ++++++++++++ package.json | 1 + webpack.config.js | 4 ++++ yarn.lock | 5 +++++ 4 files changed, 22 insertions(+) diff --git a/babel.config.js b/babel.config.js index da3942c6da..85f818aff9 100644 --- a/babel.config.js +++ b/babel.config.js @@ -32,4 +32,16 @@ module.exports = { "@babel/plugin-syntax-dynamic-import", "@babel/plugin-transform-runtime", ], + env: { + production: { + plugins: [ + [ + "babel-plugin-jsx-remove-data-test-id", + { + attributes: "data-testid", + }, + ], + ], + }, + }, }; diff --git a/package.json b/package.json index 6a4fcfbb25..22c5a9c764 100644 --- a/package.json +++ b/package.json @@ -116,6 +116,7 @@ "allchange": "^1.0.6", "babel-jest": "^29.0.0", "babel-loader": "^8.2.2", + "babel-plugin-jsx-remove-data-test-id": "^3.0.0", "chokidar": "^3.5.1", "concurrently": "^8.0.0", "cpx": "^1.5.0", diff --git a/webpack.config.js b/webpack.config.js index 28d60af8a7..0d17107401 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -269,6 +269,7 @@ module.exports = (env, argv) => { }, loader: "babel-loader", options: { + envName: nodeEnv, cacheDirectory: true, }, }, @@ -434,6 +435,9 @@ module.exports = (env, argv) => { { // TS -> JS because the worklet-loader won't do this for us. loader: "babel-loader", + options: { + envName: nodeEnv, + }, }, ], }, diff --git a/yarn.lock b/yarn.lock index 88c7672d06..d84e5d028e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3005,6 +3005,11 @@ babel-plugin-jest-hoist@^29.5.0: "@types/babel__core" "^7.1.14" "@types/babel__traverse" "^7.0.6" +babel-plugin-jsx-remove-data-test-id@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jsx-remove-data-test-id/-/babel-plugin-jsx-remove-data-test-id-3.0.0.tgz#15c95f97ce0ff60d72b29e403bde245f86393288" + integrity sha512-E4uM/LIUizjy2Z5tVAfa8pSXsYgoKWJ97kzuEMfsIxSLSNDWsAhgFVPkgNuakViX5dkNjw1DKIi0VpWP6djqbw== + babel-plugin-polyfill-corejs2@^0.3.3: version "0.3.3" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.3.3.tgz#5d1bd3836d0a19e1b84bbf2d9640ccb6f951c122"