From 062be50b00d413edcb8cfd18948c86ec13b1fae8 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 25 Sep 2018 16:08:29 -0400 Subject: [PATCH] Drop IE 11 support by default (#5090) * Drop ie 11 support and move polyfills to a new package * More useful directions for what entry point to use https://github.com/facebook/create-react-app/pull/5090#discussion_r220313783 * Clear up what file this polyfill goes in https://github.com/facebook/create-react-app/pull/5090#discussion_r220313980 * Polyfill `window`, not `global` * Remove proxy polyfill file --- config/polyfills.js | 30 ------------------------------ config/webpack.config.dev.js | 3 --- config/webpack.config.prod.js | 4 ++-- package.json | 7 ++----- scripts/utils/createJestConfig.js | 2 +- 5 files changed, 5 insertions(+), 41 deletions(-) delete mode 100644 config/polyfills.js diff --git a/config/polyfills.js b/config/polyfills.js deleted file mode 100644 index 8d97fb4ac39..00000000000 --- a/config/polyfills.js +++ /dev/null @@ -1,30 +0,0 @@ -// @remove-on-eject-begin -/** - * Copyright (c) 2015-present, Facebook, Inc. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ -// @remove-on-eject-end -'use strict'; - -if (typeof Promise === 'undefined') { - // Rejection tracking prevents a common issue where React gets into an - // inconsistent state due to an error, but it gets swallowed by a Promise, - // and the user has no idea what causes React's erratic future behavior. - require('promise/lib/rejection-tracking').enable(); - window.Promise = require('promise/lib/es6-extensions.js'); -} - -// fetch() polyfill for making API calls. -require('whatwg-fetch'); - -// Object.assign() is commonly used with React. -// It will use the native implementation if it's present and isn't buggy. -Object.assign = require('object-assign'); - -// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet. -// We don't polyfill it in the browser--this is user's responsibility. -if (process.env.NODE_ENV === 'test') { - require('raf').polyfill(global); -} diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index 13fe5cafc24..24f51c018b7 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -82,10 +82,7 @@ module.exports = { devtool: 'cheap-module-source-map', // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. - // The first two entry points enable "hot" CSS and auto-refreshes for JS. entry: [ - // We ship a few polyfills by default: - require.resolve('./polyfills'), // Include an alternative client for WebpackDevServer. A client's job is to // connect to WebpackDevServer by a socket and get notified about changes. // When you save a file, the client will either apply hot updates (in case diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js index af250048d14..76e767faddf 100644 --- a/config/webpack.config.prod.js +++ b/config/webpack.config.prod.js @@ -100,8 +100,8 @@ module.exports = { // We generate sourcemaps in production. This is slow but gives good results. // You can exclude the *.map files from the build during deployment. devtool: shouldUseSourceMap ? 'source-map' : false, - // In production, we only want to load the polyfills and the app code. - entry: [require.resolve('./polyfills'), paths.appIndexJs], + // In production, we only want to load the app code. + entry: [paths.appIndexJs], output: { // The build folder. path: paths.appBuild, diff --git a/package.json b/package.json index 93627fd1db2..c632cecbb9c 100644 --- a/package.json +++ b/package.json @@ -50,14 +50,12 @@ "jest": "23.6.0", "loader-utils": "1.1.0", "mini-css-extract-plugin": "0.4.3", - "object-assign": "4.1.1", "optimize-css-assets-webpack-plugin": "5.0.1", "postcss-flexbugs-fixes": "4.1.0", "postcss-loader": "3.0.0", "postcss-preset-env": "6.0.6", "postcss-safe-parser": "4.0.1", - "promise": "8.0.2", - "raf": "3.4.0", + "react-app-polyfill": "^0.0.0", "react-dev-utils": "^5.0.0", "resolve": "1.8.1", "sass-loader": "7.1.0", @@ -68,8 +66,7 @@ "url-loader": "1.1.1", "webpack": "4.19.1", "webpack-dev-server": "3.1.9", - "webpack-manifest-plugin": "2.0.4", - "whatwg-fetch": "3.0.0" + "webpack-manifest-plugin": "2.0.4" }, "devDependencies": { "react": "^16.3.2", diff --git a/scripts/utils/createJestConfig.js b/scripts/utils/createJestConfig.js index c077746a9e2..22e52dbdca4 100644 --- a/scripts/utils/createJestConfig.js +++ b/scripts/utils/createJestConfig.js @@ -22,7 +22,7 @@ module.exports = (resolve, rootDir, isEjecting) => { // in Jest configs. We need help from somebody with Windows to determine this. const config = { collectCoverageFrom: ['src/**/*.{js,jsx}'], - setupFiles: [resolve('config/polyfills.js')], + setupFiles: ['react-app-polyfill/jsdom'], setupTestFrameworkScriptFile: setupTestsFile, testMatch: [ '/src/**/__tests__/**/*.{js,jsx}',