From e01da7d54b1d01ad943ff26d7502f73b66b2b242 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 17 Aug 2021 14:55:44 +0200 Subject: [PATCH 1/2] Scripts: Add missing fallback for target in webpack 5 config --- package-lock.json | 2 ++ packages/scripts/config/.browserslistrc | 1 + packages/scripts/config/webpack.config.js | 8 +++++++- packages/scripts/package.json | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 packages/scripts/config/.browserslistrc diff --git a/package-lock.json b/package-lock.json index 0e4bda96706c2a..d28e3313afec57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19001,6 +19001,7 @@ "requires": { "@svgr/webpack": "^5.5.0", "@wordpress/babel-preset-default": "file:packages/babel-preset-default", + "@wordpress/browserslist-config": "file:packages/browserslist-config", "@wordpress/dependency-extraction-webpack-plugin": "file:packages/dependency-extraction-webpack-plugin", "@wordpress/eslint-plugin": "file:packages/eslint-plugin", "@wordpress/jest-preset-default": "file:packages/jest-preset-default", @@ -19010,6 +19011,7 @@ "@wordpress/stylelint-config": "file:packages/stylelint-config", "babel-jest": "^26.6.3", "babel-loader": "^8.2.2", + "browserslist": "^4.16.6", "chalk": "^4.0.0", "check-node-version": "^4.1.0", "clean-webpack-plugin": "^3.0.0", diff --git a/packages/scripts/config/.browserslistrc b/packages/scripts/config/.browserslistrc new file mode 100644 index 00000000000000..0152f61ef03df1 --- /dev/null +++ b/packages/scripts/config/.browserslistrc @@ -0,0 +1 @@ +extends @wordpress/browserslist-config diff --git a/packages/scripts/config/webpack.config.js b/packages/scripts/config/webpack.config.js index 9ef08203f876c9..86ed99807d8815 100644 --- a/packages/scripts/config/webpack.config.js +++ b/packages/scripts/config/webpack.config.js @@ -6,6 +6,7 @@ const LiveReloadPlugin = require( 'webpack-livereload-plugin' ); const MiniCSSExtractPlugin = require( 'mini-css-extract-plugin' ); const TerserPlugin = require( 'terser-webpack-plugin' ); const { CleanWebpackPlugin } = require( 'clean-webpack-plugin' ); +const browserslist = require( 'browserslist' ); const path = require( 'path' ); /** @@ -18,6 +19,7 @@ const postcssPlugins = require( '@wordpress/postcss-plugins-preset' ); * Internal dependencies */ const { + fromConfigRoot, hasBabelConfig, hasCssnanoConfig, hasPostCSSConfig, @@ -25,6 +27,10 @@ const { const isProduction = process.env.NODE_ENV === 'production'; const mode = isProduction ? 'production' : 'development'; +let target = 'browserslist'; +if ( ! browserslist.findConfig( '.' ) ) { + target += ':' + fromConfigRoot( '.browserslistrc' ); +} const cssLoaders = [ { @@ -81,7 +87,7 @@ const getLiveReloadPort = ( inputPort ) => { const config = { mode, - target: 'browserslist', + target, entry: { index: path.resolve( process.cwd(), 'src', 'index.js' ), }, diff --git a/packages/scripts/package.json b/packages/scripts/package.json index 8c59a007bceace..561816a693aa9c 100644 --- a/packages/scripts/package.json +++ b/packages/scripts/package.json @@ -34,6 +34,7 @@ "dependencies": { "@svgr/webpack": "^5.5.0", "@wordpress/babel-preset-default": "file:../babel-preset-default", + "@wordpress/browserslist-config": "file:../browserslist-config", "@wordpress/dependency-extraction-webpack-plugin": "file:../dependency-extraction-webpack-plugin", "@wordpress/eslint-plugin": "file:../eslint-plugin", "@wordpress/jest-preset-default": "file:../jest-preset-default", @@ -43,6 +44,7 @@ "@wordpress/stylelint-config": "file:../stylelint-config", "babel-jest": "^26.6.3", "babel-loader": "^8.2.2", + "browserslist": "^4.16.6", "chalk": "^4.0.0", "check-node-version": "^4.1.0", "clean-webpack-plugin": "^3.0.0", From 235c4f5a5fb5e725196ec8d08e54507d46bd8682 Mon Sep 17 00:00:00 2001 From: Grzegorz Ziolkowski Date: Tue, 17 Aug 2021 15:07:36 +0200 Subject: [PATCH 2/2] Add changelog entry --- packages/scripts/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/scripts/CHANGELOG.md b/packages/scripts/CHANGELOG.md index 25a5d8fc5acc9e..72acb296712ac7 100644 --- a/packages/scripts/CHANGELOG.md +++ b/packages/scripts/CHANGELOG.md @@ -24,6 +24,10 @@ - The bundled `@svgr/webpack` dependency has been updated from requiring `^5.2.0` to requiring `^5.5.0` ([#33818](https://github.com/WordPress/gutenberg/pull/33818)). - The bundled `webpack-bundle-analyzer` dependency has been updated from requiring `^4.2.0` to requiring `^4.4.2` ([#33818](https://github.com/WordPress/gutenberg/pull/33818)). +### Bug Fixes + +- Add missing fallback for target in webpack 5 config ([#34112](https://github.com/WordPress/gutenberg/pull/34112)), + ## 17.1.0 (2021-07-29) ### Enhancements