From 15b91e23e590d2b0223c17a898bc63df75777035 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 12 Jan 2018 20:42:56 -0500 Subject: [PATCH 1/6] Provide better defaults --- packages/react-scripts/scripts/init.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 27b214e6431..7854a803771 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -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` + ), + production: ['>1%', 'last 4 versions', 'Firefox ESR', 'not ie < 11'], + }; fs.writeFileSync( path.join(appPath, 'package.json'), From 56c839edc21cd70b28f9771f507636bf91069800 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 12 Jan 2018 20:55:20 -0500 Subject: [PATCH 2/6] Let babel determine features to compile --- packages/babel-preset-react-app/index.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index bce9b72f7cc..38b82de4ee6 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -46,16 +46,13 @@ 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, - // Do not transform modules to CJS + // `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, }, ], @@ -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, }, ], From f49973ac5ae485904ba7cfd10049d4882483a77f Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 12 Jan 2018 20:57:04 -0500 Subject: [PATCH 3/6] meh --- packages/babel-preset-react-app/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 38b82de4ee6..4c9daa7161a 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -52,7 +52,7 @@ module.exports = function(api, opts) { // 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. + // Do not transform modules to CJS modules: false, }, ], From ee2db707faa8b9ada3e7a668e8a94944f5955a1e Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 12 Jan 2018 21:35:25 -0500 Subject: [PATCH 4/6] Remove setting of BABEL_ENV --- tasks/e2e-kitchensink.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 7b17163ca9e..19421bf3981 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,14 +151,12 @@ E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - BABEL_ENV=test \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_PATH=src \ NODE_ENV=production \ - BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js @@ -204,14 +202,12 @@ E2E_URL="http://localhost:3002" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - BABEL_ENV=test \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_ENV=production \ - BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js From a0ac1374e075465f722c81a12a9c32238e642e47 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 12 Jan 2018 21:39:27 -0500 Subject: [PATCH 5/6] Revert "Remove setting of BABEL_ENV" This reverts commit ee2db707faa8b9ada3e7a668e8a94944f5955a1e. --- tasks/e2e-kitchensink.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 19421bf3981..7b17163ca9e 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -151,12 +151,14 @@ E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ + BABEL_ENV=test \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_PATH=src \ NODE_ENV=production \ + BABEL_ENV=test \ PUBLIC_URL=http://www.example.org/spa/ \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js @@ -202,12 +204,14 @@ E2E_URL="http://localhost:3002" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ + BABEL_ENV=test \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Test "production" environment E2E_FILE=./build/index.html \ CI=true \ NODE_ENV=production \ + BABEL_ENV=test \ NODE_PATH=src \ PUBLIC_URL=http://www.example.org/spa/ \ node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js From ce32902120b25e46c883c31d6914a0a06cae24fd Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Fri, 12 Jan 2018 21:48:15 -0500 Subject: [PATCH 6/6] Set browsers to ie9 --- tasks/e2e-kitchensink.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 7b17163ca9e..a1e1ccc9d42 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -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` @@ -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"