-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scripts: Add missing fallback for target in webpack 5 config #34112
Conversation
hasBabelConfig, | ||
hasCssnanoConfig, | ||
hasPostCSSConfig, | ||
} = require( '../utils' ); | ||
|
||
const isProduction = process.env.NODE_ENV === 'production'; | ||
const mode = isProduction ? 'production' : 'development'; | ||
let target = 'browserslist'; | ||
if ( ! browserslist.findConfig( '.' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the same trick in @wordpress/babel-config-default
:
gutenberg/packages/babel-preset-default/index.js
Lines 34 to 40 in 76fe632
const localBrowserslistConfig = | |
browserslist.findConfig( '.' ) || {}; | |
opts.targets = { | |
browsers: | |
localBrowserslistConfig.defaults || | |
require( '@wordpress/browserslist-config' ), | |
}; |
Size Change: 0 B Total Size: 1.03 MB ℹ️ View Unchanged
|
Looks good to me. Fallback is And with |
Yes, this is exactly how it should work. It always prefers a file provided by the project. |
This PR was cherry-picked to the Gutenberg 11.3 release. |
* Scripts: Add missing fallback for target in webpack 5 config * Add changelog entry
Description
Follow up for #33818.
Fixes the following error when using
@wordpress/scripts
without the browserslist config provided:It adds a fallback when that happens.
Related webpack 5 docs:
https://webpack.js.org/configuration/target/#target
How has this been tested?
npx wp-create-block example --no-wp-scripts rm .browserslistconfig cd example ./node_modules/.bin/wp-scripts build
Types of changes
Bug fix (non-breaking change which fixes an issue).
Checklist:
*.native.js
files for terms that need renaming or removal).