Scripts: Add missing fallback for target in webpack 5 config - #34112
Merged
Conversation
gziolo
commented
Aug 17, 2021
| const isProduction = process.env.NODE_ENV === 'production'; | ||
| const mode = isProduction ? 'production' : 'development'; | ||
| let target = 'browserslist'; | ||
| if ( ! browserslist.findConfig( '.' ) ) { |
Member
Author
There was a problem hiding this comment.
We use the same trick in @wordpress/babel-config-default:
gutenberg/packages/babel-preset-default/index.js
Lines 34 to 40 in 76fe632
|
Size Change: 0 B Total Size: 1.03 MB ℹ️ View Unchanged
|
10 tasks
Contributor
|
Looks good to me. Fallback is And with |
Member
Author
Yes, this is exactly how it should work. It always prefers a file provided by the project. |
samikeijonen
approved these changes
Aug 18, 2021
Member
Author
|
This PR was cherry-picked to the Gutenberg 11.3 release. |
gziolo
added a commit
that referenced
this pull request
Aug 18, 2021
* Scripts: Add missing fallback for target in webpack 5 config * Add changelog entry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Follow up for #33818.
Fixes the following error when using
@wordpress/scriptswithout 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 buildTypes of changes
Bug fix (non-breaking change which fixes an issue).
Checklist:
*.native.jsfiles for terms that need renaming or removal).