Skip to content
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

Loosen Babel preset to use browserslist #3770

Merged
merged 6 commits into from
Jan 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions packages/babel-preset-react-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,12 @@ module.exports = function(api, opts) {
// Latest stable ECMAScript features
require('@babel/preset-env').default,
{
targets: {
// React parses on ie 9, so we should too
ie: 9,
},
// We currently minify with uglify
// Remove after https://github.com/mishoo/UglifyJS2/issues/448
forceAllTransforms: true,
// Disable polyfill transforms
useBuiltIns: false,
// `entry` transforms `@babel/polyfill` into individual requires for
// the targeted browsers. This is safer than `usage` which performs
// static code analysis to determine what's required.
// This is probably a fine default to help trim down bundles when
// end-users inevitably import '@babel/polyfill'.
useBuiltIns: 'entry',
// Do not transform modules to CJS
modules: false,
},
Expand Down Expand Up @@ -104,7 +101,7 @@ module.exports = function(api, opts) {
!isEnvTest && [
require('@babel/plugin-transform-regenerator').default,
{
// Async functions are converted to generators by babel-preset-env
// Async functions are converted to generators by @babel/preset-env
async: false,
},
],
Expand Down
12 changes: 6 additions & 6 deletions packages/react-scripts/scripts/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ module.exports = function(
eject: 'react-scripts eject',
};

appPackage.browserslist = [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9',
];
appPackage.browserslist = {
development: ['chrome', 'firefox', 'edge'].map(
browser => `last 2 ${browser} versions`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change? Does this correspond to any specific list we use elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I got it.
Wish there was a shorter way to write this.
Maybe something like >5% is equivalent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a magic percent -- and I didn't want to discriminate browsers.

),
production: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 11'],
};

fs.writeFileSync(
path.join(appPath, 'package.json'),
Expand Down
4 changes: 4 additions & 0 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ original_yarn_registry_url=`yarn config get registry`

function cleanup {
echo 'Cleaning up.'
unset BROWSERSLIST
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9
cd "$root_path"
# TODO: fix "Device or resource busy" and remove ``|| $CI`
Expand Down Expand Up @@ -114,6 +115,9 @@ yarn add test-integrity@^2.0.1
# Enter the app directory
cd "$temp_app_path/test-kitchensink"

# In kitchensink, we want to test all transforms
export BROWSERSLIST='ie 9'

# Link to test module
npm link "$temp_module_path/node_modules/test-integrity"

Expand Down