From ff544949b904cf4d2ea5fe926fd25ff367a59999 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Thu, 11 Jan 2018 09:59:42 +0700 Subject: [PATCH 0001/1111] Use uglifyjs-webpack-plugin v1 (#3618) --- .../config/webpack.config.prod.js | 42 +++++++++++-------- packages/react-scripts/package.json | 1 + 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 3b2a2068db2..e1d4bc14a28 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -12,6 +12,7 @@ const autoprefixer = require('autoprefixer'); const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); +const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const ManifestPlugin = require('webpack-manifest-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); @@ -290,24 +291,31 @@ module.exports = { // Otherwise React will be compiled in the very slow development mode. new webpack.DefinePlugin(env.stringified), // Minify the code. - new webpack.optimize.UglifyJsPlugin({ - compress: { - warnings: false, - // Disabled because of an issue with Uglify breaking seemingly valid code: - // https://github.com/facebookincubator/create-react-app/issues/2376 - // Pending further investigation: - // https://github.com/mishoo/UglifyJS2/issues/2011 - comparisons: false, - }, - mangle: { - safari10: true, - }, - output: { - comments: false, - // Turned on because emoji and regex is not minified properly using default - // https://github.com/facebookincubator/create-react-app/issues/2488 - ascii_only: true, + new UglifyJsPlugin({ + uglifyOptions: { + compress: { + warnings: false, + // Disabled because of an issue with Uglify breaking seemingly valid code: + // https://github.com/facebookincubator/create-react-app/issues/2376 + // Pending further investigation: + // https://github.com/mishoo/UglifyJS2/issues/2011 + comparisons: false, + }, + mangle: { + safari10: true, + }, + output: { + comments: false, + // Turned on because emoji and regex is not minified properly using default + // https://github.com/facebookincubator/create-react-app/issues/2488 + ascii_only: true, + }, }, + // Use multi-process parallel running to improve the build speed + // Default number of concurrent runs: os.cpus().length - 1 + parallel: true, + // Enable file caching + cache: true, sourceMap: shouldUseSourceMap, }), // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 91d4a584cf4..6abfd73490c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,6 +53,7 @@ "react-dev-utils": "^5.0.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", + "uglifyjs-webpack-plugin": "1.1.4", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4", From 1f18ab7879dff957efe51d342be8ece71a0b43b9 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Wed, 10 Jan 2018 22:20:33 -0500 Subject: [PATCH 0002/1111] Specify ecma version (#3743) --- packages/react-scripts/config/webpack.config.prod.js | 1 + packages/react-scripts/package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index e1d4bc14a28..b99db8a27ef 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -293,6 +293,7 @@ module.exports = { // Minify the code. new UglifyJsPlugin({ uglifyOptions: { + ecma: 5, compress: { warnings: false, // Disabled because of an issue with Uglify breaking seemingly valid code: diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 6abfd73490c..bc1f07b34c1 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,7 +53,7 @@ "react-dev-utils": "^5.0.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", - "uglifyjs-webpack-plugin": "1.1.4", + "uglifyjs-webpack-plugin": "1.1.6", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4", From 0a331710aa8cc8d9c76e17b06066eec5779ead1c Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Wed, 10 Jan 2018 02:39:13 +1000 Subject: [PATCH 0003/1111] Move browsers to cross-tool config (#3644) --- packages/react-scripts/config/webpack.config.dev.js | 6 ------ packages/react-scripts/config/webpack.config.prod.js | 6 ------ packages/react-scripts/scripts/init.js | 7 +++++++ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 9f3131b0660..843ec0dd318 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -200,12 +200,6 @@ module.exports = { plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway - ], flexbox: 'no-2009', }), ], diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index b99db8a27ef..2f37dbfe7f4 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -222,12 +222,6 @@ module.exports = { plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway - ], flexbox: 'no-2009', }), ], diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index b283bad6ee6..27b214e6431 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -43,6 +43,13 @@ module.exports = function( eject: 'react-scripts eject', }; + appPackage.browserslist = [ + '>1%', + 'last 4 versions', + 'Firefox ESR', + 'not ie < 9', + ]; + fs.writeFileSync( path.join(appPath, 'package.json'), JSON.stringify(appPackage, null, 2) From 3c3547f9428fc6d4ef4251f6a689de91b0b9c9df Mon Sep 17 00:00:00 2001 From: "Kent C. Dodds" Date: Tue, 9 Jan 2018 09:53:42 -0700 Subject: [PATCH 0004/1111] add experimental babel-plugin-macros support (#3675) * add experimental babel-plugin-macros support closes #2730 This will remain undocumented until the brave have tried it in the wild. **Test Plan:** There's currently no established way to test changes to `babel-preset-react-app`. But I did create [`unmaintained-react-scripts-babel-macros`](https://www.npmjs.com/package/unmaintained-react-scripts-babel-macros) [a while back](https://github.com/facebookincubator/create-react-app/issues/2730#issuecomment-328153982) and it worked well. * Pin the version --- packages/babel-preset-react-app/index.js | 3 +++ packages/babel-preset-react-app/package.json | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index d90fb6af50b..d1639dd2161 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -7,6 +7,9 @@ 'use strict'; const plugins = [ + // Experimental macros support. Will be documented after it's had some time + // in the wild. + require.resolve('babel-plugin-macros'), // Necessary to include regardless of the environment because // in practice some other transforms (such as object-rest-spread) // don't work without it: https://github.com/babel/babel/issues/7215 diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index c6a7e29441d..108e1ea3cfa 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -12,6 +12,7 @@ ], "dependencies": { "babel-plugin-dynamic-import-node": "1.1.0", + "babel-plugin-macros": "2.0.0", "babel-plugin-syntax-dynamic-import": "6.18.0", "babel-plugin-transform-class-properties": "6.24.1", "babel-plugin-transform-es2015-destructuring": "6.23.0", From 813584ff35bc850383e4b075b7aa712b24ade993 Mon Sep 17 00:00:00 2001 From: everdimension Date: Wed, 10 Jan 2018 04:38:54 +0300 Subject: [PATCH 0005/1111] Redisable require.ensure() (#3121) --- packages/eslint-config-react-app/index.js | 13 ++++++------- packages/react-scripts/config/webpack.config.dev.js | 5 ++--- .../react-scripts/config/webpack.config.prod.js | 5 ++--- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index c7a619abd62..9b687663da9 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -225,13 +225,12 @@ module.exports = { 'valid-typeof': 'warn', 'no-restricted-properties': [ 'error', - // TODO: reenable once import() is no longer slow. - // https://github.com/facebookincubator/create-react-app/issues/2176 - // { - // object: 'require', - // property: 'ensure', - // message: 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting', - // }, + { + object: 'require', + property: 'ensure', + message: + 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting', + }, { object: 'System', property: 'import', diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 843ec0dd318..b509af97054 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -117,9 +117,8 @@ module.exports = { module: { strictExportPresence: true, rules: [ - // TODO: Disable require.ensure as it's not a standard language feature. - // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176. - // { parser: { requireEnsure: false } }, + // Disable require.ensure as it's not a standard language feature. + { parser: { requireEnsure: false } }, // First, run the linter. // It's important to do this before Babel processes the JS. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 2f37dbfe7f4..d3673a723b5 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -124,9 +124,8 @@ module.exports = { module: { strictExportPresence: true, rules: [ - // TODO: Disable require.ensure as it's not a standard language feature. - // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176. - // { parser: { requireEnsure: false } }, + // Disable require.ensure as it's not a standard language feature. + { parser: { requireEnsure: false } }, // First, run the linter. // It's important to do this before Babel processes the JS. From b6aebb9e8f2e1bb049e855e739e578bd00d90021 Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Tue, 9 Jan 2018 21:08:39 -0500 Subject: [PATCH 0006/1111] Remove the navigateFallback behavior from the generated service worker (#3419) * Disables navigateFallback and updates the README * Typos * Updated a URL in a comment. --- .../config/webpack.config.prod.js | 9 ++-- packages/react-scripts/template/README.md | 47 ++++++++++++++----- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index d3673a723b5..dea5b99eac6 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -344,13 +344,12 @@ module.exports = { console.log(message); }, minify: true, - // For unknown URLs, fallback to the index page - navigateFallback: publicUrl + '/index.html', - // Ignores URLs starting from /__ (useful for Firebase): - // https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219 - navigateFallbackWhitelist: [/^(?!\/__).*/], // Don't precache sourcemaps (they're large) and build asset manifest: staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], + // `navigateFallback` and `navigateFallbackWhitelist` are disabled by default; see + // https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#service-worker-considerations + // navigateFallback: publicUrl + '/index.html', + // navigateFallbackWhitelist: [/^(?!\/__).*/], }), // Moment.js is an extremely popular library that bundles large locale files // by default due to how Webpack interprets its code. This is a practical diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 7c641456056..ee0860f0b6b 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -83,6 +83,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Static Server](#static-server) - [Other Solutions](#other-solutions) - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing) + - [Service Worker Considerations](#service-worker-considerations) - [Building for Relative Paths](#building-for-relative-paths) - [Azure](#azure) - [Firebase](#firebase) @@ -1791,8 +1792,14 @@ is integrated into production configuration, and it will take care of generating a service worker file that will automatically precache all of your local assets and keep them up to date as you deploy updates. The service worker will use a [cache-first strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network) -for handling all requests for local assets, including the initial HTML, ensuring -that your web app is reliably fast, even on a slow or unreliable network. +for handling all requests for local assets, including +[navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests) +for `/` and `/index.html`, ensuring that your web app is consistently fast, even +on a slow or unreliable network. + +>Note: If you are using the `pushState` history API and want to enable +cache-first navigations for URLs other than `/` and `/index.html`, please +[follow these steps](#service-worker-considerations). ### Opting Out of Caching @@ -1995,21 +2002,37 @@ If you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow Now requests to `/todos/42` will be handled correctly both in development and in production. -On a production build, and in a browser that supports [service workers](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers), -the service worker will automatically handle all navigation requests, like for -`/todos/42`, by serving the cached copy of your `index.html`. This -service worker navigation routing can be configured or disabled by -[`eject`ing](#npm-run-eject) and then modifying the -[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) -and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp) -options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js). - -When users install your app to the homescreen of their device the default configuration will make a shortcut to `/index.html`. This may not work for client-side routers which expect the app to be served from `/`. Edit the web app manifest at [`public/manifest.json`](public/manifest.json) and change `start_url` to match the required URL scheme, for example: +When users install your app to the homescreen of their device the default +configuration will make a shortcut to `/index.html`. This may not work for +client-side routers which expect the app to be served from `/`. Edit the web app +manifest at [`public/manifest.json`](public/manifest.json) and change +`start_url` to match the required URL scheme, for example: ```js "start_url": ".", ``` +### Service Worker Considerations + +[Navigation requests](https://developers.google.com/web/fundamentals/primers/service-workers/high-performance-loading#first_what_are_navigation_requests) +for URLs like `/todos/42` will not be intercepted by the +[service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) +created by the production build. Navigations for those URLs will always +require a network connection, as opposed to navigations for `/` and +`/index.html`, both of which will be served from the cache by the service worker +and work without requiring a network connection. + +If you are using the `pushState` history API and would like to enable service +worker support for navigations to URLs like `/todos/42`, you need to +[`npm eject`](#npm-run-eject) and enable the +[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) +and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp) +options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js). + +>Note: This is a [change in default behavior](https://github.com/facebookincubator/create-react-app/issues/3248), +as earlier versions of `create-react-app` shipping with `navigateFallback` +enabled by default. + ### Building for Relative Paths By default, Create React App produces a build assuming your app is hosted at the server root.
From 3c79497eb016d02d6cf85e8b9dcec96b5fa2bb20 Mon Sep 17 00:00:00 2001 From: Rami Date: Wed, 10 Jan 2018 15:49:34 +0000 Subject: [PATCH 0007/1111] Change the default `start_url` to `.` (#3346) --- packages/react-scripts/template/README.md | 13 ++----------- .../react-scripts/template/public/manifest.json | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index ee0860f0b6b..044ccc0ecdd 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -2002,15 +2002,7 @@ If you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow Now requests to `/todos/42` will be handled correctly both in development and in production. -When users install your app to the homescreen of their device the default -configuration will make a shortcut to `/index.html`. This may not work for -client-side routers which expect the app to be served from `/`. Edit the web app -manifest at [`public/manifest.json`](public/manifest.json) and change -`start_url` to match the required URL scheme, for example: - -```js - "start_url": ".", -``` +When users install your app to the homescreen of their device the default configuration will make a shortcut to `/`. This may not work if you don't use a client-side router and expect the app to be served from `/index.html`. In this case, the web app manifest at [`public/manifest.json`](public/manifest.json) and change `start_url` to `./index.html`. ### Service Worker Considerations @@ -2024,8 +2016,7 @@ and work without requiring a network connection. If you are using the `pushState` history API and would like to enable service worker support for navigations to URLs like `/todos/42`, you need to -[`npm eject`](#npm-run-eject) and enable the -[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) +[`npm eject`](#npm-run-eject) and enable the [`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string) and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp) options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js). diff --git a/packages/react-scripts/template/public/manifest.json b/packages/react-scripts/template/public/manifest.json index ef19ec243e7..1f2f141fafd 100644 --- a/packages/react-scripts/template/public/manifest.json +++ b/packages/react-scripts/template/public/manifest.json @@ -8,7 +8,7 @@ "type": "image/x-icon" } ], - "start_url": "./index.html", + "start_url": ".", "display": "standalone", "theme_color": "#000000", "background_color": "#ffffff" From 776d2d6036a32172a310e8dd05c9ad2c71443470 Mon Sep 17 00:00:00 2001 From: aisensiy Date: Thu, 11 Jan 2018 15:49:30 +0800 Subject: [PATCH 0008/1111] Update jest to 22 and support watchPathIgnorePatterns configuration (#3124) * update jest to 21.0.2 to support watchPathIgnorePatterns configuration * update jest to 21.1.0 * Try bumping Jest * Bump babel-jest * Try to debug weird CI failure * Remove debug code * Bump other Jest packages * ffs * temp * Revert "temp" This reverts commit 62aec9ac1ae70a995a89548feb7ac7870e5324c0. --- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 2 +- packages/react-scripts/package.json | 4 ++-- packages/react-scripts/scripts/utils/createJestConfig.js | 1 + 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 18f37c971e4..d589710e67d 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -56,7 +56,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "20.0.4" + "jest": "22.0.5" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 87099dd5e82..208be0d4017 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -48,7 +48,7 @@ "eslint-plugin-react": "7.1.0", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "20.0.4", + "jest": "22.0.5", "jest-fetch-mock": "1.2.1", "object-assign": "4.1.1", "promise": "8.0.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index bc1f07b34c1..59c6be2d13f 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -24,7 +24,7 @@ "autoprefixer": "7.1.6", "babel-core": "6.26.0", "babel-eslint": "7.2.3", - "babel-jest": "20.0.3", + "babel-jest": "22.0.4", "babel-loader": "7.1.2", "babel-preset-react-app": "^3.1.1", "babel-runtime": "6.26.0", @@ -44,7 +44,7 @@ "file-loader": "1.1.5", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", - "jest": "20.0.4", + "jest": "22.0.5", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.8", diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index b4c2cfa5ea9..4c2e6f1d002 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -62,6 +62,7 @@ module.exports = (resolve, rootDir, isEjecting) => { 'coverageReporters', 'coverageThreshold', 'snapshotSerializers', + 'watchPathIgnorePatterns', ]; if (overrides) { supportedKeys.forEach(key => { From 590df7eead1a2526828aa36ceff41397e82bd4dd Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 11 Jan 2018 14:14:17 +0000 Subject: [PATCH 0009/1111] Bump Jest to 22.0.6 (#3751) --- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 2 +- packages/react-scripts/package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index d589710e67d..24f851b1cfc 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -56,7 +56,7 @@ "text-table": "0.2.0" }, "devDependencies": { - "jest": "22.0.5" + "jest": "22.0.6" }, "scripts": { "test": "jest" diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 208be0d4017..c6cbfeca108 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -48,7 +48,7 @@ "eslint-plugin-react": "7.1.0", "flow-bin": "^0.63.1", "html-entities": "1.2.1", - "jest": "22.0.5", + "jest": "22.0.6", "jest-fetch-mock": "1.2.1", "object-assign": "4.1.1", "promise": "8.0.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 59c6be2d13f..0b2f62eb825 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -24,7 +24,7 @@ "autoprefixer": "7.1.6", "babel-core": "6.26.0", "babel-eslint": "7.2.3", - "babel-jest": "22.0.4", + "babel-jest": "22.0.6", "babel-loader": "7.1.2", "babel-preset-react-app": "^3.1.1", "babel-runtime": "6.26.0", @@ -44,7 +44,7 @@ "file-loader": "1.1.5", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", - "jest": "22.0.5", + "jest": "22.0.6", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.8", From 1552949a3bce629de9e6fde1794e01c07226bf9c Mon Sep 17 00:00:00 2001 From: Clement Hoang Date: Thu, 11 Jan 2018 18:42:33 -0500 Subject: [PATCH 0010/1111] Switch to Babel 7 (#3522) * Update dependencies in react-scripts * Add first pass of working dependencies for babel-preset-react-app and react-scripts * Bump more dependency versions * Adjust more versions and edit fix options * Restore functionality of old preset * Disable Uglify in iframe webpack * Apply prettier * Re-enable cache in dev and clean deps * Lock packages and move babel/core to dep in preset * Bump babel-jest * Re-enable uglify * Nest forceAllTransforms correctly in webpack config * Install babel-core bridge for jest * Add jest-cli and babel-core bridge to make tests in react-error-overlay pass * Re-enable transform-dynamic-import * Add dynamic import syntax support back * Use new babel in kitchensink * Transform modules in test * Revert "Transform modules in test" This reverts commit 539e46a1d77259898b7e70d778a5e43fc25edc2a. * Attempt fix for ejected tests * try this * Add regenerator back * Bump babel deps to beta.34 * Remove bad files * Use default when requiring babel transform plugin * Bump deps * Try the fix? * Oopsie * Remove some weird things * Run Babel on react-error-overlay tests * Try fixing kitchensink * Use new API for codeFrame * Add missing (?) babelrc * Maybe this helps? * Maybe fix mocha * I shouldn't have deleted this :facepalm: --- packages/babel-preset-react-app/index.js | 195 ++++++++---------- packages/babel-preset-react-app/package.json | 30 ++- packages/eslint-config-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 12 +- .../src/containers/StackFrameCodeBlock.js | 15 +- .../webpack.config.iframe.js | 19 +- .../config/webpack.config.dev.js | 6 +- .../config/webpack.config.prod.js | 6 +- .../fixtures/kitchensink/.babelrc | 4 - .../kitchensink/.template.dependencies.json | 6 +- packages/react-scripts/package.json | 9 +- tasks/e2e-kitchensink.sh | 25 ++- tasks/replace-own-deps.js | 10 +- 14 files changed, 178 insertions(+), 163 deletions(-) delete mode 100644 packages/react-scripts/fixtures/kitchensink/.babelrc diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index d1639dd2161..1a153606e2a 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -6,138 +6,117 @@ */ 'use strict'; -const plugins = [ - // Experimental macros support. Will be documented after it's had some time - // in the wild. - require.resolve('babel-plugin-macros'), - // Necessary to include regardless of the environment because - // in practice some other transforms (such as object-rest-spread) - // don't work without it: https://github.com/babel/babel/issues/7215 - require.resolve('babel-plugin-transform-es2015-destructuring'), - // class { handleClick = () => { } } - require.resolve('babel-plugin-transform-class-properties'), - // The following two plugins use Object.assign directly, instead of Babel's - // extends helper. Note that this assumes `Object.assign` is available. - // { ...todo, completed: true } - [ - require.resolve('babel-plugin-transform-object-rest-spread'), - { - useBuiltIns: true, - }, - ], - // Transforms JSX - [ - require.resolve('babel-plugin-transform-react-jsx'), - { - useBuiltIns: true, - }, - ], - // Polyfills the runtime needed for async/await and generators - [ - require.resolve('babel-plugin-transform-runtime'), - { - helpers: false, - polyfill: false, - regenerator: true, - }, - ], -]; - -// This is similar to how `env` works in Babel: -// https://babeljs.io/docs/usage/babelrc/#env-option -// We are not using `env` because it’s ignored in versions > babel-core@6.10.4: -// https://github.com/babel/babel/issues/4539 -// https://github.com/facebookincubator/create-react-app/issues/720 -// It’s also nice that we can enforce `NODE_ENV` being specified. -var env = process.env.BABEL_ENV || process.env.NODE_ENV; -if (env !== 'development' && env !== 'test' && env !== 'production') { - throw new Error( - 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' + - '`BABEL_ENV` environment variables. Valid values are "development", ' + - '"test", and "production". Instead, received: ' + - JSON.stringify(env) + - '.' - ); -} +module.exports = function(api, opts) { + if (!opts) { + opts = {}; + } -if (env === 'development' || env === 'test') { - // The following two plugins are currently necessary to make React warnings - // include more valuable information. They are included here because they are - // currently not enabled in babel-preset-react. See the below threads for more info: - // https://github.com/babel/babel/issues/4702 - // https://github.com/babel/babel/pull/3540#issuecomment-228673661 - // https://github.com/facebookincubator/create-react-app/issues/989 - plugins.push.apply(plugins, [ - // Adds component stack to warning messages - require.resolve('babel-plugin-transform-react-jsx-source'), - // Adds __self attribute to JSX which React will use for some warnings - require.resolve('babel-plugin-transform-react-jsx-self'), - ]); -} + // This is similar to how `env` works in Babel: + // https://babeljs.io/docs/usage/babelrc/#env-option + // We are not using `env` because it’s ignored in versions > babel-core@6.10.4: + // https://github.com/babel/babel/issues/4539 + // https://github.com/facebookincubator/create-react-app/issues/720 + // It’s also nice that we can enforce `NODE_ENV` being specified. + var env = process.env.BABEL_ENV || process.env.NODE_ENV; + var isEnvDevelopment = env === 'development'; + var isEnvProduction = env === 'production'; + var isEnvTest = env === 'test'; + if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) { + throw new Error( + 'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' + + '`BABEL_ENV` environment variables. Valid values are "development", ' + + '"test", and "production". Instead, received: ' + + JSON.stringify(env) + + '.' + ); + } -if (env === 'test') { - module.exports = { + return { presets: [ - // ES features necessary for user's Node version - [ - require('babel-preset-env').default, + isEnvTest && [ + // ES features necessary for user's Node version + require('@babel/preset-env').default, { targets: { - node: 'current', + node: '6.12', }, }, ], - // JSX, Flow - require.resolve('babel-preset-react'), - ], - plugins: plugins.concat([ - // Compiles import() to a deferred require() - require.resolve('babel-plugin-dynamic-import-node'), - ]), - }; -} else { - module.exports = { - presets: [ - // Latest stable ECMAScript features - [ - require.resolve('babel-preset-env'), + (isEnvProduction || isEnvDevelopment) && [ + // 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 - uglify: true, }, + // 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 modules: false, }, ], - // JSX, Flow - require.resolve('babel-preset-react'), - ], - plugins: plugins.concat([ - // function* () { yield 42; yield 43; } [ - require.resolve('babel-plugin-transform-regenerator'), + require('@babel/preset-react').default, + { + // Adds component stack to warning messages + // Adds __self attribute to JSX which React will use for some warnings + development: isEnvDevelopment || isEnvTest, + }, + ], + [require('@babel/preset-flow').default], + ].filter(Boolean), + plugins: [ + // Experimental macros support. Will be documented after it's had some time + // in the wild. + require('babel-plugin-macros'), + // Necessary to include regardless of the environment because + // in practice some other transforms (such as object-rest-spread) + // don't work without it: https://github.com/babel/babel/issues/7215 + require('@babel/plugin-transform-destructuring').default, + // class { handleClick = () => { } } + require('@babel/plugin-proposal-class-properties').default, + // The following two plugins use Object.assign directly, instead of Babel's + // extends helper. Note that this assumes `Object.assign` is available. + // { ...todo, completed: true } + [ + require('@babel/plugin-proposal-object-rest-spread').default, + { + useBuiltIns: true, + }, + ], + // Transforms JSX + [ + require('@babel/plugin-transform-react-jsx').default, + { + useBuiltIns: true, + }, + ], + // Polyfills the runtime needed for async/await and generators + [ + require('@babel/plugin-transform-runtime').default, + { + helpers: false, + polyfill: false, + regenerator: true, + }, + ], + // function* () { yield 42; yield 43; } + !isEnvTest && [ + require('@babel/plugin-transform-regenerator').default, { // Async functions are converted to generators by babel-preset-env async: false, }, ], // Adds syntax support for import() - require.resolve('babel-plugin-syntax-dynamic-import'), - ]), + require('@babel/plugin-syntax-dynamic-import').default, + isEnvTest && + // Transform dynamic import to require + require('babel-plugin-transform-dynamic-import').default, + ].filter(Boolean), }; - - if (env === 'production') { - // Optimization: hoist JSX that never changes out of render() - // Disabled because of issues: https://github.com/facebookincubator/create-react-app/issues/553 - // TODO: Enable again when these issues are resolved. - // plugins.push.apply(plugins, [ - // require.resolve('babel-plugin-transform-react-constant-elements') - // ]); - } -} +}; diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 108e1ea3cfa..adb596cadd4 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -11,22 +11,20 @@ "index.js" ], "dependencies": { - "babel-plugin-dynamic-import-node": "1.1.0", + "@babel/core": "7.0.0-beta.36", + "@babel/plugin-proposal-class-properties": "7.0.0-beta.36", + "@babel/plugin-syntax-dynamic-import": "^7.0.0-beta.36", + "@babel/plugin-transform-classes": "7.0.0-beta.36", + "@babel/plugin-transform-destructuring": "7.0.0-beta.36", + "@babel/plugin-transform-react-constant-elements": "7.0.0-beta.36", + "@babel/plugin-transform-react-display-name": "7.0.0-beta.36", + "@babel/plugin-transform-react-jsx": "7.0.0-beta.36", + "@babel/plugin-transform-regenerator": "7.0.0-beta.36", + "@babel/plugin-transform-runtime": "7.0.0-beta.36", + "@babel/preset-env": "7.0.0-beta.36", + "@babel/preset-flow": "7.0.0-beta.36", + "@babel/preset-react": "7.0.0-beta.36", "babel-plugin-macros": "2.0.0", - "babel-plugin-syntax-dynamic-import": "6.18.0", - "babel-plugin-transform-class-properties": "6.24.1", - "babel-plugin-transform-es2015-destructuring": "6.23.0", - "babel-plugin-transform-object-rest-spread": "6.26.0", - "babel-plugin-transform-react-constant-elements": "6.23.0", - "babel-plugin-transform-react-jsx": "6.24.1", - "babel-plugin-transform-react-jsx-self": "6.22.0", - "babel-plugin-transform-react-jsx-source": "6.22.0", - "babel-plugin-transform-regenerator": "6.26.0", - "babel-plugin-transform-runtime": "6.23.0", - "babel-preset-env": "1.6.1", - "babel-preset-react": "6.24.1" - }, - "peerDependencies": { - "babel-runtime": "^6.23.0" + "babel-plugin-transform-dynamic-import": "2.0.0" } } diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index c13b0417c46..86cdbbaf1ef 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -11,7 +11,7 @@ "index.js" ], "peerDependencies": { - "babel-eslint": "^7.2.3", + "babel-eslint": "^8.0.2", "eslint": "^4.1.1", "eslint-plugin-flowtype": "^2.34.1", "eslint-plugin-import": "^2.6.0", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 24f851b1cfc..1ab145a4b89 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -37,7 +37,7 @@ ], "dependencies": { "address": "1.0.3", - "babel-code-frame": "6.26.0", + "@babel/code-frame": "7.0.0-beta.36", "chalk": "1.1.3", "cross-spawn": "5.1.0", "detect-port-alt": "1.1.5", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index c6cbfeca108..8b4aa4d443d 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -30,13 +30,15 @@ "lib/index.js" ], "devDependencies": { + "@babel/code-frame": "7.0.0-beta.36", + "@babel/core": "7.0.0-beta.36", + "@babel/runtime": "7.0.0-beta.36", "anser": "1.4.4", - "babel-code-frame": "6.26.0", - "babel-core": "^6.26.0", - "babel-eslint": "7.2.3", - "babel-loader": "^7.1.2", + "babel-core": "^7.0.0-bridge.0", + "babel-eslint": "^8.0.2", + "babel-jest": "^22.0.6", + "babel-loader": "^8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", - "babel-runtime": "6.26.0", "chalk": "^2.1.0", "chokidar": "^1.7.0", "cross-env": "5.0.5", diff --git a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js index 9bd36e019f7..eedf8006b84 100644 --- a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js +++ b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js @@ -14,7 +14,7 @@ import type { ScriptLine } from '../utils/stack-frame'; import { primaryErrorStyle, secondaryErrorStyle } from '../styles'; import generateAnsiHTML from '../utils/generateAnsiHTML'; -import codeFrame from 'babel-code-frame'; +import { codeFrameColumns } from '@babel/code-frame'; type StackFrameCodeBlockPropsType = {| lines: ScriptLine[], @@ -53,10 +53,17 @@ function StackFrameCodeBlock(props: Exact) { } sourceCode[line - 1] = text; }); - const ansiHighlight = codeFrame( + const ansiHighlight = codeFrameColumns( sourceCode.join('\n'), - lineNum, - columnNum == null ? 0 : columnNum - (isFinite(whiteSpace) ? whiteSpace : 0), + { + start: { + line: lineNum, + column: + columnNum == null + ? 0 + : columnNum - (isFinite(whiteSpace) ? whiteSpace : 0), + }, + }, { forceColor: true, linesAbove: contextSize, diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index c80b15afa14..2f26b43823f 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -19,7 +19,24 @@ module.exports = { rules: [ { test: /\.js$/, - include: path.resolve(__dirname, './src'), + include: [ + path.resolve(__dirname, './src'), + path.dirname( + require.resolve('chalk', { + paths: path.dirname(require.resolve('@babel/code-frame')), + }) + ), + path.dirname( + require.resolve( + 'ansi-styles', + path.dirname( + require.resolve('chalk', { + paths: path.dirname(require.resolve('@babel/code-frame')), + }) + ) + ) + ), + ], use: 'babel-loader', }, ], diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index b509af97054..2c6b364fe55 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -96,9 +96,9 @@ module.exports = { // Resolve Babel runtime relative to react-scripts. // It usually still works on npm 3 without this but it would be // unfortunate to rely on, as react-scripts could be symlinked, - // and thus babel-runtime might not be resolvable from the source. - 'babel-runtime': path.dirname( - require.resolve('babel-runtime/package.json') + // and thus @babel/runtime might not be resolvable from the source. + '@babel/runtime': path.dirname( + require.resolve('@babel/runtime/package.json') ), // @remove-on-eject-end // Support React Native Web diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index dea5b99eac6..0f1fc1c1704 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -103,9 +103,9 @@ module.exports = { // Resolve Babel runtime relative to react-scripts. // It usually still works on npm 3 without this but it would be // unfortunate to rely on, as react-scripts could be symlinked, - // and thus babel-runtime might not be resolvable from the source. - 'babel-runtime': path.dirname( - require.resolve('babel-runtime/package.json') + // and thus @babel/runtime might not be resolvable from the source. + '@babel/runtime': path.dirname( + require.resolve('@babel/runtime/package.json') ), // @remove-on-eject-end // Support React Native Web diff --git a/packages/react-scripts/fixtures/kitchensink/.babelrc b/packages/react-scripts/fixtures/kitchensink/.babelrc deleted file mode 100644 index 14397221e3b..00000000000 --- a/packages/react-scripts/fixtures/kitchensink/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "presets": ["react-app"], - "plugins": ["babel-plugin-transform-es2015-modules-commonjs"] -} diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index b8500f804b1..e4d3bec84f2 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -1,8 +1,8 @@ { "dependencies": { - "babel-register": "6.22.0", - "babel-plugin-transform-es2015-modules-commonjs": "6.22.0", - "babel-polyfill": "6.20.0", + "@babel/plugin-transform-modules-commonjs": "7.0.0-beta.36", + "@babel/polyfill": "7.0.0-beta.36", + "@babel/register": "7.0.0-beta.36", "chai": "3.5.0", "jsdom": "9.8.3", "mocha": "3.2.0", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 0b2f62eb825..357cc1bb376 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -21,13 +21,14 @@ "react-scripts": "./bin/react-scripts.js" }, "dependencies": { + "@babel/core": "7.0.0-beta.36", + "@babel/runtime": "7.0.0-beta.36", "autoprefixer": "7.1.6", - "babel-core": "6.26.0", - "babel-eslint": "7.2.3", + "babel-core": "7.0.0-bridge.0", + "babel-eslint": "8.0.2", "babel-jest": "22.0.6", - "babel-loader": "7.1.2", + "babel-loader": "8.0.0-beta.0", "babel-preset-react-app": "^3.1.1", - "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", "css-loader": "0.28.7", diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index d73c45ddbfa..7b17163ca9e 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -134,26 +134,37 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_ENV=test \ yarn test --no-cache --testPathPattern=src -# Test "development" environment +# Prepare "development" environment tmp_server_log=`mktemp` PORT=3001 \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_PATH=src \ nohup yarn start &>$tmp_server_log & grep -q 'You can now view' <(tail -f $tmp_server_log) + +# Before running Mocha, specify that it should use our preset +# TODO: this is very hacky and we should find some other solution +echo '{"presets":["react-app"]}' > .babelrc + +# Test "development" environment E2E_URL="http://localhost:3001" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js - + 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 --require babel-register --require babel-polyfill integration/*.test.js + node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js + +# Remove the config we just created for Mocha +# TODO: this is very hacky and we should find some other solution +rm .babelrc # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -193,15 +204,17 @@ E2E_URL="http://localhost:3002" \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true NODE_PATH=src \ NODE_ENV=development \ - node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js + 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 --require babel-register --require babel-polyfill integration/*.test.js + node_modules/.bin/mocha --compilers js:@babel/register --require @babel/polyfill integration/*.test.js # Cleanup cleanup diff --git a/tasks/replace-own-deps.js b/tasks/replace-own-deps.js index 9178b01029e..15d53d9dc86 100755 --- a/tasks/replace-own-deps.js +++ b/tasks/replace-own-deps.js @@ -16,13 +16,15 @@ const packagesDir = path.join(__dirname, '../packages'); const pkgFilename = path.join(packagesDir, 'react-scripts/package.json'); const data = require(pkgFilename); -fs.readdirSync(packagesDir).forEach((name) => { +fs.readdirSync(packagesDir).forEach(name => { if (data.dependencies[name]) { data.dependencies[name] = 'file:' + path.join(packagesDir, name); } -}) +}); -fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', (err) => { - if (err) throw err; +fs.writeFile(pkgFilename, JSON.stringify(data, null, 2), 'utf8', err => { + if (err) { + throw err; + } console.log('Replaced local dependencies.'); }); From b90f2337d1c4bee35561e7a2c63d15a97de55f6d Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 12 Jan 2018 13:24:16 +0000 Subject: [PATCH 0011/1111] wip --- .../webpack.config.iframe.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 2f26b43823f..8e9bed55b42 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -23,21 +23,27 @@ module.exports = { path.resolve(__dirname, './src'), path.dirname( require.resolve('chalk', { - paths: path.dirname(require.resolve('@babel/code-frame')), + paths: [path.dirname(require.resolve('@babel/code-frame'))], }) ), path.dirname( - require.resolve( - 'ansi-styles', - path.dirname( - require.resolve('chalk', { - paths: path.dirname(require.resolve('@babel/code-frame')), - }) - ) - ) + require.resolve('ansi-styles', { + paths: [ + path.dirname( + require.resolve('chalk', { + paths: [path.dirname(require.resolve('@babel/code-frame'))], + }) + ), + ], + }) ), ], - use: 'babel-loader', + use: { + loader: 'babel-loader', + options: { + presets: ['react-app'], + }, + }, }, ], }, From c8970c4e9a99db27fb541b471ab82a124f228b14 Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 12 Jan 2018 18:10:40 +0000 Subject: [PATCH 0012/1111] Fix the build --- .../webpack.config.iframe.js | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 8e9bed55b42..1da7c9ba841 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -21,22 +21,7 @@ module.exports = { test: /\.js$/, include: [ path.resolve(__dirname, './src'), - path.dirname( - require.resolve('chalk', { - paths: [path.dirname(require.resolve('@babel/code-frame'))], - }) - ), - path.dirname( - require.resolve('ansi-styles', { - paths: [ - path.dirname( - require.resolve('chalk', { - paths: [path.dirname(require.resolve('@babel/code-frame'))], - }) - ), - ], - }) - ), + /\/node_modules\/(ansi-styles|chalk)\//, ], use: { loader: 'babel-loader', From 11b4fae3c746f4af5b51a6c458d93269418908e2 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 Jan 2018 19:55:28 +0000 Subject: [PATCH 0013/1111] Update appveyor.cleanup-cache.txt --- appveyor.cleanup-cache.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/appveyor.cleanup-cache.txt b/appveyor.cleanup-cache.txt index ea6d1b9c010..d48a91fdf35 100644 --- a/appveyor.cleanup-cache.txt +++ b/appveyor.cleanup-cache.txt @@ -2,5 +2,3 @@ Edit this file to trigger a cache rebuild. http://help.appveyor.com/discussions/questions/1310-delete-cache ---- -Just testing if this works. -lalala. From a573d37f36ad17a4e9f0a04b8382a85c48bb38bd Mon Sep 17 00:00:00 2001 From: Dan Date: Fri, 12 Jan 2018 20:00:42 +0000 Subject: [PATCH 0014/1111] Fix windows build --- packages/react-error-overlay/webpack.config.iframe.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 1da7c9ba841..e6a7f69de30 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -21,7 +21,7 @@ module.exports = { test: /\.js$/, include: [ path.resolve(__dirname, './src'), - /\/node_modules\/(ansi-styles|chalk)\//, + /[\/\\]node_modules[\/\\](ansi-styles|chalk)[\/\\]/, ], use: { loader: 'babel-loader', From bf02edbef2a20ff8af66b396d7ee6ae7901c45a0 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 12 Jan 2018 22:43:40 +0000 Subject: [PATCH 0015/1111] Bump eslint-plugin-jsx-a11y version (#2690) * Bump eslint-plugin-jsx-a11y * Update index.js * Update index.js * Update package.json * Don't use links for non-linky things --- packages/eslint-config-react-app/index.js | 7 ++++++- packages/eslint-config-react-app/package.json | 2 +- packages/react-error-overlay/package.json | 2 +- .../src/containers/CompileErrorContainer.js | 4 ++-- packages/react-error-overlay/src/containers/StackFrame.js | 8 ++++---- packages/react-scripts/package.json | 2 +- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 9b687663da9..836dd5aa0ae 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -270,13 +270,18 @@ module.exports = { 'jsx-a11y/accessible-emoji': 'warn', 'jsx-a11y/alt-text': 'warn', 'jsx-a11y/anchor-has-content': 'warn', + 'jsx-a11y/anchor-is-valid': [ + 'warn', + { + aspects: ['noHref', 'invalidHref'], + }, + ], 'jsx-a11y/aria-activedescendant-has-tabindex': 'warn', 'jsx-a11y/aria-props': 'warn', 'jsx-a11y/aria-proptypes': 'warn', 'jsx-a11y/aria-role': 'warn', 'jsx-a11y/aria-unsupported-elements': 'warn', 'jsx-a11y/heading-has-content': 'warn', - 'jsx-a11y/href-no-hash': 'warn', 'jsx-a11y/iframe-has-title': 'warn', 'jsx-a11y/img-redundant-alt': 'warn', 'jsx-a11y/no-access-key': 'warn', diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 86cdbbaf1ef..b15be1dd29a 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -15,7 +15,7 @@ "eslint": "^4.1.1", "eslint-plugin-flowtype": "^2.34.1", "eslint-plugin-import": "^2.6.0", - "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-jsx-a11y": "^6.0.2", "eslint-plugin-react": "^7.1.0" } } diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 8b4aa4d443d..8d9f429ce76 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -46,7 +46,7 @@ "eslint-config-react-app": "^2.1.0", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", - "eslint-plugin-jsx-a11y": "5.1.1", + "eslint-plugin-jsx-a11y": "6.0.2", "eslint-plugin-react": "7.1.0", "flow-bin": "^0.63.1", "html-entities": "1.2.1", diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js index 9d1e399fd10..3e9d4611860 100644 --- a/packages/react-error-overlay/src/containers/CompileErrorContainer.js +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -32,14 +32,14 @@ class CompileErrorContainer extends PureComponent { return (
- editorHandler(errLoc) : null } style={canOpenInEditor ? codeAnchorStyle : null} > - +