Skip to content

Commit e2dc3fc

Browse files
committed
Lessen significance of browserslist
Adjust the default browsers to be a single list and remove it from the build output; it only affects CSS now
1 parent a1a08db commit e2dc3fc

File tree

3 files changed

+8
-48
lines changed

3 files changed

+8
-48
lines changed

packages/react-dev-utils/browsersHelper.js

Lines changed: 3 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ const inquirer = require('inquirer');
1313
const pkgUp = require('pkg-up');
1414
const fs = require('fs');
1515

16-
const defaultBrowsers = {
17-
development: ['chrome', 'firefox', 'edge'].map(
18-
browser => `last 2 ${browser} versions`
19-
),
20-
production: ['>0.25%', 'not op_mini all', 'ie 11'],
21-
};
16+
const defaultBrowsers = ['>0.25%', 'not op_mini all', 'ie 11'];
2217

2318
function checkBrowsers(dir, retry = true) {
2419
const current = browserslist.findConfig(dir);
@@ -66,16 +61,7 @@ function checkBrowsers(dir, retry = true) {
6661
console.log();
6762
console.log(chalk.green('Set target browsers:'));
6863
console.log();
69-
console.log(
70-
`\t${chalk.bold('Production')}: ${chalk.cyan(
71-
defaultBrowsers.production.join(', ')
72-
)}`
73-
);
74-
console.log(
75-
`\t${chalk.bold('Development')}: ${chalk.cyan(
76-
defaultBrowsers.development.join(', ')
77-
)}`
78-
);
64+
console.log(`\t${chalk.cyan(defaultBrowsers.join(', '))}`);
7965
console.log();
8066
})
8167
// Swallow any error
@@ -88,20 +74,4 @@ function checkBrowsers(dir, retry = true) {
8874
});
8975
}
9076

91-
function printBrowsers(dir) {
92-
return checkBrowsers(dir).then(browsers => {
93-
if (browsers == null) {
94-
console.log('Built the bundle with default browser support.');
95-
return;
96-
}
97-
browsers = browsers[process.env.NODE_ENV] || browsers;
98-
if (Array.isArray(browsers)) {
99-
browsers = browsers.join(', ');
100-
}
101-
console.log(
102-
`Built the bundle with browser support for ${chalk.cyan(browsers)}.`
103-
);
104-
});
105-
}
106-
107-
module.exports = { defaultBrowsers, checkBrowsers, printBrowsers };
77+
module.exports = { defaultBrowsers, checkBrowsers };

packages/react-scripts/package.json

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,9 @@
8080
"optionalDependencies": {
8181
"fsevents": "1.2.4"
8282
},
83-
"browserslist": {
84-
"development": [
85-
"last 2 chrome versions",
86-
"last 2 firefox versions",
87-
"last 2 edge versions"
88-
],
89-
"production": [
90-
">1%",
91-
"last 4 versions",
92-
"Firefox ESR",
93-
"not ie < 11"
94-
]
95-
}
83+
"browserslist": [
84+
">0.25%",
85+
"not op_mini all",
86+
"ie 11"
87+
]
9688
}

packages/react-scripts/scripts/build.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
4141
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
4242
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
4343
const printBuildError = require('react-dev-utils/printBuildError');
44-
const { printBrowsers } = require('react-dev-utils/browsersHelper');
4544

4645
const measureFileSizesBeforeBuild =
4746
FileSizeReporter.measureFileSizesBeforeBuild;
@@ -119,7 +118,6 @@ checkBrowsers(paths.appPath)
119118
buildFolder,
120119
useYarn
121120
);
122-
printBrowsers(paths.appPath);
123121
},
124122
err => {
125123
console.log(chalk.red('Failed to compile.\n'));

0 commit comments

Comments
 (0)