From b7cd3a7e4abc9ced826e8d07e9bb3c6fa2fe5a08 Mon Sep 17 00:00:00 2001 From: renrizzolo Date: Fri, 4 Feb 2022 12:17:23 +1100 Subject: [PATCH] fix: tree shaking & regeneratorRuntime --- babel.config.js | 14 +++++- config/webpack.config.dev.js | 1 + config/webpack.config.prod.js | 1 + package-lock.json | 90 +++++++++++++++++++++++++++++++++++ package.json | 5 ++ 5 files changed, 109 insertions(+), 2 deletions(-) diff --git a/babel.config.js b/babel.config.js index c5a53b46b..ee66002f6 100644 --- a/babel.config.js +++ b/babel.config.js @@ -35,11 +35,21 @@ const env = { }, esm: { presets: [['@babel/preset-env', { useBuiltIns: false, modules: false }]], - plugins: ['jsx-remove-data-test-id', inlineSvgPlugin, ['transform-remove-imports', { test: '\\.(scss|css)$' }]], + plugins: [ + ['@babel/plugin-transform-runtime', { regenerator: true }], + 'jsx-remove-data-test-id', + inlineSvgPlugin, + ['transform-remove-imports', { test: '\\.(scss|css)$' }], + ], }, cjs: { presets: [['@babel/preset-env', { useBuiltIns: false, modules: 'cjs' }]], - plugins: ['jsx-remove-data-test-id', inlineSvgPlugin, ['transform-remove-imports', { test: '\\.(scss|css)$' }]], + plugins: [ + ['@babel/plugin-transform-runtime', { regenerator: true }], + 'jsx-remove-data-test-id', + inlineSvgPlugin, + ['transform-remove-imports', { test: '\\.(scss|css)$' }], + ], }, }; diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index a1fbf473f..9e02cd38f 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -69,6 +69,7 @@ module.exports = webpackMerge(commonConfig, { }, { test: /\.((c|sc)ss)$/i, + sideEffects: true, use: [ 'style-loader', { diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index 3510f7b87..d85629183 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -89,6 +89,7 @@ module.exports = webpackMerge(commonConfig, { }, { test: /\.((c|sc)ss)$/i, + sideEffects: true, use: [ MiniCssExtractPlugin.loader, { diff --git a/package-lock.json b/package-lock.json index 033764771..2d6eb4e95 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "devDependencies": { "@babel/cli": "^7.17.0", "@babel/core": "^7.17.0", + "@babel/plugin-transform-runtime": "^7.17.0", "@babel/preset-env": "^7.16.11", "@babel/preset-react": "^7.16.7", "@commitlint/cli": "^16.1.0", @@ -2185,6 +2186,57 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/plugin-transform-runtime": { + "version": "7.17.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.17.0.tgz", + "integrity": "sha512-fr7zPWnKXNc1xoHfrIU9mN/4XKX4VLZ45Q+oMhfsYIaHvg7mHgmhfOy/ckRWqDK7XF3QDigRpkh5DKq6+clE8A==", + "dev": true, + "dependencies": { + "@babel/helper-module-imports": "^7.16.7", + "@babel/helper-plugin-utils": "^7.16.7", + "babel-plugin-polyfill-corejs2": "^0.3.0", + "babel-plugin-polyfill-corejs3": "^0.5.0", + "babel-plugin-polyfill-regenerator": "^0.3.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-runtime/node_modules/@babel/helper-plugin-utils": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz", + "integrity": "sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/plugin-transform-runtime/node_modules/babel-plugin-polyfill-corejs3": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", + "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", + "dev": true, + "dependencies": { + "@babel/helper-define-polyfill-provider": "^0.3.1", + "core-js-compat": "^3.21.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-runtime/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/@babel/plugin-transform-shorthand-properties": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz", @@ -25146,6 +25198,44 @@ } } }, + "@babel/plugin-transform-runtime": { + "version": "7.17.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-runtime/-/plugin-transform-runtime-7.17.0.tgz", + "integrity": "sha512-fr7zPWnKXNc1xoHfrIU9mN/4XKX4VLZ45Q+oMhfsYIaHvg7mHgmhfOy/ckRWqDK7XF3QDigRpkh5DKq6+clE8A==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.16.7", + "@babel/helper-plugin-utils": "^7.16.7", + "babel-plugin-polyfill-corejs2": "^0.3.0", + "babel-plugin-polyfill-corejs3": "^0.5.0", + "babel-plugin-polyfill-regenerator": "^0.3.0", + "semver": "^6.3.0" + }, + "dependencies": { + "@babel/helper-plugin-utils": { + "version": "7.16.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz", + "integrity": "sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA==", + "dev": true + }, + "babel-plugin-polyfill-corejs3": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.2.tgz", + "integrity": "sha512-G3uJih0XWiID451fpeFaYGVuxHEjzKTHtc9uGFEjR6hHrvNzeS/PX+LLLcetJcytsB5m4j+K3o/EpXJNb/5IEQ==", + "dev": true, + "requires": { + "@babel/helper-define-polyfill-provider": "^0.3.1", + "core-js-compat": "^3.21.0" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "@babel/plugin-transform-shorthand-properties": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.16.7.tgz", diff --git a/package.json b/package.json index 0e9c2fc66..510014ec9 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,10 @@ "lib", "es" ], + "sideEffects": [ + "./src/**/*.scss", + "./dist/*.css" + ], "license": "MIT", "scripts": { "generate-docs": "node ./scripts/generateDocs.js", @@ -71,6 +75,7 @@ "@babel/cli": "^7.17.0", "@babel/core": "^7.17.0", "@babel/preset-env": "^7.16.11", + "@babel/plugin-transform-runtime": "^7.17.0", "@babel/preset-react": "^7.16.7", "@commitlint/cli": "^16.1.0", "@commitlint/config-conventional": "^16.0.0",