Skip to content

Commit 231b226

Browse files
authored
build(plugins): Add a browserslist environment for wpcom plugins (#51178)
* Fix webpack 5 * Add browserslist env wpcom * Don't set any default browserslist
1 parent 11ba38e commit 231b226

File tree

10 files changed

+33
-29
lines changed

10 files changed

+33
-29
lines changed

apps/editing-toolkit/package.json

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,57 +16,57 @@
1616
},
1717
"homepage": "https://github.com/Automattic/wp-calypso",
1818
"scripts": {
19-
"dotcom-fse": "calypso-build --env source='dotcom-fse'",
19+
"dotcom-fse": "BROWSERSLIST_ENV=wpcom calypso-build --env source='dotcom-fse'",
2020
"dev:dotcom-fse": "yarn run dotcom-fse",
2121
"build:dotcom-fse": "NODE_ENV=production yarn run dotcom-fse",
22-
"posts-list-block": "calypso-build --env source='posts-list-block'",
22+
"posts-list-block": "BROWSERSLIST_ENV=wpcom calypso-build --env source='posts-list-block'",
2323
"dev:posts-list-block": "yarn run posts-list-block",
2424
"build:posts-list-block": "NODE_ENV=production yarn run posts-list-block",
25-
"common": "calypso-build --env source='common','common/data-stores','common/hide-plugin-buttons-mobile'",
25+
"common": "BROWSERSLIST_ENV=wpcom calypso-build --env source='common','common/data-stores','common/hide-plugin-buttons-mobile'",
2626
"dev:common": "yarn run common",
2727
"build:common": "NODE_ENV=production yarn run common",
2828
"editor-site-launch": "npm-run-all --parallel editor-site-launch-*",
29-
"editor-site-launch-button": "calypso-build --env source='editor-site-launch/launch-button'",
30-
"editor-site-launch-gutenboarding": "calypso-build --env source='editor-site-launch/gutenboarding-launch'",
31-
"editor-site-launch-focused": "calypso-build --env source='editor-site-launch/focused-launch'",
29+
"editor-site-launch-button": "BROWSERSLIST_ENV=wpcom calypso-build --env source='editor-site-launch/launch-button'",
30+
"editor-site-launch-gutenboarding": "BROWSERSLIST_ENV=wpcom calypso-build --env source='editor-site-launch/gutenboarding-launch'",
31+
"editor-site-launch-focused": "BROWSERSLIST_ENV=wpcom calypso-build --env source='editor-site-launch/focused-launch'",
3232
"dev:editor-site-launch": "yarn run editor-site-launch",
3333
"build:editor-site-launch": "NODE_ENV=production yarn run editor-site-launch",
3434
"newspack-blocks": "npm run sync:newspack-blocks -- --nodemodules && npm-run-all --parallel newspack-blocks-*",
35-
"newspack-blog-posts-block-editor": "calypso-build --env source='newspack-blocks/blog-posts-block-editor'",
36-
"newspack-blog-posts-block-view": "calypso-build --env source='newspack-blocks/blog-posts-block-view'",
35+
"newspack-blog-posts-block-editor": "BROWSERSLIST_ENV=wpcom calypso-build --env source='newspack-blocks/blog-posts-block-editor'",
36+
"newspack-blog-posts-block-view": "BROWSERSLIST_ENV=wpcom calypso-build --env source='newspack-blocks/blog-posts-block-view'",
3737
"newspack-blocks-blog-posts-block": "npm-run-all --parallel newspack-blog-posts-block-*",
38-
"newspack-carousel-block-editor": "calypso-build --env source='newspack-blocks/carousel-block-editor'",
39-
"newspack-carousel-block-view": "calypso-build --env source='newspack-blocks/carousel-block-view'",
38+
"newspack-carousel-block-editor": "BROWSERSLIST_ENV=wpcom calypso-build --env source='newspack-blocks/carousel-block-editor'",
39+
"newspack-carousel-block-view": "BROWSERSLIST_ENV=wpcom calypso-build --env source='newspack-blocks/carousel-block-view'",
4040
"newspack-blocks-carousel-block": "npm-run-all --parallel newspack-carousel-block-*",
4141
"dev:newspack-blocks": "yarn run newspack-blocks",
4242
"build:newspack-blocks": "NODE_ENV=production yarn run newspack-blocks",
43-
"starter-page-templates": "calypso-build --env source='starter-page-templates'",
43+
"starter-page-templates": "BROWSERSLIST_ENV=wpcom calypso-build --env source='starter-page-templates'",
4444
"dev:starter-page-templates": "yarn run starter-page-templates",
4545
"build:starter-page-templates": "NODE_ENV=production yarn run starter-page-templates",
46-
"event-countdown-block": "calypso-build --env source='event-countdown-block'",
46+
"event-countdown-block": "BROWSERSLIST_ENV=wpcom calypso-build --env source='event-countdown-block'",
4747
"dev:event-countdown-block": "yarn run event-countdown-block",
4848
"build:event-countdown-block": "NODE_ENV=production yarn run event-countdown-block",
49-
"global-styles": "calypso-build --env source='global-styles'",
49+
"global-styles": "BROWSERSLIST_ENV=wpcom calypso-build --env source='global-styles'",
5050
"build:global-styles": "NODE_ENV=production yarn run global-styles",
5151
"dev:global-styles": "yarn run global-styles",
52-
"jetpack-timeline": "calypso-build --env source='jetpack-timeline'",
52+
"jetpack-timeline": "BROWSERSLIST_ENV=wpcom calypso-build --env source='jetpack-timeline'",
5353
"dev:jetpack-timeline": "yarn run jetpack-timeline",
5454
"build:jetpack-timeline": "NODE_ENV=production yarn run jetpack-timeline",
55-
"wpcom-block-editor-nux": "calypso-build --env source='wpcom-block-editor-nux'",
55+
"wpcom-block-editor-nux": "BROWSERSLIST_ENV=wpcom calypso-build --env source='wpcom-block-editor-nux'",
5656
"dev:wpcom-block-editor-nux": "yarn run wpcom-block-editor-nux",
5757
"build:wpcom-block-editor-nux": "NODE_ENV=production yarn run wpcom-block-editor-nux",
58-
"wpcom-block-editor-welcome-tour": "calypso-build --env source='wpcom-block-editor-welcome-tour'",
58+
"wpcom-block-editor-welcome-tour": "BROWSERSLIST_ENV=wpcom calypso-build --env source='wpcom-block-editor-welcome-tour'",
5959
"block-inserter-modifications": "npm-run-all --parallel block-inserter-modifications-*",
60-
"block-inserter-modifications-contextual-tips": "calypso-build --env source='block-inserter-modifications/contextual-tips'",
60+
"block-inserter-modifications-contextual-tips": "BROWSERSLIST_ENV=wpcom calypso-build --env source='block-inserter-modifications/contextual-tips'",
6161
"dev:block-inserter-modifications": "yarn run block-inserter-modifications",
6262
"build:block-inserter-modifications": "NODE_ENV=production yarn run block-inserter-modifications",
63-
"wpcom-block-editor-nav-sidebar": "calypso-build --env source='wpcom-block-editor-nav-sidebar'",
63+
"wpcom-block-editor-nav-sidebar": "BROWSERSLIST_ENV=wpcom calypso-build --env source='wpcom-block-editor-nav-sidebar'",
6464
"dev:wpcom-block-editor-nav-sidebar": "yarn run wpcom-block-editor-nav-sidebar",
6565
"build:wpcom-block-editor-nav-sidebar": "NODE_ENV=production yarn run wpcom-block-editor-nav-sidebar",
66-
"block-patterns": "calypso-build --env source='block-patterns'",
66+
"block-patterns": "BROWSERSLIST_ENV=wpcom calypso-build --env source='block-patterns'",
6767
"dev:block-patterns": "yarn run block-patterns",
6868
"build:block-patterns": "NODE_ENV=production yarn run block-patterns",
69-
"whats-new": "calypso-build --env source='whats-new'",
69+
"whats-new": "BROWSERSLIST_ENV=wpcom calypso-build --env source='whats-new'",
7070
"dev:whats-new": "yarn run whats-new",
7171
"build:whats-new": "NODE_ENV=production yarn run whats-new",
7272
"dev": "node bin/npm-run-build.js --dev",

apps/notifications/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"clean": "npx rimraf dist",
2121
"prebuild": "yarn run clean",
22-
"build": "calypso-build --config='./webpack.config.js'",
22+
"build": "BROWSERSLIST_ENV=wpcom calypso-build --config='./webpack.config.js'",
2323
"sync": "yarn run clean && yarn run build && sh ./bin/wpcom-watch-and-sync.sh"
2424
},
2525
"dependencies": {

apps/o2-blocks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"scripts": {
2020
"clean": "npx rimraf dist",
2121
"prebuild": "yarn run clean",
22-
"build": "calypso-build"
22+
"build": "BROWSERSLIST_ENV=wpcom calypso-build"
2323
},
2424
"dependencies": {
2525
"@automattic/calypso-build": "^7.0.0",

apps/wpcom-block-editor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
},
1717
"homepage": "https://github.com/Automattic/wp-calypso",
1818
"scripts": {
19-
"bundle": "calypso-build --env WP",
20-
"build:dev": "npm run bundle --",
19+
"bundle": "BROWSERSLIST_ENV=wpcom calypso-build --env WP",
20+
"build:dev": "yarn run bundle --",
2121
"build:prod": "NODE_ENV=production yarn run bundle --",
2222
"build": "npm-run-all --parallel \"build:* -- {@}\" --",
2323
"clean": "npx rimraf dist",

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"url": "https://github.com/Automattic/wp-calypso.git"
2727
},
2828
"browserslist": {
29+
"wpcom": [
30+
"extends @wordpress/browserslist-config"
31+
],
2932
"defaults": [
3033
"extends @wordpress/browserslist-config"
3134
],

packages/calypso-build/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Breaking: Drop option `postCssConfig` for Sass loader. The property `postCssOptions` will be passed as is
66
to `postcss-loader`. See the doc in <https://github.com/webpack-contrib/postcss-loader#postcssoptions>
7+
- Breaking: `calypso-build`, `transpile` and `webpack/minify` won't set `defaults` as browserslist environment anymore.
8+
Instead they will fallback to the [default resolution methods from browserslist](https://github.com/browserslist/browserslist#queries)
79
- Added: peer dependency postcss ^8.2.6
810
- Updated dependencies:
911
- postcss-custom-properties to ^11.0.0

packages/calypso-build/bin/transpile.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ const baseCommand = `npx --no-install babel --presets="${ babelPresetFile }" --i
3939

4040
if ( transpileAll || transpileESM ) {
4141
execSync( `${ baseCommand } -d "${ outputDirESM }" "${ inputDir }"`, {
42-
env: Object.assign( {}, process.env, { BROWSERSLIST_ENV: 'defaults' } ),
4342
cwd: root,
4443
} );
4544
}
4645

4746
if ( transpileAll || transpileCJS ) {
4847
execSync( `${ baseCommand } -d "${ outputDirCJS }" "${ inputDir }"`, {
49-
env: Object.assign( {}, process.env, { BROWSERSLIST_ENV: 'defaults', MODULES: 'commonjs' } ),
48+
env: Object.assign( {}, process.env, { MODULES: 'commonjs' } ),
5049
cwd: root,
5150
} );
5251
}

packages/calypso-build/webpack/minify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const browserslist = require( 'browserslist' );
66
const babelPlugins = require( '@babel/compat-data/plugins' );
77
const semver = require( 'semver' );
88

9-
const supportedBrowsers = browserslist( null, { env: process.env.BROWSERSLIST_ENV || 'defaults' } );
9+
const supportedBrowsers = browserslist();
1010

1111
// The list of browsers to check, that are supported by babel compat-data.
1212
// Babel compat-data also includes non-browser environments, which we want to exclude.

packages/wpcom.js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"build": "run-s build:modules build:bundle",
1313
"prepack": "yarn run clean && yarn run build",
1414
"build:modules": "transpile",
15-
"build:bundle": "webpack --display errors-only"
15+
"build:bundle": "webpack --stats-preset errors-only"
1616
},
1717
"keywords": [
1818
"wordpress",

packages/wpcom.js/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ module.exports = {
99
libraryTarget: 'var',
1010
library: 'WPCOM',
1111
},
12-
devtool: 'sourcemap',
12+
devtool: 'source-map',
1313
};

0 commit comments

Comments
 (0)