From b60f55c6bf229890c2f7e23eba27cb825aace5dc Mon Sep 17 00:00:00 2001 From: Jin Zheng Date: Thu, 25 May 2017 23:18:29 +0800 Subject: [PATCH 001/265] Print file sizes with correct build folder path. (#2361) * Print file sizes with correct build folder path. * Just use the print the basename. --- packages/react-dev-utils/FileSizeReporter.js | 4 ++-- packages/react-scripts/scripts/build.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js index a0db0684f..8f822d201 100644 --- a/packages/react-dev-utils/FileSizeReporter.js +++ b/packages/react-dev-utils/FileSizeReporter.js @@ -18,7 +18,7 @@ var stripAnsi = require('strip-ansi'); var gzipSize = require('gzip-size').sync; // Prints a detailed summary of build files. -function printFileSizesAfterBuild(webpackStats, previousSizeMap) { +function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder) { var root = previousSizeMap.root; var sizes = previousSizeMap.sizes; var assets = webpackStats @@ -30,7 +30,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap) { var previousSize = sizes[removeFileNameHash(root, asset.name)]; var difference = getDifferenceLabel(size, previousSize); return { - folder: path.join('build', path.dirname(asset.name)), + folder: path.join(path.basename(buildFolder), path.dirname(asset.name)), name: path.basename(asset.name), size: size, sizeLabel: filesize(size) + (difference ? ' (' + difference + ')' : ''), diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 6548609ff..bc46c71d6 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -75,7 +75,7 @@ measureFileSizesBeforeBuild(paths.appBuild) } console.log('File sizes after gzip:\n'); - printFileSizesAfterBuild(stats, previousFileSizes); + printFileSizesAfterBuild(stats, previousFileSizes, paths.appBuild); console.log(); const appPackage = require(paths.appPackageJson); From fbaeff2d6ef83ae5dc8213150e0fa6589ed29150 Mon Sep 17 00:00:00 2001 From: Mirza Joldic Date: Fri, 26 May 2017 07:33:02 -0400 Subject: [PATCH 002/265] Update README.md for `now` deployments (#2372) Simplified steps for deploying app to `now` as a static site. No need to `serve` script in `package.json` file. As of May 15, 2017, all static deployments on `now` are free and unlimited. --- packages/react-scripts/template/README.md | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index dd7a48299..a04686c9c 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1774,27 +1774,23 @@ When you build the project, Create React App will place the `public` folder cont ### Now -[now](https://zeit.co/now) offers a zero-configuration single-command deployment. +[now](https://zeit.co/now) offers a zero-configuration single-command deployment. You can use `now` to deploy your app for free. 1. Install the `now` command-line tool either via the recommended [desktop tool](https://zeit.co/download) or via node with `npm install -g now`. -2. Install `serve` by running `npm install --save serve`. +2. Build your app by running `npm run build`. -3. Add this line to `scripts` in `package.json`: +3. Move into the build directory by running `cd build`. - ``` - "now-start": "serve -s build/", - ``` - -4. Run `now` from your project directory. You will see a **now.sh** URL in your output like this: +4. Run `now --name your-project-name` from within the build directory. You will see a **now.sh** URL in your output like this: ``` - > Ready! https://your-project-dirname-tpspyhtdtk.now.sh (copied to clipboard) + > Ready! https://your-project-name-tpspyhtdtk.now.sh (copied to clipboard) ``` Paste that URL into your browser when the build is complete, and you will see your deployed app. -Details are available in [this article.](https://zeit.co/blog/now-static) +Details are available in [this article.](https://zeit.co/blog/unlimited-static) ### S3 and CloudFront From c1ba38dbf525029c637a89b9b33fd0e744b3fd2e Mon Sep 17 00:00:00 2001 From: Zac Kwan Date: Sat, 27 May 2017 19:33:13 +0800 Subject: [PATCH 003/265] Removed the overriding of reduce_vars to false since webpack v2.6.0 included the fixed for Uglify bug (#2351) --- packages/react-scripts/config/webpack.config.prod.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 446fd5ca3..fec81bcab 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -282,10 +282,6 @@ module.exports = { new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false, - // This feature has been reported as buggy a few times, such as: - // https://github.com/mishoo/UglifyJS2/issues/1964 - // We'll wait with enabling it by default until it is more solid. - reduce_vars: false, }, output: { comments: false, From f6d85440335ba61c828cfb30259b2ecb91c3da2d Mon Sep 17 00:00:00 2001 From: David Ascher Date: Sat, 27 May 2017 04:36:42 -0700 Subject: [PATCH 004/265] Disable comparisons feature in uglify compression in production (#2379) * Disable a micro-option in uglify that appears to be buggy See https://github.com/facebookincubator/create-react-app/issues/2376 * wrong plugin * Add a comment --- packages/react-scripts/config/webpack.config.prod.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index fec81bcab..5943c1450 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -282,6 +282,11 @@ module.exports = { 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, }, output: { comments: false, From 2069e8ac43c4765f1698091d3985ecb70ba88089 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 27 May 2017 12:37:07 +0100 Subject: [PATCH 005/265] Consistently set environment variables (#2382) --- packages/react-scripts/scripts/build.js | 1 + packages/react-scripts/scripts/start.js | 6 ++++-- packages/react-scripts/scripts/test.js | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index bc46c71d6..a83d287de 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -11,6 +11,7 @@ 'use strict'; // Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'production'; process.env.NODE_ENV = 'production'; // Makes the script crash on unhandled rejections instead of silently diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index a451228df..b86943b4d 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -10,6 +10,10 @@ // @remove-on-eject-end 'use strict'; +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'development'; +process.env.NODE_ENV = 'development'; + // Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. @@ -17,8 +21,6 @@ process.on('unhandledRejection', err => { throw err; }); -process.env.NODE_ENV = 'development'; - // Ensure environment variables are read. require('../config/env'); diff --git a/packages/react-scripts/scripts/test.js b/packages/react-scripts/scripts/test.js index ef333e6c0..e9adb48f0 100644 --- a/packages/react-scripts/scripts/test.js +++ b/packages/react-scripts/scripts/test.js @@ -10,6 +10,8 @@ // @remove-on-eject-end 'use strict'; +// Do this as the first thing so that any code reading it knows the right env. +process.env.BABEL_ENV = 'test'; process.env.NODE_ENV = 'test'; process.env.PUBLIC_URL = ''; From 1421010ae28059be09b98b233e99b32eaf36a237 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 27 May 2017 12:38:40 +0100 Subject: [PATCH 006/265] Update webpack to 2.6.1 (#2383) --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 8835ff86f..d12b68b89 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,7 +53,7 @@ "style-loader": "0.17.0", "sw-precache-webpack-plugin": "0.9.1", "url-loader": "0.5.8", - "webpack": "2.6.0", + "webpack": "2.6.1", "webpack-dev-server": "2.4.5", "webpack-manifest-plugin": "1.1.0", "whatwg-fetch": "2.0.3" From 84efd450319b7280a49e21001770ffd2da775c5d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 27 May 2017 12:41:44 +0100 Subject: [PATCH 007/265] Add changelog for 1.0.7 (#2384) --- CHANGELOG.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cbeed3a4..9049c88fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,53 @@ +## 1.0.7 (May 27, 2017) + +#### :bug: Bug Fix + +* `react-scripts` + + * [#2382](https://github.com/facebookincubator/create-react-app/pull/2382) Consistently set environment variables. ([@gaearon](https://github.com/gaearon)) + * [#2379](https://github.com/facebookincubator/create-react-app/pull/2379) Temporarily disable `comparisons` feature in uglify compression. ([@davidascher](https://github.com/davidascher)) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#2383](https://github.com/facebookincubator/create-react-app/pull/2383) Update webpack to 2.6.1. ([@gaearon](https://github.com/gaearon)) + * [#2349](https://github.com/facebookincubator/create-react-app/pull/2349) Update webpack to v2.6.0. ([@ingro](https://github.com/ingro)) + * [#2351](https://github.com/facebookincubator/create-react-app/pull/2351) Removed the overriding of `reduce_vars` since webpack v2.6.0 included fix of Uglify. ([@Zaccc123](https://github.com/Zaccc123)) + +* `react-dev-utils`, `react-scripts` + + * [#2361](https://github.com/facebookincubator/create-react-app/pull/2361) Print file sizes with correct build folder path. ([@fezhengjin](https://github.com/fezhengjin)) + +#### :memo: Documentation + +* `react-scripts` + + * [#2372](https://github.com/facebookincubator/create-react-app/pull/2372) Update README.md for `now` deployments. ([@purplecones](https://github.com/purplecones)) + * [#2350](https://github.com/facebookincubator/create-react-app/pull/2350) Fix broken links. ([@gaearon](https://github.com/gaearon)) + +#### Committers: 6 +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- David Ascher ([davidascher](https://github.com/davidascher)) +- Emanuele Ingrosso ([ingro](https://github.com/ingro)) +- Jin Zheng ([fezhengjin](https://github.com/fezhengjin)) +- Mirza Joldic ([purplecones](https://github.com/purplecones)) +- Zac Kwan ([Zaccc123](https://github.com/Zaccc123)) + +### Migrating from 1.0.6 to 1.0.7 + +Inside any created project that has not been ejected, run: + +``` +npm install --save-dev --save-exact react-scripts@1.0.7 +``` + +or + +``` +yarn add --dev --exact react-scripts@1.0.7 +``` + ## 1.0.6 (May 24, 2017) #### :bug: Bug Fix From 58d8c5c05cc90d9286beb6b4200f5ac1918a8910 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 27 May 2017 12:42:54 +0100 Subject: [PATCH 008/265] Publish - react-dev-utils@3.0.0 - react-error-overlay@1.0.7 - react-scripts@1.0.7 --- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 4 ++-- packages/react-scripts/package.json | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index f62d87f8b..46f3a9203 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "2.0.1", + "version": "3.0.0", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 70a01e3f6..88c909e11 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "1.0.6", + "version": "1.0.7", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { @@ -34,7 +34,7 @@ "anser": "1.2.5", "babel-code-frame": "6.22.0", "babel-runtime": "6.23.0", - "react-dev-utils": "^2.0.1", + "react-dev-utils": "^3.0.0", "settle-promise": "1.0.0", "source-map": "0.5.6" }, diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index d12b68b89..e6879f756 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.6", + "version": "1.0.7", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -48,8 +48,8 @@ "postcss-flexbugs-fixes": "3.0.0", "postcss-loader": "2.0.5", "promise": "7.1.1", - "react-dev-utils": "^2.0.1", - "react-error-overlay": "^1.0.6", + "react-dev-utils": "^3.0.0", + "react-error-overlay": "^1.0.7", "style-loader": "0.17.0", "sw-precache-webpack-plugin": "0.9.1", "url-loader": "0.5.8", From 5317b3f910d4796dafbf87aa571eebc45cd1b277 Mon Sep 17 00:00:00 2001 From: Fabrizio Castellarin Date: Sat, 27 May 2017 21:32:12 +0200 Subject: [PATCH 009/265] Catch "No tests found" during CI (#2387) --- tasks/e2e-kitchensink.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 2295615e8..9d60d6e29 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -158,6 +158,16 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_ENV=test \ npm test -- --no-cache --testPathPattern="/src/" +# Catch when no tests are detected +testsList=$(REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ + CI=true \ + NODE_PATH=src \ + npm test -- --no-cache --testPathPattern="/src/" --listTests) + +if [[ ${testsList} =~ "[]" ]]; then + exit 1 +fi + # Test "development" environment tmp_server_log=`mktemp` PORT=3001 \ From 70bf12505c4419c171aca3e07d7a388bf1dc9cbc Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 27 May 2017 21:26:53 +0100 Subject: [PATCH 010/265] Suggest just "yarn build" (#2385) --- packages/react-dev-utils/WebpackDevServerUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index b681c601f..51a0feb56 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -107,7 +107,7 @@ function printInstructions(appName, urls, useYarn) { console.log('Note that the development build is not optimized.'); console.log( `To create a production build, use ` + - `${chalk.cyan(`${useYarn ? 'yarn' : 'npm'} run build`)}.` + `${chalk.cyan(`${useYarn ? 'yarn' : 'npm run'} build`)}.` ); console.log(); } From 2aafaad72d1737eae98c4de9cbe275c1988ec4ae Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 27 May 2017 21:38:00 +0100 Subject: [PATCH 011/265] Fix wrong path expansion in end-to-end test (#2388) * Update e2e-kitchensink.sh * Try again (differently) --- tasks/e2e-kitchensink.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 9d60d6e29..4506066cc 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -156,13 +156,13 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ NODE_ENV=test \ - npm test -- --no-cache --testPathPattern="/src/" + npm test -- --no-cache --testPathPattern=src # Catch when no tests are detected testsList=$(REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ - npm test -- --no-cache --testPathPattern="/src/" --listTests) + npm test -- --no-cache --testPathPattern=src --listTests) if [[ ${testsList} =~ "[]" ]]; then exit 1 @@ -230,7 +230,7 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ CI=true \ NODE_PATH=src \ NODE_ENV=test \ - npm test -- --no-cache --testPathPattern='/src/' + npm test -- --no-cache --testPathPattern=src # Test "development" environment tmp_server_log=`mktemp` From 3f342383c3fd6a39058d82e599a523103cff7fbc Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sat, 27 May 2017 23:26:03 +0100 Subject: [PATCH 012/265] Revert "Catch "No tests found" during CI" (#2390) * Revert "Fix wrong path expansion in end-to-end test (#2388)" This reverts commit 2aafaad72d1737eae98c4de9cbe275c1988ec4ae. * Revert "Suggest just "yarn build" (#2385)" This reverts commit 70bf12505c4419c171aca3e07d7a388bf1dc9cbc. * Revert "Catch "No tests found" during CI (#2387)" This reverts commit 5317b3f910d4796dafbf87aa571eebc45cd1b277. --- tasks/e2e-kitchensink.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 4506066cc..9e689ca22 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -158,16 +158,6 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ NODE_ENV=test \ npm test -- --no-cache --testPathPattern=src -# Catch when no tests are detected -testsList=$(REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ - CI=true \ - NODE_PATH=src \ - npm test -- --no-cache --testPathPattern=src --listTests) - -if [[ ${testsList} =~ "[]" ]]; then - exit 1 -fi - # Test "development" environment tmp_server_log=`mktemp` PORT=3001 \ From e6ddfb041175918917ae507bd9a994b834ede91d Mon Sep 17 00:00:00 2001 From: Ro Savage Date: Mon, 29 May 2017 22:09:40 +1200 Subject: [PATCH 013/265] Fix kill command in e2e-kitchensink.sh cleanup (#2397) --- tasks/e2e-kitchensink.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 9e689ca22..1a19f4ae6 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -22,7 +22,7 @@ temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'` function cleanup { echo 'Cleaning up.' - ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -s 9 + 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` rm -rf "$temp_cli_path" "$temp_app_path" "$temp_module_path" || $CI From 32f82c03cb5b811337616a7bf959a544e5ba836d Mon Sep 17 00:00:00 2001 From: Ro Savage Date: Tue, 30 May 2017 06:00:43 +1200 Subject: [PATCH 014/265] Added cache clear to e2e scripts (#2400) * Added cache clear to e2e scripts * Install latest yarn on AppVeyor to avoid windows crashing bug in yarn * Alternative fix for yarn crashing e2e tests on windows machines --- tasks/e2e-installs.sh | 24 ++++++++++++++++++++++++ tasks/e2e-kitchensink.sh | 24 ++++++++++++++++++++++++ tasks/e2e-simple.sh | 24 ++++++++++++++++++++++++ 3 files changed, 72 insertions(+) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index b27b1239e..8f4789ff0 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -83,6 +83,30 @@ set -x cd .. root_path=$PWD +# Clear cache to avoid issues with incorrect packages being used +if hash yarnpkg 2>/dev/null +then + # AppVeyor uses an old version of yarn. + # Once updated to 0.24.3 or above, the workaround can be removed + # and replaced with `yarnpkg cache clean` + # Issues: + # https://github.com/yarnpkg/yarn/issues/2591 + # https://github.com/appveyor/ci/issues/1576 + # https://github.com/facebookincubator/create-react-app/pull/2400 + # When removing workaround, you may run into + # https://github.com/facebookincubator/create-react-app/issues/2030 + case "$(uname -s)" in + *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;; + *) yarn=yarnpkg;; + esac + $yarn cache clean +fi + +if hash npm 2>/dev/null +then + npm cache clean +fi + # Prevent lerna bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "lerna bootstrap" package.json > temp && mv temp package.json diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 1a19f4ae6..fcd687e4b 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -66,6 +66,30 @@ set -x cd .. root_path=$PWD +# Clear cache to avoid issues with incorrect packages being used +if hash yarnpkg 2>/dev/null +then + # AppVeyor uses an old version of yarn. + # Once updated to 0.24.3 or above, the workaround can be removed + # and replaced with `yarnpkg cache clean` + # Issues: + # https://github.com/yarnpkg/yarn/issues/2591 + # https://github.com/appveyor/ci/issues/1576 + # https://github.com/facebookincubator/create-react-app/pull/2400 + # When removing workaround, you may run into + # https://github.com/facebookincubator/create-react-app/issues/2030 + case "$(uname -s)" in + *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;; + *) yarn=yarnpkg;; + esac + $yarn cache clean +fi + +if hash npm 2>/dev/null +then + npm cache clean +fi + # Prevent lerna bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "lerna bootstrap" package.json > temp && mv temp package.json diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 4795d09a8..163bec081 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -65,6 +65,30 @@ set -x cd .. root_path=$PWD +# Clear cache to avoid issues with incorrect packages being used +if hash yarnpkg 2>/dev/null +then + # AppVeyor uses an old version of yarn. + # Once updated to 0.24.3 or above, the workaround can be removed + # and replaced with `yarnpkg cache clean` + # Issues: + # https://github.com/yarnpkg/yarn/issues/2591 + # https://github.com/appveyor/ci/issues/1576 + # https://github.com/facebookincubator/create-react-app/pull/2400 + # When removing workaround, you may run into + # https://github.com/facebookincubator/create-react-app/issues/2030 + case "$(uname -s)" in + *CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;; + *) yarn=yarnpkg;; + esac + $yarn cache clean +fi + +if hash npm 2>/dev/null +then + npm cache clean +fi + # Prevent lerna bootstrap, we only want top-level dependencies cp package.json package.json.bak grep -v "lerna bootstrap" package.json > temp && mv temp package.json From bcf398d75bd9b24651f1404e51e45f65917bf0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Miserey?= Date: Mon, 29 May 2017 20:49:57 +0200 Subject: [PATCH 015/265] Fix detection of parent directory in ModuleScopePlugin (#2405) * Fix detection of parent directory * Correct parent directory detection fix Add windows specific path and extend to issuer path --- packages/react-dev-utils/ModuleScopePlugin.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js index fd70a2f40..adc9bdcba 100644 --- a/packages/react-dev-utils/ModuleScopePlugin.js +++ b/packages/react-dev-utils/ModuleScopePlugin.js @@ -37,7 +37,10 @@ class ModuleScopePlugin { // Maybe an indexOf === 0 would be better? const relative = path.relative(appSrc, request.context.issuer); // If it's not in src/ or a subdirectory, not our request! - if (relative[0] === '.') { + if ( + relative.startsWith('../') || + relative.startsWith('..\\') + ) { return callback(); } // Find path from src to the requested file @@ -49,7 +52,10 @@ class ModuleScopePlugin { ) ); // Error if in a parent directory of src/ - if (requestRelative[0] === '.') { + if ( + requestRelative.startsWith('../') || + requestRelative.startsWith('..\\') + ) { callback( new Error( `You attempted to import ${chalk.cyan(request.__innerRequest_request)} which falls outside of the project ${chalk.cyan('src/')} directory. ` + From 19c5277593e933a4e2dc8d169182859ff3a8bf1a Mon Sep 17 00:00:00 2001 From: Lufty Wiranda Date: Tue, 30 May 2017 01:50:32 +0700 Subject: [PATCH 016/265] docs: update `jest-enzyme` section (#2392) since CRA now use the latest version of Jest under the hood, `jest-enzyme` v3.2.0 is now working perfectly fine --- packages/react-scripts/template/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index a04686c9c..ca2879b9c 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1171,10 +1171,10 @@ Additionally, you might find [jest-enzyme](https://github.com/blainekasten/enzym expect(wrapper).toContainReact(welcome) ``` -To setup jest-enzyme with Create React App, follow the instructions for [initializing your test environment](#initializing-test-environment) to import `jest-enzyme`. **Note that currently only version 2.x is compatible with Create React App.** +To setup jest-enzyme with Create React App, follow the instructions for [initializing your test environment](#initializing-test-environment) to import `jest-enzyme`. ```sh -npm install --save-dev jest-enzyme@2.x +npm install --save-dev jest-enzyme ``` ```js From 02f88ba15701f70e613137dd5a3d81caba9d9eb8 Mon Sep 17 00:00:00 2001 From: Marius Wirtherle Date: Tue, 30 May 2017 15:00:16 +0200 Subject: [PATCH 017/265] Add WebStorm >2017 launchEditor Support (#2414) --- packages/react-dev-utils/launchEditor.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index 8bfa3f3dc..a1893d13b 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -72,6 +72,12 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { ['-g', fileName + ':' + lineNumber], workspace ); + case 'webstorm': + case 'webstorm64': + return addWorkspaceToArgumentsIfExists( + ['--line', lineNumber, fileName], + workspace + ); } // For all others, drop the lineNumber until we have From e91648a9bb55230fa15a7867fd5b730d7e1a5808 Mon Sep 17 00:00:00 2001 From: Rustem Kakimov Date: Wed, 31 May 2017 21:40:46 +0800 Subject: [PATCH 018/265] Fix docs typo (#2420) "ensuring that you web app" -> "ensuring that your web app" --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index ca2879b9c..080329cff 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1381,7 +1381,7 @@ and it will take care of generating a service worker file that will automaticall 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 you web app is reliably fast, even on a slow or unreliable network. +that your web app is reliably fast, even on a slow or unreliable network. If you would prefer not to enable service workers prior to your initial production deployment, then remove the call to `serviceWorkerRegistration.register()` From d1f37d98abc9b89771a9582b7657f7cf2d7a5d85 Mon Sep 17 00:00:00 2001 From: Ryan Sullivan Date: Fri, 2 Jun 2017 06:05:25 -0700 Subject: [PATCH 019/265] Update Travis CI Node versions in User Guide (#2454) Removed Node v4 (CRA only supports Node >= 6) --- packages/react-scripts/template/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 080329cff..7db9aef88 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1244,7 +1244,6 @@ Popular CI servers already set the environment variable `CI` by default but you ``` language: node_js node_js: - - 4 - 6 cache: directories: From e898215b7ffcc436306e209227fcf393d134fe69 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Sun, 4 Jun 2017 14:14:16 +0200 Subject: [PATCH 020/265] re-add storybook && update the documentation and links (#2331) * re-add storybook && update the documentation and links * Change to new documentation domain --- packages/react-scripts/template/README.md | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 7db9aef88..955026ac0 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1321,30 +1321,30 @@ If you use [Visual Studio Code](https://code.visualstudio.com), there is a [Jest ![VS Code Jest Preview](https://cloud.githubusercontent.com/assets/49038/20795349/a032308a-b7c8-11e6-9b34-7eeac781003f.png) - +* [GitHub Repo](https://github.com/storybooks/storybook) +* [Documentation](https://storybook.js.org/docs/react-storybook/basics/introduction/) +* [Snapshot Testing UI](https://github.com/storybooks/storybook/tree/master/addons/storyshots) with Storybook + addon/storyshot ## Making a Progressive Web App From b264b8de33cb3a76d30cfc228a7a3a4218603157 Mon Sep 17 00:00:00 2001 From: bryankang Date: Mon, 5 Jun 2017 18:36:13 -0500 Subject: [PATCH 021/265] Prioritize index.css over the implicit App.css (#2470) --- packages/react-scripts/template/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/src/index.js b/packages/react-scripts/template/src/index.js index 53c768842..fae3e3500 100644 --- a/packages/react-scripts/template/src/index.js +++ b/packages/react-scripts/template/src/index.js @@ -1,8 +1,8 @@ import React from 'react'; import ReactDOM from 'react-dom'; +import './index.css'; import App from './App'; import registerServiceWorker from './registerServiceWorker'; -import './index.css'; ReactDOM.render(, document.getElementById('root')); registerServiceWorker(); From c78c1fae6282d4eb0ba6b844e91e49097c0073ea Mon Sep 17 00:00:00 2001 From: Zac Kwan Date: Tue, 6 Jun 2017 21:06:39 +0800 Subject: [PATCH 022/265] Added NamedModulesPlugin in webpack.config.dev.js (#2458) * Added NamedModulesPlugin in webpack.config.dev.js * Update webpack.config.dev.js --- packages/react-scripts/config/webpack.config.dev.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index adf92f5b1..55d3b6ad7 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -249,6 +249,8 @@ module.exports = { inject: true, template: paths.appHtml, }), + // Add module names to factory functions so they appear in browser profiler. + new webpack.NamedModulesPlugin(), // Makes some environment variables available to the JS code, for example: // if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`. new webpack.DefinePlugin(env.stringified), From dc4ce606ef8b4c97aec0c80c20f8116e9795bb21 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 6 Jun 2017 14:02:27 -0400 Subject: [PATCH 023/265] Unscope detect-port (#2483) Resolves #2481 --- packages/react-dev-utils/WebpackDevServerUtils.js | 2 +- packages/react-dev-utils/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 51a0feb56..9c03af40d 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -13,7 +13,7 @@ const fs = require('fs'); const path = require('path'); const url = require('url'); const chalk = require('chalk'); -const detect = require('@timer/detect-port'); +const detect = require('detect-port-alt'); const inquirer = require('inquirer'); const clearConsole = require('./clearConsole'); const formatWebpackMessages = require('./formatWebpackMessages'); diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 46f3a9203..9a7a61119 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -33,12 +33,12 @@ "webpackHotDevClient.js" ], "dependencies": { - "@timer/detect-port": "1.1.3", "address": "1.0.1", "anser": "1.3.0", "babel-code-frame": "6.22.0", "chalk": "1.1.3", "cross-spawn": "4.0.2", + "detect-port-alt": "1.1.3", "escape-string-regexp": "1.0.5", "filesize": "3.3.0", "gzip-size": "3.0.0", From 9438c5bbc12ec5dd261a2afd73c53214cb3016df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanislas=20Ormi=C3=A8res?= Date: Wed, 7 Jun 2017 16:43:22 +0200 Subject: [PATCH 024/265] Update webpack links to point to webpack 2 (#2492) * Update README.md to make links to webpack point to webpack.js.org instead insteade of webpack 1 webpack.githup.io --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8cd74f24f..06a2fbf4d 100644 --- a/README.md +++ b/README.md @@ -199,7 +199,7 @@ Some of them might get added in the future if they are stable, are useful to maj The tools used by Create React App are subject to change. Currently it is a thin layer on top of many amazing community projects, such as: -* [webpack](https://webpack.github.io/) with [webpack-dev-server](https://github.com/webpack/webpack-dev-server), [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin) and [style-loader](https://github.com/webpack/style-loader) +* [webpack](https://webpack.js.org/) with [webpack-dev-server](https://github.com/webpack/webpack-dev-server), [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin) and [style-loader](https://github.com/webpack/style-loader) * [Babel](http://babeljs.io/) with ES6 and extensions used by Facebook (JSX, [object spread](https://github.com/sebmarkbage/ecmascript-rest-spread/commits/master), [class properties](https://github.com/jeffmo/es-class-public-fields)) * [Autoprefixer](https://github.com/postcss/autoprefixer) * [ESLint](http://eslint.org/) @@ -248,5 +248,5 @@ Notable alternatives also include: * [dev-toolkit](https://github.com/stoikerty/dev-toolkit) * [sku](https://github.com/seek-oss/sku) -You can also use module bundlers like [webpack](http://webpack.github.io) and [Browserify](http://browserify.org/) directly.
+You can also use module bundlers like [webpack](http://webpack.js.org) and [Browserify](http://browserify.org/) directly.
React documentation includes [a walkthrough](https://facebook.github.io/react/docs/package-management.html) on this topic. From 054778f4dbae58a875fb44385f1a578fba49b578 Mon Sep 17 00:00:00 2001 From: Glenn Reyes Date: Wed, 7 Jun 2017 16:44:46 +0200 Subject: [PATCH 025/265] chore(templates): Move GitHub templates to hidden .github folder (#2489) --- ISSUE_TEMPLATE.md => .github/ISSUE_TEMPLATE.md | 0 PULL_REQUEST_TEMPLATE.md => .github/PULL_REQUEST_TEMPLATE.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename ISSUE_TEMPLATE.md => .github/ISSUE_TEMPLATE.md (100%) rename PULL_REQUEST_TEMPLATE.md => .github/PULL_REQUEST_TEMPLATE.md (100%) diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md similarity index 100% rename from ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE.md diff --git a/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from PULL_REQUEST_TEMPLATE.md rename to .github/PULL_REQUEST_TEMPLATE.md From cccd855fc84e3342c9539dff0150dd1c648746e6 Mon Sep 17 00:00:00 2001 From: Alexandre Nicastro Date: Thu, 8 Jun 2017 03:41:29 -0300 Subject: [PATCH 026/265] Fix minor docs typo (#2500) --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 955026ac0..a794c615c 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1082,7 +1082,7 @@ The watcher includes an interactive command-line interface with the ability to r ### Version Control Integration -By default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests runs fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests. +By default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests. Jest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests. From 9b3cf2f57dae310d077b9f3da6a57691b3a4605b Mon Sep 17 00:00:00 2001 From: Michael Shilman Date: Mon, 12 Jun 2017 15:15:26 +1200 Subject: [PATCH 027/265] Fix link to Storybook docs (#2521) --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index a794c615c..6439e9dbd 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1359,7 +1359,7 @@ Learn more about React Storybook: * Screencast: [Getting Started with React Storybook](https://egghead.io/lessons/react-getting-started-with-react-storybook) * [GitHub Repo](https://github.com/storybooks/storybook) -* [Documentation](https://storybook.js.org/docs/react-storybook/basics/introduction/) +* [Documentation](https://storybook.js.org/basics/introduction/) * [Snapshot Testing UI](https://github.com/storybooks/storybook/tree/master/addons/storyshots) with Storybook + addon/storyshot ## Making a Progressive Web App From 67f6163b0d86a2980fbaba5ec931fa27abad2f99 Mon Sep 17 00:00:00 2001 From: Khang Lu Date: Tue, 13 Jun 2017 03:19:12 +1000 Subject: [PATCH 028/265] Simplify flow init docs (#2522) - Call `npm run flow --init` won't create a .flowconfig file, it should be `npm run flow init` --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 6439e9dbd..de8e5b44a 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -690,7 +690,7 @@ To add Flow to a Create React App project, follow these steps: 1. Run `npm install --save-dev flow-bin` (or `yarn add --dev flow-bin`). 2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. -3. Run `npm run flow -- init` (or `yarn flow -- init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory. +3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory. 4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). Now you can run `npm run flow` (or `yarn flow`) to check the files for type errors. From acb19575558c2a89df42228c50d2be3e10f02ad5 Mon Sep 17 00:00:00 2001 From: Joseph Frazier <1212jtraceur@gmail.com> Date: Sun, 18 Jun 2017 12:48:40 -0400 Subject: [PATCH 029/265] Upgrade fsevents to 1.1.2 (#2550) This eliminates a `yarn` warning on OSX machines running Node.js 8. See here for details: https://github.com/strongloop/fsevents/issues/170 You can see an example of the warning in the second screenshot in https://github.com/facebookincubator/create-react-app/issues/2422#issuecomment-305218252 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index e6879f756..41ecb0ac4 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -63,6 +63,6 @@ "react-dom": "^15.5.4" }, "optionalDependencies": { - "fsevents": "1.0.17" + "fsevents": "1.1.2" } } From e6f99359e8e2038aa563b85485136a34b9dad537 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 18 Jun 2017 19:50:19 +0300 Subject: [PATCH 030/265] Fix broken link to React Router docs (#2538) * Update README.md Fix broken link to React Router documentation * Update README.md --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index de8e5b44a..1f44ce0af 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1696,7 +1696,7 @@ You can configure a custom domain with GitHub Pages by adding a `CNAME` file to GitHub Pages doesn’t support routers that use the HTML5 `pushState` history API under the hood (for example, React Router using `browserHistory`). This is because when there is a fresh page load for a url like `http://user.github.io/todomvc/todos/42`, where `/todos/42` is a frontend route, the GitHub Pages server returns 404 because it knows nothing of `/todos/42`. If you want to add a router to a project hosted on GitHub Pages, here are a couple of solutions: -* You could switch from using HTML5 history API to routing with hashes. If you use React Router, you can switch to `hashHistory` for this effect, but the URL will be longer and more verbose (for example, `http://user.github.io/todomvc/#/todos/42?_k=yknaj`). [Read more](https://github.com/reactjs/react-router/blob/master/docs/guides/Histories.md#histories) about different history implementations in React Router. +* You could switch from using HTML5 history API to routing with hashes. If you use React Router, you can switch to `hashHistory` for this effect, but the URL will be longer and more verbose (for example, `http://user.github.io/todomvc/#/todos/42?_k=yknaj`). [Read more](https://reacttraining.com/react-router/web/api/Router) about different history implementations in React Router. * Alternatively, you can use a trick to teach GitHub Pages to handle 404 by redirecting to your `index.html` page with a special redirect parameter. You would need to add a `404.html` file with the redirection code to the `build` folder before deploying your project, and you’ll need to add code handling the redirect parameter to `index.html`. You can find a detailed explanation of this technique [in this guide](https://github.com/rafrex/spa-github-pages). ### Heroku From 2ab7ead9070d2221acec564c9d5d68d2a8182a7c Mon Sep 17 00:00:00 2001 From: "Andi N. Dirgantara" Date: Sun, 18 Jun 2017 23:52:34 +0700 Subject: [PATCH 031/265] Fix wrong comment on Proxy guide (#2447) It should be `baz` instead of `bar` on last example. --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 1f44ce0af..c4591c183 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -972,7 +972,7 @@ You may also narrow down matches using `*` and/or `**`, to match the path exactl "target": "", // ... }, - // Matches /bar/abc.html and /bar/sub/def.html + // Matches /baz/abc.html and /baz/sub/def.html "/baz/**/*.html": { "target": "" // ... From b1c0faaffe52cd34b0028ef7cc6b1ff42168b214 Mon Sep 17 00:00:00 2001 From: Levin Rickert Date: Mon, 19 Jun 2017 18:00:11 +0200 Subject: [PATCH 032/265] Show warning when trying to run on port below 1024 without admin permissions under Linux (#2518) --- packages/react-dev-utils/WebpackDevServerUtils.js | 12 ++++++++---- packages/react-dev-utils/package.json | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 9c03af40d..648fef3e1 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -14,6 +14,7 @@ const path = require('path'); const url = require('url'); const chalk = require('chalk'); const detect = require('detect-port-alt'); +const isRoot = require('is-root'); const inquirer = require('inquirer'); const clearConsole = require('./clearConsole'); const formatWebpackMessages = require('./formatWebpackMessages'); @@ -378,6 +379,11 @@ function choosePort(host, defaultPort) { if (port === defaultPort) { return resolve(port); } + const message = process.platform !== 'win32' && + defaultPort < 1024 && + !isRoot() + ? `Admin permissions are required to run a server on a port below 1024.` + : `Something is already running on port ${defaultPort}.`; if (isInteractive) { clearConsole(); const existingProcess = getProcessForPort(defaultPort); @@ -385,7 +391,7 @@ function choosePort(host, defaultPort) { type: 'confirm', name: 'shouldChangePort', message: chalk.yellow( - `Something is already running on port ${defaultPort}.` + + message + `${existingProcess ? ` Probably:\n ${existingProcess}` : ''}` ) + '\n\nWould you like to run the app on another port instead?', default: true, @@ -398,9 +404,7 @@ function choosePort(host, defaultPort) { } }); } else { - console.log( - chalk.red(`Something is already running on port ${defaultPort}.`) - ); + console.log(chalk.red(message)); resolve(null); } }), diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 9a7a61119..6fa6c4117 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -44,6 +44,7 @@ "gzip-size": "3.0.0", "html-entities": "1.2.1", "inquirer": "3.0.6", + "is-root": "1.0.0", "opn": "5.0.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", From 5b38c5439d9f078cbb65e3f9c6ae86cb6f9d7097 Mon Sep 17 00:00:00 2001 From: varnav Date: Mon, 19 Jun 2017 19:36:28 +0300 Subject: [PATCH 033/265] Check if CI variable is set to `'false'` (#2501) * Fix incorrect check if CI variable is set to true Originally build would fail on warnings with any value of CI environment variable. Now it will correctly check if it's true. Discussed here: https://github.com/facebookincubator/create-react-app/issues/2453 * Check for "not false" instead of "not true" After discussion we decided that this will be closer to current functionality and not break anything. --- packages/react-scripts/scripts/build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index a83d287de..aa95774f5 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -112,7 +112,7 @@ function build(previousFileSizes) { if (messages.errors.length) { return reject(new Error(messages.errors.join('\n\n'))); } - if (process.env.CI && messages.warnings.length) { + if (process.env.CI && process.env.CI.toLowerCase() !== 'false' && messages.warnings.length) { console.log( chalk.yellow( '\nTreating warnings as errors because process.env.CI = true.\n' + From 31a4d14b339e769ced0575a566b625fb44196163 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 19 Jun 2017 13:27:02 -0400 Subject: [PATCH 034/265] Fix a potential issue (#2569) --- packages/react-scripts/scripts/build.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index aa95774f5..2e4bc21ee 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -112,7 +112,12 @@ function build(previousFileSizes) { if (messages.errors.length) { return reject(new Error(messages.errors.join('\n\n'))); } - if (process.env.CI && process.env.CI.toLowerCase() !== 'false' && messages.warnings.length) { + if ( + process.env.CI && + (typeof process.env.CI !== 'string' || + process.env.CI.toLowerCase() !== 'false') && + messages.warnings.length + ) { console.log( chalk.yellow( '\nTreating warnings as errors because process.env.CI = true.\n' + From 70e36f04f42a31094ad2739960819d13517a918a Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 23 Jun 2017 17:26:42 +0100 Subject: [PATCH 035/265] Warn about npm 5 in issue template --- .github/ISSUE_TEMPLATE.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 374dbf179..79b79e449 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,21 +1,21 @@ If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely. -### Can you reproduce the problem with latest npm? +### Can you reproduce the problem with npm 4.x? Many errors, especially related to "missing modules", are due to npm bugs. -If you're using Windows, [follow these instructions to update npm](https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows). - -If you're using OS X or Linux, run this to update npm: +Try to update npm to 4.x first: ``` -npm install -g npm@latest +npm install -g npm@4 cd your_project_directory rm -rf node_modules npm install ``` +**This is especially important if `npm -v` gives you 5 because npm 5 is [known to have many issues](https://github.com/npm/npm/issues/16991).** + Then try to reproduce the issue again. Can you still reproduce it? From d468a80f2510dc0542aec7a8b036b94b1a2320b5 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 15:02:42 +0100 Subject: [PATCH 036/265] Update issue & PR templates (#2618) * New issue template * Update PULL_REQUEST_TEMPLATE.md * Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 145 ++++++++++++++++++++++++------- .github/PULL_REQUEST_TEMPLATE.md | 3 +- 2 files changed, 116 insertions(+), 32 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 79b79e449..934d59204 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,59 +1,144 @@ -If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely. + -### Can you reproduce the problem with npm 4.x? +### Is this a bug report? + +(write your answer here) + + -Try to update npm to 4.x first: +### Can you reproduce the problem with npm 4.x? + + -### Description +(Write your answer here.) -What are you reporting? +### Have you read the Troubleshooting section and searched the User Guide? -### Expected behavior + -Tell us what actually happens. +(Write your answer here.) ### Environment -Run these commands in the project folder and fill in their results: + -1. `npm ls react-scripts` (if you haven’t ejected): -2. `node -v`: -3. `npm -v`: +1. `node -v`: +2. `npm -v`: +4. `yarn --version` (if you use Yarn): +3. `npm ls react-scripts` (if you haven’t ejected): Then, specify: 1. Operating system: -2. Browser and version: +2. Browser and version (if relevant): + +### Steps to Reproduce + + + +(Write your steps here:) + +1. +2. +3. + +### Expected Behavior + + + +(Write what you thought would happen.) + +### Actual Behavior + + + +(Write what happened. Add screenshots!) ### Reproducible Demo -Please take the time to create a new app that reproduces the issue. + + +(Paste the link to an example project and exact instructions to reproduce the issue.) + + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 87acf9c2f..45268d0b6 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,8 +1,7 @@ From 4289fcef842c4c73f62d32269c4f969bb8d93509 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 15:08:37 +0100 Subject: [PATCH 037/265] Whitespace --- .github/ISSUE_TEMPLATE.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 934d59204..cc0cefbc9 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,6 +2,8 @@ PLEASE DON'T DELETE THIS TEMPLATE UNTIL YOU HAVE READ THE FIRST SECTION. --> + + ### Is this a bug report? (write your answer here) @@ -19,9 +21,10 @@ Note that we don't provide help for webpack questions after ejecting. You can find webpack docs at https://webpack.js.org/. - Now let's get started! + Now scroll below! --> + ### Can you reproduce the problem with npm 4.x? - ### Is this a bug report? (write your answer here) From de839e9cc5a61d1a9f53e4d6c4a73b1f58241ae6 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 15:10:12 +0100 Subject: [PATCH 039/265] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index c2d24e7ee..feca25d68 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,7 +2,6 @@ PLEASE DON'T DELETE THIS TEMPLATE UNTIL YOU HAVE READ THE FIRST SECTION. --> - ### Is this a bug report? (write your answer here) From 839c7bf6523c142294217eec9fd80660e6eb3b47 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 15:19:16 +0100 Subject: [PATCH 040/265] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index feca25d68..ff7fbb91d 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -60,7 +60,7 @@ Please write the answer below: --> -(Write your answer here.) +(Write the terms you searched for on the User Guide page.) ### Environment From 58ef08f798ecef14902794770ab0a53e5a5af705 Mon Sep 17 00:00:00 2001 From: Mikhail Osher Date: Mon, 26 Jun 2017 18:19:21 +0300 Subject: [PATCH 041/265] Support PhpStorm in launchEditor (#2622) https://www.jetbrains.com/help/webstorm/opening-files-from-command-line.html https://www.jetbrains.com/help/phpstorm/opening-files-from-command-line.html Both editors have the same signature ` --line ` to open file from the command line. It seems to work even if `` is omitted (commit 02f88ba15701f70e613137dd5a3d81caba9d9eb8). Tested on `Win10`+`PhpStorm2016` and `macOS 10.12`+`PhpStorm2017`. --- packages/react-dev-utils/launchEditor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index a1893d13b..0cc170fb6 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -74,6 +74,8 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { ); case 'webstorm': case 'webstorm64': + case 'phpstorm': + case 'phpstorm64': return addWorkspaceToArgumentsIfExists( ['--line', lineNumber, fileName], workspace From 6e2898e5965098ccd3c4e5f06c213ca2e20b3e21 Mon Sep 17 00:00:00 2001 From: Mico Piira Date: Mon, 26 Jun 2017 18:48:21 +0300 Subject: [PATCH 042/265] Add empty mock for dgram (#2600) --- packages/react-scripts/config/webpack.config.dev.js | 1 + packages/react-scripts/config/webpack.config.prod.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 55d3b6ad7..070b05c1e 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -275,6 +275,7 @@ module.exports = { // Some libraries import Node modules but don't use them in the browser. // Tell Webpack to provide empty mocks for them so importing them works. node: { + dgram: 'empty', fs: 'empty', net: 'empty', tls: 'empty', diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 5943c1450..1ee1b2026 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -341,6 +341,7 @@ module.exports = { // Some libraries import Node modules but don't use them in the browser. // Tell Webpack to provide empty mocks for them so importing them works. node: { + dgram: 'empty', fs: 'empty', net: 'empty', tls: 'empty', From 76bd132157e80aee805e039016e2a2ec7f1522cb Mon Sep 17 00:00:00 2001 From: Jay V Date: Mon, 26 Jun 2017 12:28:56 -0400 Subject: [PATCH 043/265] Docs: Added link to tutorial on code splitting (#2427) * Adding link to tutorial on code splitting Link to tutorial on Code Splitting with React Router * Update README.md --- packages/react-scripts/template/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index c4591c183..906c1c6e8 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -377,6 +377,10 @@ This will make `moduleA.js` and all its unique dependencies as a separate chunk You can also use it with `async` / `await` syntax if you prefer it. +### With React Router + +If you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app). + ## Adding a Stylesheet This project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**: From 3e9955ddb633fda66d49d09bd2fc1b2dd714e88f Mon Sep 17 00:00:00 2001 From: Will Farley Date: Mon, 26 Jun 2017 09:29:52 -0700 Subject: [PATCH 044/265] Update sw-precache-webpack-plugin to lastest version (#2429) * Update sw-precache-webpack-plugin to v0.11.3 * Pin the version --- packages/react-scripts/config/webpack.config.prod.js | 3 --- packages/react-scripts/package.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 1ee1b2026..5a3d1a37b 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -327,9 +327,6 @@ module.exports = { navigateFallbackWhitelist: [/^(?!\/__).*/], // Don't precache sourcemaps (they're large) and build asset manifest: staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/], - // Work around Windows path issue in SWPrecacheWebpackPlugin: - // https://github.com/facebookincubator/create-react-app/issues/2235 - stripPrefix: paths.appBuild.replace(/\\/g, '/') + '/', }), // 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/package.json b/packages/react-scripts/package.json index 41ecb0ac4..ad12d6fb6 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -51,7 +51,7 @@ "react-dev-utils": "^3.0.0", "react-error-overlay": "^1.0.7", "style-loader": "0.17.0", - "sw-precache-webpack-plugin": "0.9.1", + "sw-precache-webpack-plugin": "0.11.3", "url-loader": "0.5.8", "webpack": "2.6.1", "webpack-dev-server": "2.4.5", From a7d31d9fa89206e37ac55e5694fbfb3639a84784 Mon Sep 17 00:00:00 2001 From: Jeffrey Posnick Date: Mon, 26 Jun 2017 12:30:43 -0400 Subject: [PATCH 045/265] Determines whether PUBLIC_URL is same-origin before registering SW. (#2432) --- .../react-scripts/template/src/registerServiceWorker.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/react-scripts/template/src/registerServiceWorker.js b/packages/react-scripts/template/src/registerServiceWorker.js index 9966897dc..ad94042e7 100644 --- a/packages/react-scripts/template/src/registerServiceWorker.js +++ b/packages/react-scripts/template/src/registerServiceWorker.js @@ -10,6 +10,15 @@ export default function register() { if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { + // The URL constructor is available in all browsers that support SW. + const publicUrl = new URL(process.env.PUBLIC_URL, window.location); + if (publicUrl.origin !== window.location.origin) { + // Our service worker won't work if PUBLIC_URL is on a different origin + // from what our page is served on. This might happen if a CDN is used to + // serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374 + return; + } + window.addEventListener('load', () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; navigator.serviceWorker From 43d0307bc18bf85e8f091d905040b08c9551bd7e Mon Sep 17 00:00:00 2001 From: Andy Kenward Date: Mon, 26 Jun 2017 17:31:25 +0100 Subject: [PATCH 046/265] webpack no need for `ident` if using complex options anymore (#2430) Since `v2.2.1` of webpack the need for `ident` for complex options is no longer required. See https://webpack.js.org/guides/migrating/#complex-options --- packages/react-scripts/config/webpack.config.dev.js | 1 - packages/react-scripts/config/webpack.config.prod.js | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 070b05c1e..f1f5b0990 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -217,7 +217,6 @@ module.exports = { { loader: require.resolve('postcss-loader'), options: { - ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 5a3d1a37b..01fe96528 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -223,7 +223,6 @@ module.exports = { { loader: require.resolve('postcss-loader'), options: { - ident: 'postcss', // https://webpack.js.org/guides/migrating/#complex-options plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ From c22c8b300762bc1cd21f0995933c0f10cb2d8110 Mon Sep 17 00:00:00 2001 From: Mateusz Zatorski Date: Mon, 26 Jun 2017 17:33:19 +0100 Subject: [PATCH 047/265] add docs for setting up CircleCI for CRA (#2423) * add docs for setting up CircleCI for CRA * Reword --- packages/react-scripts/template/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 906c1c6e8..3ab19b548 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1259,6 +1259,10 @@ script: 1. Trigger your first build with a git push. 1. [Customize your Travis CI Build](https://docs.travis-ci.com/user/customizing-the-build/) if needed. +#### CircleCI + +Follow [this article](https://medium.com/@knowbody/circleci-and-zeits-now-sh-c9b7eebcd3c1) to set up CircleCI with a Create React App project. + ### On your own environment ##### Windows (cmd.exe) From 1f91848d5188ed37766fd3dfc5e2773640baa887 Mon Sep 17 00:00:00 2001 From: Fabrizio Castellarin Date: Mon, 26 Jun 2017 18:34:03 +0200 Subject: [PATCH 048/265] E2E testing enhancements (#2408) * Local testing with docker * Docs on e2e testing * `bash` callback after docker * Add a TL;DR in the CONTRIBUTING section * Local e2e testing with modified files * Remove the N.B. from the README * Fixed a fixme in e2e doc --- CONTRIBUTING.md | 6 + package.json | 1 + .../fixtures/kitchensink/README.md | 52 ++++++++ tasks/local-test.sh | 113 ++++++++++++++++++ 4 files changed, 172 insertions(+) create mode 100644 packages/react-scripts/fixtures/kitchensink/README.md create mode 100755 tasks/local-test.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4e3414be..1c93e310d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,6 +90,12 @@ and then run `npm start` or `npm run build`. *Note: if you are using yarn, we suggest that you use `yarn install --no-lockfile` instead of the bare `yarn` or `yarn install` because we [intentionally](https://github.com/facebookincubator/create-react-app/pull/2014#issuecomment-300811661) do not ignore or add yarn.lock to our repo.* +## Contributing to E2E (end to end) tests + +**TL;DR** use the command yarn e2e:docker to run unit and e2e tests. + +More detailed information are in the dedicated [README](/packages/react-scripts/fixtures/kitchensink/README.md). + ## Cutting a Release 1. Tag all merged pull requests that go into the release with the relevant milestone. Each merged PR should also be labeled with one of the [labels](https://github.com/facebookincubator/create-react-app/labels) named `tag: ...` to indicate what kind of change it is. diff --git a/package.json b/package.json index e6bd7b0c3..d5c7a6c8f 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "changelog": "lerna-changelog", "create-react-app": "tasks/cra.sh", "e2e": "tasks/e2e-simple.sh", + "e2e:docker": "tasks/local-test.sh", "postinstall": "lerna bootstrap && cd packages/react-error-overlay/ && npm run build:prod", "publish": "tasks/release.sh", "start": "node packages/react-scripts/scripts/start.js", diff --git a/packages/react-scripts/fixtures/kitchensink/README.md b/packages/react-scripts/fixtures/kitchensink/README.md new file mode 100644 index 000000000..8d259d56e --- /dev/null +++ b/packages/react-scripts/fixtures/kitchensink/README.md @@ -0,0 +1,52 @@ +# Contributing to Create React App's E2E tests + +This is an end to end kitchensink test suite, but has multiple usages in it. + +## Running the test suite + +Tests are automatically run by the CI tools. +In order to run them locally, without having to manually install and configure everything, the `yarn e2e:docker` CLI command can be used. + +This is a simple script that runs a **Docker** container, where the node version, git branch to clone, test suite, and whether to run it with `yarn` or `npm` can be chosen. +Simply run `yarn e2e:docker -- --help` to get additional info. + +## Writing tests + +Each time a new feature is added, it is advised to add at least one test covering it. + +Features are categorized by their scope: + + - *env*, all those which deal with environment variables (e.g. `NODE_PATH`) + + - *syntax*, all those which showcase a single EcmaScript syntax feature that is expected to be transpiled by **Babel** + + - *webpack*, all those which make use of webpack settings, loaders or plugins + +### Using it as Unit Tests + +In it's most basic for this serve as a collection of unit tests on a single functionality. + +Unit tests are written in a `src/features/**/*.test.js` file located in the same folder as the feature they test, and usually consist of a simple `ReactDOM.render` call. + +These tests are run by **jest** and the environment is `test`, so that it resembles how a **Create React App** application is tested. + +### Using it as Integration Tests + +This suite tests how the single features as before behave while development and in production. +A local HTTP server is started, then every single feature is loaded, one by one, to be tested. + +Test are written in `integration/{env|syntax|webpack}.test.js`, depending on their scope. + +For every test case added there is just a little chore to do: + + - a `case` statement must be added in `src/App.js`, which simply perform a dynamic `import()` of the feature + + - add a test case in the appropriate integration test file, which calls and awaits `initDOM` with the previous `SwitchCase` string + +An usual flow for the test itself is something similar to: + + - add an `id` attribute in a target HTML tag in the feature itself + + - since `initDOM` returns a `Document` element, the previous `id` attribute is used to target the feature's DOM and `expect` accordingly + +These tests are run by **mocha** (why not **jest**? See [this issue](https://github.com/facebook/jest/issues/2288)) and the environments used are both `development` and `production`. diff --git a/tasks/local-test.sh b/tasks/local-test.sh new file mode 100755 index 000000000..42d98ffcd --- /dev/null +++ b/tasks/local-test.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash + +function print_help { + echo "Usage: ${0} [OPTIONS]" + echo "" + echo "OPTIONS:" + echo " --node-version the node version to use while testing [6]" + echo " --git-branch the git branch to checkout for testing [the current one]" + echo " --test-suite which test suite to use ('simple', installs', 'kitchensink', 'all') ['all']" + echo " --yarn if present, use yarn as the package manager" + echo " --interactive gain a bash shell after the test run" + echo " --help print this message and exit" + echo "" +} + +cd $(dirname $0) + +node_version=6 +current_git_branch=`git rev-parse --abbrev-ref HEAD` +git_branch=${current_git_branch} +use_yarn=no +test_suite=all +interactive=false + +while [ "$1" != "" ]; do + case $1 in + "--node-version") + shift + node_version=$1 + ;; + "--git-branch") + shift + git_branch=$1 + ;; + "--yarn") + use_yarn=yes + ;; + "--test-suite") + shift + test_suite=$1 + ;; + "--interactive") + interactive=true + ;; + "--help") + print_help + exit 0 + ;; + esac + shift +done + +test_command="./tasks/e2e-simple.sh && ./tasks/e2e-kitchensink.sh && ./tasks/e2e-installs.sh" +case ${test_suite} in + "all") + ;; + "simple") + test_command="./tasks/e2e-simple.sh" + ;; + "kitchensink") + test_command="./tasks/e2e-kitchensink.sh" + ;; + "installs") + test_command="./tasks/e2e-installs.sh" + ;; + *) + ;; +esac + +read -r -d '' apply_changes <<- CMD +cd /var/create-react-app +git config --global user.name "Create React App" +git config --global user.email "cra@email.com" +git stash save -u +git stash show -p > patch +git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 stash^3 >> patch +git stash pop +cd - +mv /var/create-react-app/patch . +git apply patch +rm patch +CMD + +if [ ${git_branch} != ${current_git_branch} ]; then + apply_changes='' +fi + +read -r -d '' command <<- CMD +echo "prefix=~/.npm" > ~/.npmrc +mkdir ~/.npm +export PATH=\$PATH:~/.npm/bin +set -x +git clone /var/create-react-app create-react-app --branch ${git_branch} +cd create-react-app +${apply_changes} +node --version +npm --version +set +x +${test_command} && echo -e "\n\e[1;32m✔ Job passed\e[0m" || echo -e "\n\e[1;31m✘ Job failes\e[0m" +$([[ ${interactive} == 'true' ]] && echo 'bash') +CMD + +docker run \ + --env CI=true \ + --env NPM_CONFIG_QUIET=true \ + --env USE_YARN=${use_yarn} \ + --tty \ + --user node \ + --volume ${PWD}/..:/var/create-react-app \ + --workdir /home/node \ + $([[ ${interactive} == 'true' ]] && echo '--interactive') \ + node:${node_version} \ + bash -c "${command}" From 7a0fb4c62b65cd1dc54ac831f150a8f948094533 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 17:35:18 +0100 Subject: [PATCH 049/265] Use Babel compact mode in production (#2389) --- packages/react-scripts/config/webpack.config.prod.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 01fe96528..629904297 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -186,12 +186,13 @@ module.exports = { test: /\.(js|jsx)$/, include: paths.appSrc, loader: require.resolve('babel-loader'), - // @remove-on-eject-begin options: { + // @remove-on-eject-begin babelrc: false, presets: [require.resolve('babel-preset-react-app')], + // @remove-on-eject-end + compact: true, }, - // @remove-on-eject-end }, // The notation here is somewhat confusing. // "postcss" loader applies autoprefixer to our CSS. From 41f2013260e082a84c9fdcbd90352113efa62e93 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil Date: Tue, 27 Jun 2017 20:05:15 +0700 Subject: [PATCH 050/265] turn on ascii_only for issue with emoji and regex (#2596) --- packages/react-scripts/config/webpack.config.prod.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 629904297..7b9872c6d 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -290,6 +290,9 @@ module.exports = { }, 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, }, sourceMap: true, }), From 0644e80d36e242c6f2362253930a2b6d64c0849c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20J=C4=99drzejczyk?= Date: Tue, 27 Jun 2017 15:11:14 +0200 Subject: [PATCH 051/265] add check to filter out custom scripts in eject command (#2562) --- packages/react-scripts/scripts/eject.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index c771e075d..d168805c6 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -169,6 +169,9 @@ inquirer Object.keys(appPackage.scripts).forEach(key => { Object.keys(ownPackage.bin).forEach(binKey => { const regex = new RegExp(binKey + ' (\\w+)', 'g'); + if (!regex.test(appPackage.scripts[key])) { + return; + } appPackage.scripts[key] = appPackage.scripts[key].replace( regex, 'node scripts/$1.js' From bed875c83d0eee185da5840b91d0ab0d95937a34 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 27 Jun 2017 15:09:46 +0100 Subject: [PATCH 052/265] Don't run yarn after ejecting (#2634) --- packages/react-scripts/scripts/eject.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index d168805c6..724b9c144 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -220,8 +220,21 @@ inquirer } if (fs.existsSync(paths.yarnLockFile)) { - console.log(cyan('Running yarn...')); - spawnSync('yarnpkg', [], { stdio: 'inherit' }); + // TODO: this is disabled for three reasons. + // + // 1. It produces garbage warnings on Windows on some systems: + // https://github.com/facebookincubator/create-react-app/issues/2030 + // + // 2. For the above reason, it breaks Windows CI: + // https://github.com/facebookincubator/create-react-app/issues/2624 + // + // 3. It is wrong anyway: re-running yarn will respect the lockfile + // rather than package.json we just updated. Instead we should have + // updated the lockfile. So we might as well not do it while it's broken. + // https://github.com/facebookincubator/create-react-app/issues/2627 + // + // console.log(cyan('Running yarn...')); + // spawnSync('yarnpkg', [], { stdio: 'inherit' }); } else { console.log(cyan('Running npm install...')); spawnSync('npm', ['install'], { stdio: 'inherit' }); From 3747144f9a697ae3048d2f974718556f89b2fedf Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 27 Jun 2017 15:39:42 +0100 Subject: [PATCH 053/265] Set npm loglevel to 'error' (#2635) --- packages/create-react-app/createReactApp.js | 8 +++++++- packages/react-scripts/scripts/eject.js | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index b3d0638e9..597a49a97 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -218,7 +218,13 @@ function install(useYarn, dependencies, verbose, isOnline) { } } else { command = 'npm'; - args = ['install', '--save', '--save-exact'].concat(dependencies); + args = [ + 'install', + '--save', + '--save-exact', + '--loglevel', + 'error', + ].concat(dependencies); } if (verbose) { diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 724b9c144..7d9409d0f 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -237,7 +237,9 @@ inquirer // spawnSync('yarnpkg', [], { stdio: 'inherit' }); } else { console.log(cyan('Running npm install...')); - spawnSync('npm', ['install'], { stdio: 'inherit' }); + spawnSync('npm', ['install', '--loglevel', 'error'], { + stdio: 'inherit', + }); } console.log(green('Ejected successfully!')); console.log(); From 2874e1209e14c7bff6c51fa3d73a53c5a15944cf Mon Sep 17 00:00:00 2001 From: Levin Rickert Date: Tue, 27 Jun 2017 17:16:02 +0200 Subject: [PATCH 054/265] Auto-detect running editor on Windows for error overlay (#2552) * Auto-detect running editor on Windows for error overlay * Ignore process output if powershell call fails * Support Notepad++ --- packages/react-dev-utils/launchEditor.js | 73 +++++++++++++++++------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index 0cc170fb6..5622c1c12 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -8,12 +8,12 @@ */ 'use strict'; -var fs = require('fs'); -var path = require('path'); -var child_process = require('child_process'); -var os = require('os'); -var chalk = require('chalk'); -var shellQuote = require('shell-quote'); +const fs = require('fs'); +const path = require('path'); +const child_process = require('child_process'); +const os = require('os'); +const chalk = require('chalk'); +const shellQuote = require('shell-quote'); function isTerminalEditor(editor) { switch (editor) { @@ -28,7 +28,7 @@ function isTerminalEditor(editor) { // Map from full process name to binary that starts the process // We can't just re-use full process name, because it will spawn a new instance // of the app every time -var COMMON_EDITORS = { +const COMMON_EDITORS_OSX = { '/Applications/Atom.app/Contents/MacOS/Atom': 'atom', '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta': '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta', '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text': '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', @@ -36,6 +36,13 @@ var COMMON_EDITORS = { '/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code', }; +const COMMON_EDITORS_WIN = [ + 'Code.exe', + 'atom.exe', + 'sublime_text.exe', + 'notepad++.exe', +]; + function addWorkspaceToArgumentsIfExists(args, workspace) { if (workspace) { args.unshift(workspace); @@ -44,7 +51,7 @@ function addWorkspaceToArgumentsIfExists(args, workspace) { } function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { - var editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, ''); + const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, ''); switch (editorBasename) { case 'vim': case 'mvim': @@ -54,11 +61,14 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { case 'Atom Beta': case 'subl': case 'sublime': + case 'sublime_text': case 'wstorm': case 'appcode': case 'charm': case 'idea': return [fileName + ':' + lineNumber]; + case 'notepad++': + return ['-n' + lineNumber, fileName]; case 'joe': case 'emacs': case 'emacsclient': @@ -68,6 +78,7 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { case 'mine': return ['--line', lineNumber, fileName]; case 'code': + case 'Code': return addWorkspaceToArgumentsIfExists( ['-g', fileName + ':' + lineNumber], workspace @@ -94,21 +105,41 @@ function guessEditor() { return shellQuote.parse(process.env.REACT_EDITOR); } - // Using `ps x` on OSX we can find out which editor is currently running. - // Potentially we could use similar technique for Windows and Linux - if (process.platform === 'darwin') { - try { - var output = child_process.execSync('ps x').toString(); - var processNames = Object.keys(COMMON_EDITORS); - for (var i = 0; i < processNames.length; i++) { - var processName = processNames[i]; + // Using `ps x` on OSX or `Get-Process` on Windows we can find out which editor is currently running. + // Potentially we could use similar technique for Linux + try { + if (process.platform === 'darwin') { + const output = child_process.execSync('ps x').toString(); + const processNames = Object.keys(COMMON_EDITORS_OSX); + for (let i = 0; i < processNames.length; i++) { + const processName = processNames[i]; if (output.indexOf(processName) !== -1) { - return [COMMON_EDITORS[processName]]; + return [COMMON_EDITORS_OSX[processName]]; + } + } + } else if (process.platform === 'win32') { + const output = child_process + .execSync('powershell -Command "Get-Process | Select-Object Path"', { + stdio: ['pipe', 'pipe', 'ignore'], + }) + .toString(); + const runningProcesses = output.split('\r\n'); + for (let i = 0; i < runningProcesses.length; i++) { + // `Get-Process` sometimes returns empty lines + if (!runningProcesses[i]) { + continue; + } + + const fullProcessPath = runningProcesses[i].trim(); + const shortProcessName = path.basename(fullProcessPath); + + if (COMMON_EDITORS_WIN.indexOf(shortProcessName) !== -1) { + return [fullProcessPath]; } } - } catch (error) { - // Ignore... } + } catch (error) { + // Ignore... } // Last resort, use old skool env vars @@ -146,7 +177,7 @@ function printInstructions(fileName, errorMessage) { console.log(); } -var _childProcess = null; +let _childProcess = null; function launchEditor(fileName, lineNumber) { if (!fs.existsSync(fileName)) { return; @@ -178,7 +209,7 @@ function launchEditor(fileName, lineNumber) { fileName = path.relative('', fileName); } - var workspace = null; + let workspace = null; if (lineNumber) { args = args.concat( getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) From 6a09ed1e6e2a31c545cd469e83f0dc860d11e4e6 Mon Sep 17 00:00:00 2001 From: Marius Wirtherle Date: Tue, 27 Jun 2017 17:30:26 +0200 Subject: [PATCH 055/265] docs: added REACT_EDITOR to `Advanced Configuration` section (#2445) * docs: added REACT_EDITOR to `Advanced Configuration` section * Update README.md * Update launchEditor.js --- packages/react-dev-utils/launchEditor.js | 3 ++- packages/react-scripts/template/README.md | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index 5622c1c12..dcdf4fee4 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -172,7 +172,8 @@ function printInstructions(fileName, errorMessage) { ' to the ' + chalk.green('.env.local') + ' file in your project folder ' + - 'and restart the development server.' + 'and restart the development server. Learn more: ' + + chalk.green('https://goo.gl/MMTaZt') ); console.log(); } diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 3ab19b548..ed431c9e1 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1826,6 +1826,7 @@ PORT | :white_check_mark: | :x: | By default, the development web server will at HTTPS | :white_check_mark: | :x: | When set to `true`, Create React App will run the development server in `https` mode. PUBLIC_URL | :x: | :white_check_mark: | Create React App assumes your application is hosted at the serving web server's root or a subpath as specified in [`package.json` (`homepage`)](#building-for-relative-paths). Normally, Create React App ignores the hostname. You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). This may be particularly useful when using a CDN to host your application. CI | :large_orange_diamond: | :white_check_mark: | When set to `true`, Create React App treats warnings as failures in the build. It also makes the test runner non-watching. Most CIs set this flag by default. +REACT_EDITOR | :white_check_mark: | :x: | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebookincubator/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable points to your editor’s bin folder. ## Troubleshooting From a9ac78996b9bfb58c19a90ad86c5ff5f8715ca34 Mon Sep 17 00:00:00 2001 From: Daniel Ciao Date: Tue, 27 Jun 2017 08:55:28 -0700 Subject: [PATCH 056/265] Fix sourcemap directory organizing on Windows (#2456) (#2610) * Fix sourcemap directory organizing on Windows * Update comments --- packages/react-scripts/config/webpack.config.dev.js | 4 ++-- packages/react-scripts/config/webpack.config.prod.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index f1f5b0990..44b5f5c4f 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -77,9 +77,9 @@ module.exports = { chunkFilename: 'static/js/[name].chunk.js', // This is the URL that app is served from. We use "/" in development. publicPath: publicPath, - // Point sourcemap entries to original disk location + // Point sourcemap entries to original disk location (format as URL on Windows) devtoolModuleFilenameTemplate: info => - path.resolve(info.absoluteResourcePath), + path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'), }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 7b9872c6d..50ad12052 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -75,9 +75,9 @@ module.exports = { chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js', // We inferred the "public path" (such as / or /my-project) from homepage. publicPath: publicPath, - // Point sourcemap entries to original disk location + // Point sourcemap entries to original disk location (format as URL on Windows) devtoolModuleFilenameTemplate: info => - path.relative(paths.appSrc, info.absoluteResourcePath), + path.relative(paths.appSrc, info.absoluteResourcePath).replace(/\\/g, '/'), }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. From 78dbf7bf2b50a35c426e5dbbfdf20ef1afcd8789 Mon Sep 17 00:00:00 2001 From: Ro Savage Date: Wed, 28 Jun 2017 02:07:38 +1000 Subject: [PATCH 057/265] Add simplified service worker invalidation (#2551) * Add service worker invalidation * Update valid service worker check only on local host --- .../template/src/registerServiceWorker.js | 100 +++++++++++++----- 1 file changed, 74 insertions(+), 26 deletions(-) diff --git a/packages/react-scripts/template/src/registerServiceWorker.js b/packages/react-scripts/template/src/registerServiceWorker.js index ad94042e7..4a3ccf021 100644 --- a/packages/react-scripts/template/src/registerServiceWorker.js +++ b/packages/react-scripts/template/src/registerServiceWorker.js @@ -8,6 +8,16 @@ // To learn more about the benefits of this model, read https://goo.gl/KwvDNy. // This link also includes instructions on opting out of this behavior. +const isLocalhost = Boolean( + window.location.hostname === 'localhost' || + // [::1] is the IPv6 localhost address. + window.location.hostname === '[::1]' || + // 127.0.0.1/8 is considered localhost for IPv4. + window.location.hostname.match( + /^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/ + ) +); + export default function register() { if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) { // The URL constructor is available in all browsers that support SW. @@ -21,36 +31,74 @@ export default function register() { window.addEventListener('load', () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; - navigator.serviceWorker - .register(swUrl) - .then(registration => { - registration.onupdatefound = () => { - const installingWorker = registration.installing; - installingWorker.onstatechange = () => { - if (installingWorker.state === 'installed') { - if (navigator.serviceWorker.controller) { - // At this point, the old content will have been purged and - // the fresh content will have been added to the cache. - // It's the perfect time to display a "New content is - // available; please refresh." message in your web app. - console.log('New content is available; please refresh.'); - } else { - // At this point, everything has been precached. - // It's the perfect time to display a - // "Content is cached for offline use." message. - console.log('Content is cached for offline use.'); - } - } - }; - }; - }) - .catch(error => { - console.error('Error during service worker registration:', error); - }); + + if (!isLocalhost) { + // Is not local host. Just register service worker + registerValidSW(swUrl); + } else { + // This is running on localhost. Lets check if a service worker still exists or not. + checkValidServiceWorker(swUrl); + } }); } } +function registerValidSW(swUrl) { + navigator.serviceWorker + .register(swUrl) + .then(registration => { + registration.onupdatefound = () => { + const installingWorker = registration.installing; + installingWorker.onstatechange = () => { + if (installingWorker.state === 'installed') { + if (navigator.serviceWorker.controller) { + // At this point, the old content will have been purged and + // the fresh content will have been added to the cache. + // It's the perfect time to display a "New content is + // available; please refresh." message in your web app. + console.log('New content is available; please refresh.'); + } else { + // At this point, everything has been precached. + // It's the perfect time to display a + // "Content is cached for offline use." message. + console.log('Content is cached for offline use.'); + } + } + }; + }; + }) + .catch(error => { + console.error('Error during service worker registration:', error); + }); +} + +function checkValidServiceWorker(swUrl) { + // Check if the service worker can be found. If it can't reload the page. + fetch(swUrl) + .then(response => { + // Ensure service worker exists, and that we really are getting a JS file. + if ( + response.status === 404 || + response.headers.get('content-type').indexOf('javascript') === -1 + ) { + // No service worker found. Probably a different app. Reload the page. + navigator.serviceWorker.ready.then(registration => { + registration.unregister().then(() => { + window.location.reload(); + }); + }); + } else { + // Service worker found. Proceed as normal. + registerValidSW(swUrl); + } + }) + .catch(() => { + console.log( + 'No internet connection found. App is running in offline mode.' + ); + }); +} + export function unregister() { if ('serviceWorker' in navigator) { navigator.serviceWorker.ready.then(registration => { From 77993e73d0e06a7a90e3331b70c51de08c2b5ace Mon Sep 17 00:00:00 2001 From: Brian Douglas Date: Tue, 27 Jun 2017 17:16:59 +0100 Subject: [PATCH 058/265] Add yarn example under "Installing a Dependency" (#2362) Due to many of the other examples in the README showing both `npm` and `yarn` commands. I have added an example of how to install a dependency using `yarn`. --- packages/react-scripts/template/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index ed431c9e1..9191e5da5 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -281,6 +281,12 @@ The generated project includes React and ReactDOM as dependencies. It also inclu npm install --save ``` +Alternatively you may also use `yarn`: + +``` +yarn add +``` + ## Importing a Component This project setup supports ES6 modules thanks to Babel.
From 0ed6c8d6fdb405200ab7fc7ed625d00f915a614a Mon Sep 17 00:00:00 2001 From: James Blight Date: Wed, 28 Jun 2017 01:51:51 +0930 Subject: [PATCH 059/265] Update docs with WebSocket proxy information (#2305) * Update docs with WebSocket proxy information * Tweak wording --- packages/react-scripts/template/README.md | 31 +++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 9191e5da5..d84fa9590 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -44,6 +44,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Proxying API Requests in Development](#proxying-api-requests-in-development) - ["Invalid Host Header" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy) - [Configuring the Proxy Manually](#configuring-the-proxy-manually) + - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy) - [Using HTTPS in Development](#using-https-in-development) - [Generating Dynamic `` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) - [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files) @@ -992,6 +993,36 @@ You may also narrow down matches using `*` and/or `**`, to match the path exactl } ``` +### Configuring a WebSocket Proxy + +When setting up a WebSocket proxy, there are a some extra considerations to be aware of. + +If you’re using a WebSocket engine like [Socket.io](https://socket.io/), you must have a Socket.io server running that you can use as the proxy target. Socket.io will not work with a standard WebSocket server. Specifically, don't expect Socket.io to work with [the websocket.org echo test](http://websocket.org/echo.html). + +There’s some good documentation available for [setting up a Socket.io server](https://socket.io/docs/). + +Standard WebSockets **will** work with a standard WebSocket server as well as the websocket.org echo test. You can use libraries like [ws](https://github.com/websockets/ws) for the server, with [native WebSockets in the browser](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket). + +Either way, you can proxy WebSocket requests manually in `package.json`: + +```js +{ + // ... + "proxy": { + "/socket": { + // Your compatible WebSocket server + "target": "ws://", + // Tell http-proxy-middleware that this is a WebSocket proxy. + // Also allows you to proxy WebSocket requests without an additional HTTP request + // https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade + "ws": true + // ... + } + } + // ... +} +``` + ## Using HTTPS in Development >Note: this feature is available with `react-scripts@0.4.0` and higher. From 117d82b28d58e7064ecaad0ad0b82b7f278a728d Mon Sep 17 00:00:00 2001 From: Gabriel Aumala Date: Tue, 27 Jun 2017 18:26:54 +0200 Subject: [PATCH 060/265] Add more info about OOM build failiure [docs] (#2060) In the section about npm run build fails in troubleshooting added more info about memory usage of the build script and a link to a tutorial for adding more swap space as a viable solution. --- packages/react-scripts/template/README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index d84fa9590..402828129 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -84,7 +84,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Troubleshooting](#troubleshooting) - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes) - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) - - [`npm run build` silently fails](#npm-run-build-silently-fails) + - [`npm run build` exits too early](#npm-run-build-exits-too-early) - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) - [Moment.js locales are missing](#momentjs-locales-are-missing) - [Something Missing?](#something-missing) @@ -1905,9 +1905,13 @@ If this still doesn’t help, try running `launchctl unload -F ~/Library/LaunchA There are also reports that *uninstalling* Watchman fixes the issue. So if nothing else helps, remove it from your system and try again. -### `npm run build` silently fails +### `npm run build` exits too early -It is reported that `npm run build` can fail on machines with no swap space, which is common in cloud environments. If [the symptoms are matching](https://github.com/facebookincubator/create-react-app/issues/1133#issuecomment-264612171), consider adding some swap space to the machine you’re building on, or build the project locally. +It is reported that `npm run build` can fail on machines with limited memory and no swap space, which is common in cloud environments. Even with small projects this command can increase RAM usage in your system by hundreds of megabytes, so if you have less than 1 GB of available memory your build is likely to fail with the following message: + +> The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process. + +If you are completely sure that you didn't terminate the process, consider [adding some swap space](https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04) to the machine you’re building on, or build the project locally. ### `npm run build` fails on Heroku From 60691e6b1c378e6876104abd39e38d052cb6f775 Mon Sep 17 00:00:00 2001 From: Heng Li Date: Tue, 27 Jun 2017 09:32:51 -0700 Subject: [PATCH 061/265] Update README.md (#1813) --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 402828129..3edaec5ce 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -139,7 +139,7 @@ For the project to build, **these files must exist with exact filenames**: You can delete or rename the other files. You may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.
-You need to **put any JS and CSS files inside `src`**, or Webpack won’t see them. +You need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them. Only files inside `public` can be used from `public/index.html`.
Read instructions below for using assets from JavaScript and HTML. From b4b3d02e6b9f087fc0e00e9c6f413d3d9c184f81 Mon Sep 17 00:00:00 2001 From: Colin Eberhardt Date: Tue, 27 Jun 2017 17:40:38 +0100 Subject: [PATCH 062/265] Fix CLI grammar (#1945) I know this is a very minor thing, but correct grammar makes it easier to understand. --- packages/create-react-app/createReactApp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 597a49a97..93bb9ab6e 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -256,7 +256,7 @@ function run( const packageToInstall = getInstallPackage(version); const allDependencies = ['react', 'react-dom', packageToInstall]; - console.log('Installing packages. This might take a couple minutes.'); + console.log('Installing packages. This might take a couple of minutes.'); getPackageName(packageToInstall) .then(packageName => checkIfOnline(useYarn).then(isOnline => ({ isOnline: isOnline, From 5474e2dff9414557b597cd97f6f08186d4c809dc Mon Sep 17 00:00:00 2001 From: Maarten Hus Date: Tue, 27 Jun 2017 18:51:58 +0200 Subject: [PATCH 063/265] Added instruction on how to install Prettier (#2006) * Added instruction on how to install Prettier * Tweak style * Update README.md * Update README.md * Support JSX * Update README.md * Update README.md --- README.md | 1 + packages/react-scripts/template/README.md | 54 +++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/README.md b/README.md index 06a2fbf4d..969d03110 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast - [Supported Language Features and Polyfills](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-language-features-and-polyfills) - [Syntax Highlighting in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#syntax-highlighting-in-the-editor) - [Displaying Lint Output in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor) +- [Formatting Code Automatically](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#formatting-code-automatically) - [Debugging in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#debugging-in-the-editor) - [Changing the Page ``](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#changing-the-page-title) - [Installing a Dependency](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#installing-a-dependency) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 3edaec5ce..c54858b03 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -17,6 +17,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor) - [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor) - [Debugging in the Editor](#debugging-in-the-editor) +- [Formatting Code Automatically](#formatting-code-automatically) - [Changing the Page `<title>`](#changing-the-page-title) - [Installing a Dependency](#installing-a-dependency) - [Importing a Component](#importing-a-component) @@ -264,6 +265,59 @@ Then add the block below to your `launch.json` file and put it inside the `.vsco Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. +## Formatting Code Automatically + +Prettier is an opinionated JavaScript formatter. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). + +To format our code whenever we make a commit in git, we need to install the following dependencies: + +``` +npm install --save-dev husky lint-staged prettier +``` + +or if you use Yarn: + +``` +yarn add --dev husky lint-staged prettier +``` + +* `husky` makes it easy to use githooks as if they are npm scripts. +* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8). +* `prettier` is the JavaScript formatter we will run before commits. + +Now we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root. + +Add the following line to `scripts` section: + +```js +{ + // ... + "scripts": { + // ... + "precommit": "lint-staged" + }, + // ... +} +``` + +Next we add a 'lint-staged' field to the `package.json`, for example: + +```js +{ + // ... + "lint-staged": { + "src/**/*.{js,jsx}": [ + "prettier --single-quote --write", + "git add" + ] + } +} +``` + +Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx}"` to format your entire project for the first time. + +Next you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://github.com/prettier/prettier#editor-integration) on the Prettier GitHub page. + ## Changing the Page `<title>` You can find the source HTML file in the `public` folder of the generated project. You may edit the `<title>` tag in it to change the title from “React App” to anything else. From 0b6c7ffc9ed63522e89b81d30e8593dc00f9baf7 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Tue, 27 Jun 2017 18:15:02 +0100 Subject: [PATCH 064/265] Less passive-aggressive issue template --- .github/ISSUE_TEMPLATE.md | 56 ++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index ff7fbb91d..c24c81a70 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,5 +1,5 @@ <!-- - PLEASE DON'T DELETE THIS TEMPLATE UNTIL YOU HAVE READ THE FIRST SECTION. + PLEASE READ THE FIRST SECTION :-) --> ### Is this a bug report? @@ -8,18 +8,20 @@ <!-- If you answered "Yes": + + Please note that your issue will be fixed much faster if you spend about + half an hour preparing it, including the exact reproduction steps and a demo. + + If you're in a hurry or don't feel confident, it's fine to report bugs with + less details, but this makes it less likely they'll get fixed soon. - We expect that it will take you about 30 minutes to produce a high-quality bug report. - While this may seem like a lot, putting care into issues helps us fix them faster. - For bug reports, it is REQUIRED to fill the rest of this template, or the issue will be closed. + In either case, please fill as many fields below as you can. If you answered "No": If this is a question or a discussion, you may delete this template and write in a free form. Note that we don't provide help for webpack questions after ejecting. You can find webpack docs at https://webpack.js.org/. - - Now scroll below! --> @@ -42,25 +44,30 @@ Then try to reproduce the issue again. Can you still reproduce it? - Note: Please try this even if you are using Yarn. Yarn also has bugs. + Note: Please try this even if you are using Yarn so that we know whether it's a Yarn-only bug. --> (Write your answer here.) -### Have you read the Troubleshooting section and searched the User Guide? +### Which terms did you search for in User Guide? <!-- - There are a few common documented problems, such as watcher not detecting changes. + There are a few common documented problems, such as watcher not detecting changes, or build failing. They are described in the Troubleshooting section of the User Guide: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#troubleshooting - Have you read that section, and have you searched the User Guide for symptoms of your problem? - Please write the answer below: + Please scan these few sections for common problems. + Additionally, you can search the User Guide itself for something you're having issues with: + + https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.me + + If you didn't find the solution, please share which words you searched for. + This helps us improve documentation for future readers who might encounter the same problem. --> -(Write the terms you searched for on the User Guide page.) +(Write your answer here if relevant.) ### Environment @@ -110,16 +117,18 @@ Then, specify: <!-- Did something go wrong? Is something broken, or not behaving as you expected? - Describe this section in detail, and attach screenshots if possible. + Please attach screenshots if possible! They are extremely helpful for diagnosing issues. --> -(Write what happened. Add screenshots!) +(Write what happened. Please add screenshots!) ### Reproducible Demo <!-- - Please share a project that reproduces the issue. + If you can, please share a project that reproduces the issue. + This is the single most effective way to get an issue fixed soon. + There are two ways to do it: * Create a new app and try to reproduce the issue in it. @@ -136,16 +145,13 @@ Then, specify: <!-- What happens if you skip this step? - - Someone will read your bug report, and maybe will be able to help you, - but it’s unlikely that it will get much attention from the team. Eventually, - the issue will likely get closed in favor of issues that have reproducible demos. - - Please remember that: - - * Issues without reproducible demos have a very low priority. - * The person fixing the bug would have to do that anyway. Please be respectful of their time. - * You might figure out the issues yourself as you work on extracting it. + + We will try to help you, but in many cases it is impossible because crucial + information is missing. In that case we'll tag an issue as having a low priority, + and eventually close it if there is no clear direction. + + We still appreciate the report though, as eventually somebody else might + create a reproducible example for it. Thanks for helping us help you! --> From 4edec9e83463439ccaa723061a8b05aa68d3513d Mon Sep 17 00:00:00 2001 From: shaun wallace <sjwallace116@gmail.com> Date: Tue, 27 Jun 2017 18:21:16 +0100 Subject: [PATCH 065/265] Updated README (#1931) * adding comment on windows support of nvm * adding tree structure for intial project output * applying feedback from this thread create-react-app/pull/1931 --- README.md | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 969d03110..544aa12dd 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Install it once globally: npm install -g create-react-app ``` -**You’ll need to have Node >= 6 on your machine**. You can use [nvm](https://github.com/creationix/nvm#usage) to easily switch Node versions between different projects. +**You’ll need to have Node >= 6 on your machine**. You can use [nvm](https://github.com/creationix/nvm#installation) to easily switch Node versions between different projects. **This tool doesn’t assume a Node backend**. The Node installation is only required for Create React App itself. @@ -57,23 +57,23 @@ It will create a directory called `my-app` inside the current folder.<br> Inside that directory, it will generate the initial project structure and install the transitive dependencies: ``` -my-app/ - README.md - node_modules/ - package.json - .gitignore - public/ - favicon.ico - index.html - manifest.json - src/ - App.css - App.js - App.test.js - index.css - index.js - logo.svg - registerServiceWorker.js +my-app +├── README.md +├── node_modules +├── package.json +├── .gitignore +├── public +│ └── favicon.ico +│ └── index.html +│ └── manifest.json +└── src + └── App.css + └── App.js + └── App.test.js + └── index.css + └── index.js + └── logo.svg + └── registerServiceWorker.js ``` No configuration or complicated folder structures, just the files you need to build your app.<br> From 84299ceb23feea0b1943af6dfa82328360898e9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pete=20Nyk=C3=A4nen?= <pete.a.nykanen@gmail.com> Date: Tue, 27 Jun 2017 23:46:59 +0300 Subject: [PATCH 066/265] Add Brackets to launchEditor.js (#2637) --- packages/react-dev-utils/launchEditor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index dcdf4fee4..7ed4ad190 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -31,12 +31,14 @@ function isTerminalEditor(editor) { const COMMON_EDITORS_OSX = { '/Applications/Atom.app/Contents/MacOS/Atom': 'atom', '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta': '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta', + '/Applications/Brackets.app/Contents/MacOS/Brackets': 'brackets', '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text': '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', '/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2': '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', '/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code', }; const COMMON_EDITORS_WIN = [ + 'Brackets.exe', 'Code.exe', 'atom.exe', 'sublime_text.exe', From 8dfc630c58b78575554638bcbc746d6bfecd3837 Mon Sep 17 00:00:00 2001 From: Ashton <me@ashtonwar.com> Date: Tue, 27 Jun 2017 21:47:36 +0100 Subject: [PATCH 067/265] Update ISSUE_TEMPLATE.md (#2643) Adding the word "also" to "Can you also reproduce the problem with npm 4.x?" clarifies that contributors aren't _expected_ to use NPM v4, but we're interested in understanding which environments the reported issue affects. --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index c24c81a70..d494cdd02 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -25,7 +25,7 @@ --> -### Can you reproduce the problem with npm 4.x? +### Can you also reproduce the problem with npm 4.x? <!-- Many errors, especially related to "missing modules", are due to npm bugs. From 12a2e42a9465758150d5bbbf37c3d615ab20ce59 Mon Sep 17 00:00:00 2001 From: Artem Sapegin <artem@sapegin.ru> Date: Tue, 27 Jun 2017 22:52:30 +0200 Subject: [PATCH 068/265] Add React Styleguidist (#2044) --- README.md | 1 + packages/react-scripts/template/README.md | 46 +++++++++++++++++++++-- 2 files changed, 43 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 544aa12dd..296925aa6 100644 --- a/README.md +++ b/README.md @@ -138,6 +138,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast - [Generating Dynamic `<meta>` Tags on the Server](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server) - [Pre-Rendering into Static HTML Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#pre-rendering-into-static-html-files) - [Running Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests) +- [Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation) - [Making a Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) - [Deployment](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment) - [Advanced Configuration](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index c54858b03..158f553d5 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -64,6 +64,9 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Disabling jsdom](#disabling-jsdom) - [Snapshot Testing](#snapshot-testing) - [Editor Integration](#editor-integration) +- [Developing Components in Isolation](#developing-components-in-isolation) + - [Getting Started with Storybook](#getting-started-with-storybook) + - [Getting Started with Styleguidist](#getting-started-with-styleguidist) - [Making a Progressive Web App](#making-a-progressive-web-app) - [Offline-First Considerations](#offline-first-considerations) - [Progressive Web App Metadata](#progressive-web-app-metadata) @@ -1431,14 +1434,15 @@ For an example, a simple button component could have following states: Usually, it’s hard to see these states without running a sample app or some examples. -Create React App doesn’t include any tools for this by default, but you can easily add [Storybook for React](https://storybook.js.org) ([source](https://github.com/storybooks/storybook)) to your project. **It is a third-party tool that lets you develop components and see all their states in isolation from your app**. +Create React App doesn’t include any tools for this by default, but you can easily add [Storybook for React](https://storybook.js.org) ([source](https://github.com/storybooks/storybook)) or [React Styleguidist](https://react-styleguidist.js.org/) ([source](https://github.com/styleguidist/react-styleguidist)) to your project. **These are third-party tools that let you develop components and see all their states in isolation from your app**. ![Storybook for React Demo](http://i.imgur.com/7CIAWpB.gif) -A storybook can also be deployed as a static app. -This way, everyone in your team can view and review different states of UI components without starting a backend server or creating an account in your app. +You can also deploy your Storybook or style guide as a static app. This way, everyone in your team can view and review different states of UI components without starting a backend server or creating an account in your app. -### Setup your app with Storybook +### Getting Started with Storybook + +Storybook is a development environment for React UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components. First, install the following npm package globally: @@ -1461,6 +1465,40 @@ Learn more about React Storybook: * [Documentation](https://storybook.js.org/basics/introduction/) * [Snapshot Testing UI](https://github.com/storybooks/storybook/tree/master/addons/storyshots) with Storybook + addon/storyshot +### Getting Started with Styleguidist + +Styleguidist combines of a style guide, where all your components are presented on a single page with their props documentation and usage examples, with an environment for developing components in isolation, similar to Storybook. In Styleguidist you write examples in Markdown, where each code snippet is rendered as a live editable playground. + +First install Styleguidist and peer dependencies from npm: + +```sh +npm install --save-dev react-styleguidist webpack +``` + +Then, add these scripts to your `package.json`: + +```sh +{ + "scripts": { + "styleguide": "styleguidist server", + "styleguide:build": "styleguidist build" + } +} +``` + +Then, run the following command inside your app’s directory: + +```sh +npm run styleguide +``` + +After that, follow the instructions on the screen. + +Learn more about React Styleguidist: + +* [GitHub Repo](https://github.com/styleguidist/react-styleguidist) +* [Documentation](https://react-styleguidist.js.org/docs/getting-started.html) + ## Making a Progressive Web App By default, the production build is a fully functional, offline-first From 91064a1c7fc80efefb3733d30f0c3e7715ed3c67 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Tue, 27 Jun 2017 22:28:00 +0100 Subject: [PATCH 069/265] Ignore "Skipping static resource" message from SW precache (#2645) --- packages/react-scripts/config/webpack.config.prod.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 50ad12052..e7995d8f7 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -77,7 +77,9 @@ module.exports = { publicPath: publicPath, // Point sourcemap entries to original disk location (format as URL on Windows) devtoolModuleFilenameTemplate: info => - path.relative(paths.appSrc, info.absoluteResourcePath).replace(/\\/g, '/'), + path + .relative(paths.appSrc, info.absoluteResourcePath) + .replace(/\\/g, '/'), }, resolve: { // This allows you to set a fallback for where Webpack should look for modules. @@ -320,6 +322,11 @@ module.exports = { // This message occurs for every build and is a bit too noisy. return; } + if (message.indexOf('Skipping static resource') === 0) { + // This message obscures real errors so we ignore it. + // https://github.com/facebookincubator/create-react-app/issues/2612 + return; + } console.log(message); }, minify: true, From a4197b610e0db8c94ec36d9764f671aba9a80e0f Mon Sep 17 00:00:00 2001 From: Colin Galindo <galindo.colin@gmail.com> Date: Tue, 27 Jun 2017 16:40:33 -0500 Subject: [PATCH 070/265] Add instructions to use source-map-explorer (#1641) --- README.md | 1 + packages/react-scripts/template/README.md | 32 +++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/README.md b/README.md index 296925aa6..1197d7b4a 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast - [Running Tests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#running-tests) - [Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation) - [Making a Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) +- [Analyzing the Bundle Size](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#analyzing-the-bundle-size) - [Deployment](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#deployment) - [Advanced Configuration](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#advanced-configuration) - [Troubleshooting](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#troubleshooting) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 158f553d5..e30a4405d 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -70,6 +70,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Making a Progressive Web App](#making-a-progressive-web-app) - [Offline-First Considerations](#offline-first-considerations) - [Progressive Web App Metadata](#progressive-web-app-metadata) +- [Analyzing the Bundle Size](#analyzing-the-bundle-size) - [Deployment](#deployment) - [Static Server](#static-server) - [Other Solutions](#other-solutions) @@ -1599,6 +1600,37 @@ icons, names, and branding colors to use when the web app is displayed. provides more context about what each field means, and how your customizations will affect your users' experience. +## Analyzing the Bundle Size + +[Source map explorer](https://www.npmjs.com/package/source-map-explorer) analyzes +JavaScript bundles using the source maps. This helps you understand where code +bloat is coming from. + +To add Source map explorer to a Create React App project, follow these steps: + +``` +npm install source-map-explorer --save-dev +``` + +Then in `package.json`, add the following line to `scripts` +On Windows you will have to type the full file path out. + +```diff + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test --env=jsdom", ++ "analyze": "source-map-explorer build/static/js/main.* " +``` + +Then to analyze the bundle run the production build then run the analyze +script. + +``` +npm run build +npm run analyze +``` + ## Deployment `npm run build` creates a `build` directory with a production build of your app. Set up your favourite HTTP server so that a visitor to your site is served `index.html`, and requests to static paths like `/static/js/main.<hash>.js` are served with the contents of the `/static/js/main.<hash>.js` file. From 7cf4de71fad6d5654dc6a2875f3d2cb2da5b9e20 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 00:00:49 +0100 Subject: [PATCH 071/265] Warn about large bundle sizes (#2648) --- packages/react-dev-utils/FileSizeReporter.js | 35 ++++++++++++++++++-- packages/react-scripts/scripts/build.js | 12 ++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js index 8f822d201..0ec62333b 100644 --- a/packages/react-dev-utils/FileSizeReporter.js +++ b/packages/react-dev-utils/FileSizeReporter.js @@ -18,7 +18,13 @@ var stripAnsi = require('strip-ansi'); var gzipSize = require('gzip-size').sync; // Prints a detailed summary of build files. -function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder) { +function printFileSizesAfterBuild( + webpackStats, + previousSizeMap, + buildFolder, + maxBundleGzipSize, + maxChunkGzipSize +) { var root = previousSizeMap.root; var sizes = previousSizeMap.sizes; var assets = webpackStats @@ -41,6 +47,7 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder) { null, assets.map(a => stripAnsi(a.sizeLabel).length) ); + var suggestBundleSplitting = false; assets.forEach(asset => { var sizeLabel = asset.sizeLabel; var sizeLength = stripAnsi(sizeLabel).length; @@ -48,14 +55,38 @@ function printFileSizesAfterBuild(webpackStats, previousSizeMap, buildFolder) { var rightPadding = ' '.repeat(longestSizeLabelLength - sizeLength); sizeLabel += rightPadding; } + var isMainBundle = asset.name.indexOf('main.') === 0; + var maxRecommendedSize = isMainBundle + ? maxBundleGzipSize + : maxChunkGzipSize; + var isLarge = maxRecommendedSize && asset.size > maxRecommendedSize; + if (isLarge && path.extname(asset.name) === '.js') { + suggestBundleSplitting = true; + } console.log( ' ' + - sizeLabel + + (isLarge ? chalk.yellow(sizeLabel) : sizeLabel) + ' ' + chalk.dim(asset.folder + path.sep) + chalk.cyan(asset.name) ); }); + if (suggestBundleSplitting) { + console.log(); + console.log( + chalk.yellow('The bundle size is significantly larger than recommended.') + ); + console.log( + chalk.yellow( + 'Consider reducing it with code splitting: https://goo.gl/9VhYWB' + ) + ); + console.log( + chalk.yellow( + 'You can also analyze the project dependencies: https://goo.gl/LeUzfb' + ) + ); + } } function removeFileNameHash(buildFolder, fileName) { diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 2e4bc21ee..06eb0695d 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -39,6 +39,10 @@ const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; const useYarn = fs.existsSync(paths.yarnLockFile); +// These sizes are pretty large. We'll warn for bundles exceeding them. +const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024; +const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024; + // Warn and crash if required files are missing if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { process.exit(1); @@ -76,7 +80,13 @@ measureFileSizesBeforeBuild(paths.appBuild) } console.log('File sizes after gzip:\n'); - printFileSizesAfterBuild(stats, previousFileSizes, paths.appBuild); + printFileSizesAfterBuild( + stats, + previousFileSizes, + paths.appBuild, + WARN_AFTER_BUNDLE_GZIP_SIZE, + WARN_AFTER_CHUNK_GZIP_SIZE + ); console.log(); const appPackage = require(paths.appPackageJson); From 4605e6c38a28c4aba3a87a18a7c439967050cdf1 Mon Sep 17 00:00:00 2001 From: Erik Engi <kireerike@gmail.com> Date: Wed, 28 Jun 2017 01:10:18 +0200 Subject: [PATCH 072/265] Razzle added to the alternatives (#2517) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1197d7b4a..0c428ef65 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,7 @@ Some of the more popular and actively maintained ones are: * [insin/nwb](https://github.com/insin/nwb) * [mozilla-neutrino/neutrino-dev](https://github.com/mozilla-neutrino/neutrino-dev) +* [jaredpalmer/razzle](https://github.com/jaredpalmer/razzle) * [NYTimes/kyt](https://github.com/NYTimes/kyt) * [zeit/next.js](https://github.com/zeit/next.js) * [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby) From 9559ba486e085b6956580ebbc6dad1d7ef4c26e2 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 14:04:26 +0100 Subject: [PATCH 073/265] Put react-scripts in dependencies, not devDependencies (#2657) * Put react-scripts in dependencies, not devDependencies * Sort dependencies on eject * Remove CI check --- packages/create-react-app/createReactApp.js | 21 +++++--------------- packages/react-scripts/scripts/eject.js | 22 +++++++++++++++------ packages/react-scripts/scripts/init.js | 1 - tasks/e2e-installs.sh | 9 --------- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 93bb9ab6e..74b121689 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -276,11 +276,7 @@ function run( }) .then(packageName => { checkNodeVersion(packageName); - - // Since react-scripts has been installed with --save - // we need to move it into devDependencies and rewrite package.json - // also ensure react dependencies have caret version range - fixDependencies(packageName); + setCaretRangeForRuntimeDeps(packageName); const scriptsPath = path.resolve( process.cwd(), @@ -497,16 +493,14 @@ function checkAppName(appName) { } // TODO: there should be a single place that holds the dependencies - const dependencies = ['react', 'react-dom']; - const devDependencies = ['react-scripts']; - const allDependencies = dependencies.concat(devDependencies).sort(); - if (allDependencies.indexOf(appName) >= 0) { + const dependencies = ['react', 'react-dom', 'react-scripts'].sort(); + if (dependencies.indexOf(appName) >= 0) { console.error( chalk.red( `We cannot create a project called ${chalk.green(appName)} because a dependency with the same name exists.\n` + `Due to the way npm works, the following names are not allowed:\n\n` ) + - chalk.cyan(allDependencies.map(depName => ` ${depName}`).join('\n')) + + chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) + chalk.red('\n\nPlease choose a different project name.') ); process.exit(1); @@ -533,7 +527,7 @@ function makeCaretRange(dependencies, name) { dependencies[name] = patchedVersion; } -function fixDependencies(packageName) { +function setCaretRangeForRuntimeDeps(packageName) { const packagePath = path.join(process.cwd(), 'package.json'); const packageJson = require(packagePath); @@ -543,16 +537,11 @@ function fixDependencies(packageName) { } const packageVersion = packageJson.dependencies[packageName]; - if (typeof packageVersion === 'undefined') { console.error(chalk.red(`Unable to find ${packageName} in package.json`)); process.exit(1); } - packageJson.devDependencies = packageJson.devDependencies || {}; - packageJson.devDependencies[packageName] = packageVersion; - delete packageJson.dependencies[packageName]; - makeCaretRange(packageJson.dependencies, 'react'); makeCaretRange(packageJson.dependencies, 'react-dom'); diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 7d9409d0f..265511860 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -146,24 +146,34 @@ inquirer console.log(cyan('Updating the dependencies')); const ownPackageName = ownPackage.name; - if (appPackage.devDependencies[ownPackageName]) { - console.log(` Removing ${cyan(ownPackageName)} from devDependencies`); - delete appPackage.devDependencies[ownPackageName]; + if (appPackage.devDependencies) { + // We used to put react-scripts in devDependencies + if (appPackage.devDependencies[ownPackageName]) { + console.log(` Removing ${cyan(ownPackageName)} from devDependencies`); + delete appPackage.devDependencies[ownPackageName]; + } } + appPackage.dependencies = appPackage.dependencies || {}; if (appPackage.dependencies[ownPackageName]) { console.log(` Removing ${cyan(ownPackageName)} from dependencies`); delete appPackage.dependencies[ownPackageName]; } - Object.keys(ownPackage.dependencies).forEach(key => { // For some reason optionalDependencies end up in dependencies after install if (ownPackage.optionalDependencies[key]) { return; } - console.log(` Adding ${cyan(key)} to devDependencies`); - appPackage.devDependencies[key] = ownPackage.dependencies[key]; + console.log(` Adding ${cyan(key)} to dependencies`); + appPackage.dependencies[key] = ownPackage.dependencies[key]; + }); + // Sort the deps + const unsortedDependencies = appPackage.dependencies; + appPackage.dependencies = {}; + Object.keys(unsortedDependencies).sort().forEach(key => { + appPackage.dependencies[key] = unsortedDependencies[key]; }); console.log(); + console.log(cyan('Updating the scripts')); delete appPackage.scripts['eject']; Object.keys(appPackage.scripts).forEach(key => { diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index a50704d1c..93e5b449a 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -39,7 +39,6 @@ module.exports = function( // Copy over some of the devDependencies appPackage.dependencies = appPackage.dependencies || {}; - appPackage.devDependencies = appPackage.devDependencies || {}; // Setup the script rules appPackage.scripts = { diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 8f4789ff0..7ea70fac6 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -55,15 +55,6 @@ function checkDependencies { echo "There are extraneous dependencies in package.json" exit 1 fi - - - if ! awk '/"devDependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \ - grep -v -q -E '^\s*"react(-dom|-scripts)?"'; then - echo "Dev Dependencies are correct" - else - echo "There are extraneous devDependencies in package.json" - exit 1 - fi } function create_react_app { From c578d148b76a465cce14e5c6921f7642b9de31e4 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 14:27:52 +0100 Subject: [PATCH 074/265] Don't ask to install webpack for using Styleguidist (#2656) * Don't ask to install webpack for using Styleguidist * Update README.md --- packages/react-scripts/template/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index e30a4405d..24821e3fc 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1470,10 +1470,10 @@ Learn more about React Storybook: Styleguidist combines of a style guide, where all your components are presented on a single page with their props documentation and usage examples, with an environment for developing components in isolation, similar to Storybook. In Styleguidist you write examples in Markdown, where each code snippet is rendered as a live editable playground. -First install Styleguidist and peer dependencies from npm: +First, install Styleguidist: ```sh -npm install --save-dev react-styleguidist webpack +npm install --save-dev react-styleguidist ``` Then, add these scripts to your `package.json`: From 0cebe046e1187b37ae6f0d838d5cd5a8c5504c27 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 15:05:12 +0100 Subject: [PATCH 075/265] Minor code style edits to user guide (#2660) * Minor code style edits to user guide * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md --- packages/react-scripts/template/README.md | 187 +++++++++++++++------- 1 file changed, 125 insertions(+), 62 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 24821e3fc..aa2ab4340 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -275,14 +275,14 @@ Prettier is an opinionated JavaScript formatter. With Prettier you can format th To format our code whenever we make a commit in git, we need to install the following dependencies: -``` -npm install --save-dev husky lint-staged prettier +```sh +npm install --save husky lint-staged prettier ``` -or if you use Yarn: +Alternatively you may use `yarn`: -``` -yarn add --dev husky lint-staged prettier +```sh +yarn add husky lint-staged prettier ``` * `husky` makes it easy to use githooks as if they are npm scripts. @@ -293,29 +293,26 @@ Now we can make sure every file is formatted correctly by adding a few lines to Add the following line to `scripts` section: -```js -{ - // ... +```diff "scripts": { - // ... - "precommit": "lint-staged" - }, - // ... -} ++ "precommit": "lint-staged", + "start": "react-scripts start", + "build": "react-scripts build", ``` Next we add a 'lint-staged' field to the `package.json`, for example: -```js -{ - // ... - "lint-staged": { - "src/**/*.{js,jsx}": [ - "prettier --single-quote --write", - "git add" - ] - } -} +```diff + "dependencies": { + // ... + }, ++ "lint-staged": { ++ "src/**/*.{js,jsx}": [ ++ "prettier --single-quote --write", ++ "git add" ++ ] ++ }, + "scripts": { ``` Now, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write "src/**/*.{js,jsx}"` to format your entire project for the first time. @@ -336,15 +333,17 @@ If you use a custom server for your app in production and want to modify the tit The generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`: -``` -npm install --save <library-name> +```sh +npm install --save react-router ``` -Alternatively you may also use `yarn`: +Alternatively you may use `yarn`: +```sh +yarn add react-router ``` -yarn add <library-name> -``` + +This works for any library, not just `react-router`. ## Importing a Component @@ -519,9 +518,16 @@ Following this rule often makes CSS preprocessors less useful, as features like First, let’s install the command-line interface for Sass: +```sh +npm install --save node-sass-chokidar ``` -npm install node-sass-chokidar --save-dev + +Alternatively you may use `yarn`: + +```sh +yarn add node-sass-chokidar ``` + Then in `package.json`, add the following lines to `scripts`: ```diff @@ -557,8 +563,14 @@ At this point you might want to remove all CSS files from the source control, an As a final step, you may find it convenient to run `watch-css` automatically with `npm start`, and run `build-css` as a part of `npm run build`. You can use the `&&` operator to execute two scripts sequentially. However, there is no cross-platform way to run two scripts in parallel, so we will install a package for this: +```sh +npm install --save npm-run-all ``` -npm install --save-dev npm-run-all + +Alternatively you may use `yarn`: + +```sh +yarn add npm-run-all ``` Then we can change `start` and `build` scripts to include the CSS preprocessor commands: @@ -716,9 +728,14 @@ You don’t have to use [React Bootstrap](https://react-bootstrap.github.io) tog Install React Bootstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well: +```sh +npm install --save react-bootstrap bootstrap@3 ``` -npm install react-bootstrap --save -npm install bootstrap@3 --save + +Alternatively you may use `yarn`: + +```sh +yarn add react-bootstrap bootstrap@3 ``` Import Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your ```src/index.js``` file: @@ -757,7 +774,7 @@ Recent versions of [Flow](http://flowtype.org/) work with Create React App proje To add Flow to a Create React App project, follow these steps: -1. Run `npm install --save-dev flow-bin` (or `yarn add --dev flow-bin`). +1. Run `npm install --save flow-bin` (or `yarn add flow-bin`). 2. Add `"flow": "flow"` to the `scripts` section of your `package.json`. 3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory. 4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`). @@ -1226,12 +1243,20 @@ This test mounts a component and makes sure that it didn’t throw during render When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. -If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). You can write a smoke test with it too: +If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: + +```sh +npm install --save enzyme react-test-renderer +``` + +Alternatively you may use `yarn`: ```sh -npm install --save-dev enzyme react-test-renderer +yarn add enzyme react-test-renderer ``` +You can write a smoke test with it too: + ```js import React from 'react'; import { shallow } from 'enzyme'; @@ -1270,18 +1295,24 @@ Additionally, you might find [jest-enzyme](https://github.com/blainekasten/enzym expect(wrapper).toContainReact(welcome) ``` -To setup jest-enzyme with Create React App, follow the instructions for [initializing your test environment](#initializing-test-environment) to import `jest-enzyme`. +To enable this, install `jest-enzyme`: + +```sh +npm install --save jest-enzyme +``` + +Alternatively you may use `yarn`: ```sh -npm install --save-dev jest-enzyme +yarn add jest-enzyme ``` +Import it in [`src/setupTests.js`](#initializing-test-environment) to make its matchers available in every test: + ```js -// src/setupTests.js import 'jest-enzyme'; ``` - ### Using Third Party Assertion Libraries We recommend that you use `expect()` for assertions and `jest.fn()` for spies. If you are having issues with them please [file those against Jest](https://github.com/facebook/jest/issues/new), and we’ll fix them. We intend to keep making them better for React, supporting, for example, [pretty-printing React elements as JSX](https://github.com/facebook/jest/pull/1566). @@ -1392,14 +1423,22 @@ The build command will check for linter warnings and fail if any are found. By default, the `package.json` of the generated project looks like this: ```js - // ... "scripts": { - // ... + "start": "react-scripts start", + "build": "react-scripts build", "test": "react-scripts test --env=jsdom" - } ``` -If you know that none of your tests depend on [jsdom](https://github.com/tmpvar/jsdom), you can safely remove `--env=jsdom`, and your tests will run faster.<br> +If you know that none of your tests depend on [jsdom](https://github.com/tmpvar/jsdom), you can safely remove `--env=jsdom`, and your tests will run faster: + +```diff + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", +- "test": "react-scripts test --env=jsdom" ++ "test": "react-scripts test" +``` + To help you make up your mind, here is a list of APIs that **need jsdom**: * Any browser globals like `window` and `document` @@ -1473,18 +1512,22 @@ Styleguidist combines of a style guide, where all your components are presented First, install Styleguidist: ```sh -npm install --save-dev react-styleguidist +npm install --save react-styleguidist ``` -Then, add these scripts to your `package.json`: +Alternatively you may use `yarn`: ```sh -{ - "scripts": { - "styleguide": "styleguidist server", - "styleguide:build": "styleguidist build" - } -} +yarn add react-styleguidist +``` + +Then, add these scripts to your `package.json`: + +```diff + "scripts": { ++ "styleguide": "styleguidist server", ++ "styleguide:build": "styleguidist build", + "start": "react-scripts start", ``` Then, run the following command inside your app’s directory: @@ -1608,21 +1651,36 @@ bloat is coming from. To add Source map explorer to a Create React App project, follow these steps: +```sh +npm install --save source-map-explorer ``` -npm install source-map-explorer --save-dev + +Alternatively you may use `yarn`: + +```sh +yarn add source-map-explorer ``` -Then in `package.json`, add the following line to `scripts` -On Windows you will have to type the full file path out. +Then in `package.json`, add the following line to `scripts`: ```diff "scripts": { ++ "analyze": "source-map-explorer build/static/js/main.*", "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test --env=jsdom", -+ "analyze": "source-map-explorer build/static/js/main.* " ``` +>**Note:** +> +>This doesn't quite work on Windows because it doesn't automatically expand `*` in the filepath. For now, the workaround is to look at the full hashed filename in `build/static/js` (e.g. `main.89b7e95a.js`) and copy it into `package.json` when you're running the analyzer. For example: +> +>```diff +>+ "analyze": "source-map-explorer build/static/js/main.89b7e95a.js", +>``` +> +>Unfortunately it will be different after every build. You can express support for fixing this on Windows [in this issue](https://github.com/danvk/source-map-explorer/issues/52). + Then to analyze the bundle run the production build then run the analyze script. @@ -1827,18 +1885,23 @@ Now, whenever you run `npm run build`, you will see a cheat sheet with instructi To publish it at [https://myusername.github.io/my-app](https://myusername.github.io/my-app), run: ```sh -npm install --save-dev gh-pages +npm install --save gh-pages +``` + +Alternatively you may use `yarn`: + +```sh +yarn add gh-pages ``` Add the following scripts in your `package.json`: -```js - // ... +```diff "scripts": { - // ... - "predeploy": "npm run build", - "deploy": "gh-pages -d build" - } ++ "predeploy": "npm run build", ++ "deploy": "gh-pages -d build", + "start": "react-scripts start", + "build": "react-scripts build", ``` The `predeploy` script will run automatically before `deploy` is run. From 16e5d15e922e488ebe914b77c25a9e95df5b954f Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 15:05:30 +0100 Subject: [PATCH 076/265] Bump dependencies (#2658) --- packages/babel-preset-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 10 +++---- packages/react-scripts/package.json | 28 ++++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 175b7b129..f56a804ea 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -21,7 +21,7 @@ "babel-plugin-transform-react-jsx-source": "6.22.0", "babel-plugin-transform-regenerator": "6.24.1", "babel-plugin-transform-runtime": "6.23.0", - "babel-preset-env": "1.4.0", + "babel-preset-env": "1.5.2", "babel-preset-react": "6.24.1" }, "peerDependencies": { diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 6fa6c4117..75b39399e 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -33,8 +33,8 @@ "webpackHotDevClient.js" ], "dependencies": { - "address": "1.0.1", - "anser": "1.3.0", + "address": "1.0.2", + "anser": "1.4.1", "babel-code-frame": "6.22.0", "chalk": "1.1.3", "cross-spawn": "4.0.2", @@ -43,13 +43,13 @@ "filesize": "3.3.0", "gzip-size": "3.0.0", "html-entities": "1.2.1", - "inquirer": "3.0.6", + "inquirer": "3.1.1", "is-root": "1.0.0", - "opn": "5.0.0", + "opn": "5.1.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", - "strip-ansi": "3.0.1", + "strip-ansi": "4.0.0", "text-table": "0.2.0" } } diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index ad12d6fb6..c441460aa 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -21,40 +21,40 @@ "react-scripts": "./bin/react-scripts.js" }, "dependencies": { - "autoprefixer": "7.1.0", - "babel-core": "6.24.1", + "autoprefixer": "7.1.1", + "babel-core": "6.25.0", "babel-eslint": "7.2.3", "babel-jest": "20.0.3", "babel-loader": "7.0.0", "babel-preset-react-app": "^3.0.0", "babel-runtime": "6.23.0", - "case-sensitive-paths-webpack-plugin": "1.1.4", + "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", - "css-loader": "0.28.1", + "css-loader": "0.28.4", "dotenv": "4.0.0", "eslint": "3.19.0", "eslint-config-react-app": "^1.0.4", "eslint-loader": "1.7.1", - "eslint-plugin-flowtype": "2.33.0", + "eslint-plugin-flowtype": "2.34.0", "eslint-plugin-import": "2.2.0", "eslint-plugin-jsx-a11y": "5.0.3", - "eslint-plugin-react": "7.0.1", - "extract-text-webpack-plugin": "2.1.0", - "file-loader": "0.11.1", + "eslint-plugin-react": "7.1.0", + "extract-text-webpack-plugin": "2.1.2", + "file-loader": "0.11.2", "fs-extra": "3.0.1", - "html-webpack-plugin": "2.28.0", - "jest": "20.0.3", + "html-webpack-plugin": "2.29.0", + "jest": "20.0.4", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.0.0", - "postcss-loader": "2.0.5", + "postcss-loader": "2.0.6", "promise": "7.1.1", "react-dev-utils": "^3.0.0", "react-error-overlay": "^1.0.7", - "style-loader": "0.17.0", + "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.3", - "url-loader": "0.5.8", + "url-loader": "0.5.9", "webpack": "2.6.1", - "webpack-dev-server": "2.4.5", + "webpack-dev-server": "2.5.0", "webpack-manifest-plugin": "1.1.0", "whatwg-fetch": "2.0.3" }, From 6ab0ec00751315353a5d42d55c17d527631dbd2d Mon Sep 17 00:00:00 2001 From: Evan Jones <evanjones4040@gmail.com> Date: Wed, 28 Jun 2017 07:29:58 -0700 Subject: [PATCH 077/265] Better React Native Web support (#2511) * Better React Native Web support * Adding better react-native-web support for jest testing --- packages/react-scripts/config/webpack.config.dev.js | 4 +++- packages/react-scripts/config/webpack.config.prod.js | 4 +++- packages/react-scripts/scripts/utils/createJestConfig.js | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 44b5f5c4f..7536b1389 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -94,7 +94,9 @@ module.exports = { // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: // https://github.com/facebookincubator/create-react-app/issues/290 - extensions: ['.js', '.json', '.jsx'], + // `web` extension prefixes have been added for better support + // for React Native Web. + extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'], alias: { // @remove-on-eject-begin // Resolve Babel runtime relative to react-scripts. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index e7995d8f7..f31fd3ebf 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -94,7 +94,9 @@ module.exports = { // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: // https://github.com/facebookincubator/create-react-app/issues/290 - extensions: ['.js', '.json', '.jsx'], + // `web` extension prefixes have been added for better support + // for React Native Web. + extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'], alias: { // @remove-on-eject-begin // Resolve Babel runtime relative to react-scripts. diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 13ae8b304..de74958ef 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -43,6 +43,7 @@ module.exports = (resolve, rootDir, isEjecting) => { moduleNameMapper: { '^react-native$': 'react-native-web', }, + moduleFileExtensions: ['web.js', 'js', 'json', 'web.jsx', 'jsx'], }; if (rootDir) { config.rootDir = rootDir; From 60ae2b6d4cb633dca46effa30178c15944d18601 Mon Sep 17 00:00:00 2001 From: Fabrizio Castellarin <f.castellarin@gmail.com> Date: Wed, 28 Jun 2017 17:01:08 +0200 Subject: [PATCH 078/265] Local testing docker links (#2662) * Fix a command style in docs * Add a link to docker's docs --- CONTRIBUTING.md | 2 +- packages/react-scripts/fixtures/kitchensink/README.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1c93e310d..68a9c4e09 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -92,7 +92,7 @@ and then run `npm start` or `npm run build`. ## Contributing to E2E (end to end) tests -**TL;DR** use the command yarn e2e:docker to run unit and e2e tests. +**TL;DR** use the command `yarn e2e:docker` to run unit and e2e tests. More detailed information are in the dedicated [README](/packages/react-scripts/fixtures/kitchensink/README.md). diff --git a/packages/react-scripts/fixtures/kitchensink/README.md b/packages/react-scripts/fixtures/kitchensink/README.md index 8d259d56e..4e7725ce1 100644 --- a/packages/react-scripts/fixtures/kitchensink/README.md +++ b/packages/react-scripts/fixtures/kitchensink/README.md @@ -10,6 +10,8 @@ In order to run them locally, without having to manually install and configure e This is a simple script that runs a **Docker** container, where the node version, git branch to clone, test suite, and whether to run it with `yarn` or `npm` can be chosen. Simply run `yarn e2e:docker -- --help` to get additional info. +If you need guidance installing **Docker**, you should follow their [official docs](https://docs.docker.com/engine/installation/). + ## Writing tests Each time a new feature is added, it is advised to add at least one test covering it. From f947669ff72bb399561f43dd13133c088f6a7a17 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 16:18:47 +0100 Subject: [PATCH 079/265] Update ISSUE_TEMPLATE.md --- .github/ISSUE_TEMPLATE.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index d494cdd02..eec13d075 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -33,6 +33,9 @@ npm -v + If it is 5.x, please be aware that it has more than 50 known bugs, and + is not guaranteed to work with Create React App. + If it's not starting with 4, try to install npm 4.x: npm install -g npm@4 From 29c8733ec46f86527e31f74f1decdd34c11b6305 Mon Sep 17 00:00:00 2001 From: Ian Schmitz <ianschmitz@gmail.com> Date: Wed, 28 Jun 2017 08:19:42 -0700 Subject: [PATCH 080/265] Update Prettier to v1 (#2465) * Update Prettier to v1 * Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d5c7a6c8f..0cef9dc02 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "lerna": "2.0.0-beta.38", "lerna-changelog": "^0.2.3", "lint-staged": "^3.3.1", - "prettier": "^0.21.0" + "prettier": "^1.5.2" }, "lint-staged": { "*.js": [ From a171d930641f513279b1c7ceaab1fa9bbbbbb896 Mon Sep 17 00:00:00 2001 From: Dan Abramov <gaearon@fb.com> Date: Wed, 28 Jun 2017 16:23:16 +0100 Subject: [PATCH 081/265] Reformat source code with Prettier 1.5.2 --- packages/create-react-app/createReactApp.js | 46 +++++--- packages/eslint-config-react-app/index.js | 3 +- packages/react-dev-utils/FileSizeReporter.js | 15 ++- packages/react-dev-utils/ModuleScopePlugin.js | 21 ++-- .../react-dev-utils/WebpackDevServerUtils.js | 99 +++++++++-------- packages/react-dev-utils/ansiHTML.js | 3 +- packages/react-dev-utils/eslintFormatter.js | 3 +- packages/react-dev-utils/launchEditor.js | 9 +- packages/react-dev-utils/openBrowser.js | 3 +- .../printHostingInstructions.js | 40 +++++-- .../react-dev-utils/webpackHotDevClient.js | 9 +- .../src/__tests__/mapper.js | 9 +- .../src/components/frame.js | 14 +-- .../src/components/overlay.js | 5 +- .../src/utils/isInternalFile.js | 6 +- .../react-error-overlay/src/utils/unmapper.js | 3 +- packages/react-scripts/config/env.js | 11 +- packages/react-scripts/config/paths.js | 7 +- .../config/webpackDevServer.config.js | 4 +- .../kitchensink/integration/env.test.js | 7 +- .../kitchensink/integration/initDOM.js | 48 +++++---- .../fixtures/kitchensink/src/App.js | 101 ++++++++++-------- .../src/features/env/FileEnvVariables.js | 12 ++- .../kitchensink/src/features/env/NodePath.js | 6 +- .../kitchensink/src/features/env/PublicUrl.js | 7 +- .../src/features/env/ShellEnvVariables.js | 5 +- .../src/features/syntax/ArrayDestructuring.js | 6 +- .../src/features/syntax/ArraySpread.js | 6 +- .../src/features/syntax/AsyncAwait.js | 6 +- .../src/features/syntax/ClassProperties.js | 6 +- .../src/features/syntax/ComputedProperties.js | 8 +- .../features/syntax/CustomInterpolation.js | 8 +- .../src/features/syntax/DefaultParameters.js | 6 +- .../features/syntax/DestructuringAndAwait.js | 6 +- .../src/features/syntax/Generators.js | 6 +- .../features/syntax/ObjectDestructuring.js | 6 +- .../src/features/syntax/ObjectSpread.js | 8 +- .../src/features/syntax/Promises.js | 6 +- .../src/features/syntax/RestAndDefault.js | 6 +- .../src/features/syntax/RestParameters.js | 6 +- .../features/syntax/TemplateInterpolation.js | 6 +- .../src/features/webpack/ImageInclusion.js | 5 +- .../src/features/webpack/JsonInclusion.js | 5 +- .../src/features/webpack/LinkedModules.js | 6 +- .../src/features/webpack/NoExtInclusion.js | 7 +- .../features/webpack/UnknownExtInclusion.js | 7 +- packages/react-scripts/scripts/build.js | 3 +- packages/react-scripts/scripts/eject.js | 52 ++++----- packages/react-scripts/scripts/init.js | 13 ++- 49 files changed, 420 insertions(+), 270 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 74b121689..9dc7b4ff3 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -74,10 +74,14 @@ const program = new commander.Command(packageJson.name) ); console.log(` - a specific npm version: ${chalk.green('0.8.2')}`); console.log( - ` - a custom fork published on npm: ${chalk.green('my-react-scripts')}` + ` - a custom fork published on npm: ${chalk.green( + 'my-react-scripts' + )}` ); console.log( - ` - a .tgz archive: ${chalk.green('https://mysite.com/my-react-scripts-0.8.2.tgz')}` + ` - a .tgz archive: ${chalk.green( + 'https://mysite.com/my-react-scripts-0.8.2.tgz' + )}` ); console.log( ` It is not needed unless you specifically want to use a fork.` @@ -87,7 +91,9 @@ const program = new commander.Command(packageJson.name) ` If you have any problems, do not hesitate to file an issue:` ); console.log( - ` ${chalk.cyan('https://github.com/facebookincubator/create-react-app/issues/new')}` + ` ${chalk.cyan( + 'https://github.com/facebookincubator/create-react-app/issues/new' + )}` ); console.log(); }) @@ -258,15 +264,19 @@ function run( console.log('Installing packages. This might take a couple of minutes.'); getPackageName(packageToInstall) - .then(packageName => checkIfOnline(useYarn).then(isOnline => ({ - isOnline: isOnline, - packageName: packageName, - }))) + .then(packageName => + checkIfOnline(useYarn).then(isOnline => ({ + isOnline: isOnline, + packageName: packageName, + })) + ) .then(info => { const isOnline = info.isOnline; const packageName = info.packageName; console.log( - `Installing ${chalk.cyan('react')}, ${chalk.cyan('react-dom')}, and ${chalk.cyan(packageName)}...` + `Installing ${chalk.cyan('react')}, ${chalk.cyan( + 'react-dom' + )}, and ${chalk.cyan(packageName)}...` ); console.log(); @@ -334,7 +344,9 @@ function run( if (!remainingFiles.length) { // Delete target folder if empty console.log( - `Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan(path.resolve(root, '..'))}` + `Deleting ${chalk.cyan(`${appName} /`)} from ${chalk.cyan( + path.resolve(root, '..') + )}` ); process.chdir(path.resolve(root, '..')); fs.removeSync(path.join(root)); @@ -422,7 +434,9 @@ function getPackageName(installPackage) { /^.+\/(.+?)(?:-\d+.+)?\.tgz$/ )[1]; console.log( - `Based on the filename, assuming it is "${chalk.cyan(assumedProjectName)}"` + `Based on the filename, assuming it is "${chalk.cyan( + assumedProjectName + )}"` ); return Promise.resolve(assumedProjectName); }); @@ -485,7 +499,9 @@ function checkAppName(appName) { const validationResult = validateProjectName(appName); if (!validationResult.validForNewPackages) { console.error( - `Could not create a project called ${chalk.red(`"${appName}"`)} because of npm naming restrictions:` + `Could not create a project called ${chalk.red( + `"${appName}"` + )} because of npm naming restrictions:` ); printValidationResults(validationResult.errors); printValidationResults(validationResult.warnings); @@ -497,7 +513,9 @@ function checkAppName(appName) { if (dependencies.indexOf(appName) >= 0) { console.error( chalk.red( - `We cannot create a project called ${chalk.green(appName)} because a dependency with the same name exists.\n` + + `We cannot create a project called ${chalk.green( + appName + )} because a dependency with the same name exists.\n` + `Due to the way npm works, the following names are not allowed:\n\n` ) + chalk.cyan(dependencies.map(depName => ` ${depName}`).join('\n')) + @@ -519,7 +537,9 @@ function makeCaretRange(dependencies, name) { if (!semver.validRange(patchedVersion)) { console.error( - `Unable to patch ${name} dependency version because version ${chalk.red(version)} will become invalid ${chalk.red(patchedVersion)}` + `Unable to patch ${name} dependency version because version ${chalk.red( + version + )} will become invalid ${chalk.red(patchedVersion)}` ); patchedVersion = version; } diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 2cbcae04c..7298a8c3b 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -236,7 +236,8 @@ module.exports = { { object: 'System', property: 'import', - message: 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting', + message: + 'Please use import() instead. More info: https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#code-splitting', }, ], diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js index 0ec62333b..ab9a27287 100644 --- a/packages/react-dev-utils/FileSizeReporter.js +++ b/packages/react-dev-utils/FileSizeReporter.js @@ -119,15 +119,12 @@ function measureFileSizesBeforeBuild(buildFolder) { if (!err && fileNames) { sizes = fileNames .filter(fileName => /\.(js|css)$/.test(fileName)) - .reduce( - (memo, fileName) => { - var contents = fs.readFileSync(fileName); - var key = removeFileNameHash(buildFolder, fileName); - memo[key] = gzipSize(contents); - return memo; - }, - {} - ); + .reduce((memo, fileName) => { + var contents = fs.readFileSync(fileName); + var key = removeFileNameHash(buildFolder, fileName); + memo[key] = gzipSize(contents); + return memo; + }, {}); } resolve({ root: buildFolder, diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js index adc9bdcba..f630a0279 100644 --- a/packages/react-dev-utils/ModuleScopePlugin.js +++ b/packages/react-dev-utils/ModuleScopePlugin.js @@ -37,10 +37,7 @@ class ModuleScopePlugin { // Maybe an indexOf === 0 would be better? const relative = path.relative(appSrc, request.context.issuer); // If it's not in src/ or a subdirectory, not our request! - if ( - relative.startsWith('../') || - relative.startsWith('..\\') - ) { + if (relative.startsWith('../') || relative.startsWith('..\\')) { return callback(); } // Find path from src to the requested file @@ -58,9 +55,19 @@ class ModuleScopePlugin { ) { callback( new Error( - `You attempted to import ${chalk.cyan(request.__innerRequest_request)} which falls outside of the project ${chalk.cyan('src/')} directory. ` + - `Relative imports outside of ${chalk.cyan('src/')} are not supported. ` + - `You can either move it inside ${chalk.cyan('src/')}, or add a symlink to it from project's ${chalk.cyan('node_modules/')}.` + `You attempted to import ${chalk.cyan( + request.__innerRequest_request + )} which falls outside of the project ${chalk.cyan( + 'src/' + )} directory. ` + + `Relative imports outside of ${chalk.cyan( + 'src/' + )} are not supported. ` + + `You can either move it inside ${chalk.cyan( + 'src/' + )}, or add a symlink to it from project's ${chalk.cyan( + 'node_modules/' + )}.` ), request ); diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 648fef3e1..8a66b15ec 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -37,18 +37,20 @@ if (isSmokeTest) { } function prepareUrls(protocol, host, port) { - const formatUrl = hostname => url.format({ - protocol, - hostname, - port, - pathname: '/', - }); - const prettyPrintUrl = hostname => url.format({ - protocol, - hostname, - port: chalk.bold(port), - pathname: '/', - }); + const formatUrl = hostname => + url.format({ + protocol, + hostname, + port, + pathname: '/', + }); + const prettyPrintUrl = hostname => + url.format({ + protocol, + hostname, + port: chalk.bold(port), + pathname: '/', + }); const isUnspecifiedHost = host === '0.0.0.0' || host === '::'; let prettyHost, lanUrlForConfig, lanUrlForTerminal; @@ -317,9 +319,11 @@ function prepareProxy(proxy, appPublicFolder) { // However API calls like `fetch()` won’t generally accept text/html. // If this heuristic doesn’t work well for you, use a custom `proxy` object. context: function(pathname, req) { - return mayProxy(pathname) && + return ( + mayProxy(pathname) && req.headers.accept && - req.headers.accept.indexOf('text/html') === -1; + req.headers.accept.indexOf('text/html') === -1 + ); }, onProxyReq: proxyReq => { // Browers may send Origin headers even with same-origin @@ -375,39 +379,40 @@ function prepareProxy(proxy, appPublicFolder) { function choosePort(host, defaultPort) { return detect(defaultPort, host).then( - port => new Promise(resolve => { - if (port === defaultPort) { - return resolve(port); - } - const message = process.platform !== 'win32' && - defaultPort < 1024 && - !isRoot() - ? `Admin permissions are required to run a server on a port below 1024.` - : `Something is already running on port ${defaultPort}.`; - if (isInteractive) { - clearConsole(); - const existingProcess = getProcessForPort(defaultPort); - const question = { - type: 'confirm', - name: 'shouldChangePort', - message: chalk.yellow( - message + - `${existingProcess ? ` Probably:\n ${existingProcess}` : ''}` - ) + '\n\nWould you like to run the app on another port instead?', - default: true, - }; - inquirer.prompt(question).then(answer => { - if (answer.shouldChangePort) { - resolve(port); - } else { - resolve(null); - } - }); - } else { - console.log(chalk.red(message)); - resolve(null); - } - }), + port => + new Promise(resolve => { + if (port === defaultPort) { + return resolve(port); + } + const message = + process.platform !== 'win32' && defaultPort < 1024 && !isRoot() + ? `Admin permissions are required to run a server on a port below 1024.` + : `Something is already running on port ${defaultPort}.`; + if (isInteractive) { + clearConsole(); + const existingProcess = getProcessForPort(defaultPort); + const question = { + type: 'confirm', + name: 'shouldChangePort', + message: + chalk.yellow( + message + + `${existingProcess ? ` Probably:\n ${existingProcess}` : ''}` + ) + '\n\nWould you like to run the app on another port instead?', + default: true, + }; + inquirer.prompt(question).then(answer => { + if (answer.shouldChangePort) { + resolve(port); + } else { + resolve(null); + } + }); + } else { + console.log(chalk.red(message)); + resolve(null); + } + }), err => { throw new Error( chalk.red(`Could not find an open port at ${chalk.bold(host)}.`) + diff --git a/packages/react-dev-utils/ansiHTML.js b/packages/react-dev-utils/ansiHTML.js index 5d3e79203..9f53cea67 100644 --- a/packages/react-dev-utils/ansiHTML.js +++ b/packages/react-dev-utils/ansiHTML.js @@ -69,7 +69,8 @@ function ansiHTML(txt) { var open = false; for (var index = 0; index < arr.length; ++index) { var c = arr[index]; - var content = c.content, fg = c.fg; + var content = c.content, + fg = c.fg; var contentParts = content.split('\n'); for (var _index = 0; _index < contentParts.length; ++_index) { diff --git a/packages/react-dev-utils/eslintFormatter.js b/packages/react-dev-utils/eslintFormatter.js index 96b6ce14b..b7756b7a2 100644 --- a/packages/react-dev-utils/eslintFormatter.js +++ b/packages/react-dev-utils/eslintFormatter.js @@ -82,7 +82,8 @@ function formatter(results) { // it here because we always show at most one error, and // we can only be sure it's an ESLint error before exiting // this function. - output += 'Search for the ' + + output += + 'Search for the ' + chalk.underline(chalk.red('keywords')) + ' to learn more about each error.'; } diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index 7ed4ad190..bcf0a5060 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -30,10 +30,13 @@ function isTerminalEditor(editor) { // of the app every time const COMMON_EDITORS_OSX = { '/Applications/Atom.app/Contents/MacOS/Atom': 'atom', - '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta': '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta', + '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta': + '/Applications/Atom Beta.app/Contents/MacOS/Atom Beta', '/Applications/Brackets.app/Contents/MacOS/Brackets': 'brackets', - '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text': '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', - '/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2': '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', + '/Applications/Sublime Text.app/Contents/MacOS/Sublime Text': + '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl', + '/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2': + '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', '/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code', }; diff --git a/packages/react-dev-utils/openBrowser.js b/packages/react-dev-utils/openBrowser.js index 9ded70781..4f5700125 100644 --- a/packages/react-dev-utils/openBrowser.js +++ b/packages/react-dev-utils/openBrowser.js @@ -68,7 +68,8 @@ function startBrowserProcess(browser, url) { // requested a different browser, we can try opening // Chrome with AppleScript. This lets us reuse an // existing tab when possible instead of creating a new one. - const shouldTryOpenChromeWithAppleScript = process.platform === 'darwin' && + const shouldTryOpenChromeWithAppleScript = + process.platform === 'darwin' && (typeof browser !== 'string' || browser === OSX_CHROME); if (shouldTryOpenChromeWithAppleScript) { diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js index 7b9284d4e..f9882d44a 100644 --- a/packages/react-dev-utils/printHostingInstructions.js +++ b/packages/react-dev-utils/printHostingInstructions.js @@ -23,10 +23,14 @@ function printHostingInstructions( if (publicUrl && publicUrl.indexOf('.github.io/') !== -1) { // "homepage": "http://user.github.io/project" console.log( - `The project was built assuming it is hosted at ${chalk.green(publicPathname)}.` + `The project was built assuming it is hosted at ${chalk.green( + publicPathname + )}.` ); console.log( - `You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.` + `You can control this with the ${chalk.green( + 'homepage' + )} field in your ${chalk.cyan('package.json')}.` ); console.log(); console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`); @@ -48,10 +52,14 @@ function printHostingInstructions( console.log(` ${chalk.yellow('"scripts"')}: {`); console.log(` ${chalk.dim('// ...')}`); console.log( - ` ${chalk.yellow('"predeploy"')}: ${chalk.yellow('"npm run build",')}` + ` ${chalk.yellow('"predeploy"')}: ${chalk.yellow( + '"npm run build",' + )}` ); console.log( - ` ${chalk.yellow('"deploy"')}: ${chalk.yellow('"gh-pages -d build"')}` + ` ${chalk.yellow('"deploy"')}: ${chalk.yellow( + '"gh-pages -d build"' + )}` ); console.log(' }'); console.log(); @@ -63,10 +71,14 @@ function printHostingInstructions( } else if (publicPath !== '/') { // "homepage": "http://mywebsite.com/project" console.log( - `The project was built assuming it is hosted at ${chalk.green(publicPath)}.` + `The project was built assuming it is hosted at ${chalk.green( + publicPath + )}.` ); console.log( - `You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.` + `You can control this with the ${chalk.green( + 'homepage' + )} field in your ${chalk.cyan('package.json')}.` ); console.log(); console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`); @@ -75,10 +87,14 @@ function printHostingInstructions( if (publicUrl) { // "homepage": "http://mywebsite.com" console.log( - `The project was built assuming it is hosted at ${chalk.green(publicUrl)}.` + `The project was built assuming it is hosted at ${chalk.green( + publicUrl + )}.` ); console.log( - `You can control this with the ${chalk.green('homepage')} field in your ${chalk.cyan('package.json')}.` + `You can control this with the ${chalk.green( + 'homepage' + )} field in your ${chalk.cyan('package.json')}.` ); console.log(); } else { @@ -87,12 +103,16 @@ function printHostingInstructions( 'The project was built assuming it is hosted at the server root.' ); console.log( - `To override this, specify the ${chalk.green('homepage')} in your ${chalk.cyan('package.json')}.` + `To override this, specify the ${chalk.green( + 'homepage' + )} in your ${chalk.cyan('package.json')}.` ); console.log('For example, add this to build it for GitHub Pages:'); console.log(); console.log( - ` ${chalk.green('"homepage"')} ${chalk.cyan(':')} ${chalk.green('"http://myname.github.io/myapp"')}${chalk.cyan(',')}` + ` ${chalk.green('"homepage"')} ${chalk.cyan(':')} ${chalk.green( + '"http://myname.github.io/myapp"' + )}${chalk.cyan(',')}` ); console.log(); } diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 7d6a979e2..78002b28e 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -81,14 +81,16 @@ function addOverlayDivTo(iframe) { } function overlayHeaderStyle() { - return 'font-size: 2em;' + + return ( + 'font-size: 2em;' + 'font-family: sans-serif;' + 'color: rgb(206, 17, 38);' + 'white-space: pre-wrap;' + 'margin: 0 2rem 0.75rem 0px;' + 'flex: 0 0 auto;' + 'max-height: 35%;' + - 'overflow: auto;'; + 'overflow: auto;' + ); } var overlayIframe = null; @@ -127,7 +129,8 @@ function ensureOverlayDivExists(onOverlayDivReady) { function showErrorOverlay(message) { ensureOverlayDivExists(function onOverlayDivReady(overlayDiv) { // TODO: unify this with our runtime overlay - overlayDiv.innerHTML = '<div style="' + + overlayDiv.innerHTML = + '<div style="' + overlayHeaderStyle() + '">Failed to compile</div>' + '<pre style="' + diff --git a/packages/react-error-overlay/src/__tests__/mapper.js b/packages/react-error-overlay/src/__tests__/mapper.js index 64c2cf730..169bf6c59 100644 --- a/packages/react-error-overlay/src/__tests__/mapper.js +++ b/packages/react-error-overlay/src/__tests__/mapper.js @@ -14,7 +14,8 @@ import { resolve } from 'path'; test('basic error; 0 context', async () => { expect.assertions(1); - const error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)\n at http://localhost:3000/static/js/bundle.js:30091:25\n at measureLifeCyclePerf (http://localhost:3000/static/js/bundle.js:29901:12)\n at http://localhost:3000/static/js/bundle.js:30090:11\n at CallbackQueue.notifyAll (http://localhost:3000/static/js/bundle.js:13256:22)\n at ReactReconcileTransaction.close (http://localhost:3000/static/js/bundle.js:35124:26)\n at ReactReconcileTransaction.closeAll (http://localhost:3000/static/js/bundle.js:7390:25)\n at ReactReconcileTransaction.perform (http://localhost:3000/static/js/bundle.js:7337:16)\n at batchedMountComponentIntoNode (http://localhost:3000/static/js/bundle.js:14204:15)\n at ReactDefaultBatchingStrategyTransaction.perform (http://localhost:3000/static/js/bundle.js:7324:20)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:33900:26)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:2181:27)\n at Object._renderNewRootComponent (http://localhost:3000/static/js/bundle.js:14398:18)\n at Object._renderSubtreeIntoContainer (http://localhost:3000/static/js/bundle.js:14479:32)\n at Object.render (http://localhost:3000/static/js/bundle.js:14500:23)\n at Object.friendlySyntaxErrorLabel (http://localhost:3000/static/js/bundle.js:17287:20)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at fn (http://localhost:3000/static/js/bundle.js:84:20)\n at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:41219:18)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at validateFormat (http://localhost:3000/static/js/bundle.js:709:39)\n at http://localhost:3000/static/js/bundle.js:712:10'; + const error = + 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)\n at http://localhost:3000/static/js/bundle.js:30091:25\n at measureLifeCyclePerf (http://localhost:3000/static/js/bundle.js:29901:12)\n at http://localhost:3000/static/js/bundle.js:30090:11\n at CallbackQueue.notifyAll (http://localhost:3000/static/js/bundle.js:13256:22)\n at ReactReconcileTransaction.close (http://localhost:3000/static/js/bundle.js:35124:26)\n at ReactReconcileTransaction.closeAll (http://localhost:3000/static/js/bundle.js:7390:25)\n at ReactReconcileTransaction.perform (http://localhost:3000/static/js/bundle.js:7337:16)\n at batchedMountComponentIntoNode (http://localhost:3000/static/js/bundle.js:14204:15)\n at ReactDefaultBatchingStrategyTransaction.perform (http://localhost:3000/static/js/bundle.js:7324:20)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:33900:26)\n at Object.batchedUpdates (http://localhost:3000/static/js/bundle.js:2181:27)\n at Object._renderNewRootComponent (http://localhost:3000/static/js/bundle.js:14398:18)\n at Object._renderSubtreeIntoContainer (http://localhost:3000/static/js/bundle.js:14479:32)\n at Object.render (http://localhost:3000/static/js/bundle.js:14500:23)\n at Object.friendlySyntaxErrorLabel (http://localhost:3000/static/js/bundle.js:17287:20)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at fn (http://localhost:3000/static/js/bundle.js:84:20)\n at Object.<anonymous> (http://localhost:3000/static/js/bundle.js:41219:18)\n at __webpack_require__ (http://localhost:3000/static/js/bundle.js:660:30)\n at validateFormat (http://localhost:3000/static/js/bundle.js:709:39)\n at http://localhost:3000/static/js/bundle.js:712:10'; fetch.mockResponseOnce( fs @@ -38,7 +39,8 @@ test('basic error; 0 context', async () => { test('default context (3)', async () => { expect.assertions(1); - const error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)'; + const error = + 'TypeError: document.body.missing is not a function\n at App.componentDidMount (http://localhost:3000/static/js/bundle.js:26122:21)'; fetch.mockResponseOnce( fs @@ -62,7 +64,8 @@ test('default context (3)', async () => { test('bad comes back same', async () => { expect.assertions(2); - const error = 'TypeError: document.body.missing is not a function\n at App.componentDidMount (A:1:2)'; + const error = + 'TypeError: document.body.missing is not a function\n at App.componentDidMount (A:1:2)'; const orig = parse(error); expect(orig).toEqual([ { diff --git a/packages/react-error-overlay/src/components/frame.js b/packages/react-error-overlay/src/components/frame.js index 3b27406dd..43d0d4043 100644 --- a/packages/react-error-overlay/src/components/frame.js +++ b/packages/react-error-overlay/src/components/frame.js @@ -242,8 +242,8 @@ function createFrame( let needsHidden = false; const isInternalUrl = isInternalFile(sourceFileName, fileName); const isThrownIntentionally = !isBultinErrorName(errorName); - const shouldCollapse = isInternalUrl && - (isThrownIntentionally || omits.hasReachedAppCode); + const shouldCollapse = + isInternalUrl && (isThrownIntentionally || omits.hasReachedAppCode); if (!isInternalUrl) { omits.hasReachedAppCode = true; @@ -281,9 +281,8 @@ function createFrame( let onSourceClick = null; if (sourceFileName) { // e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1" - const isInternalWebpackBootstrapCode = sourceFileName - .trim() - .indexOf(' ') !== -1; + const isInternalWebpackBootstrapCode = + sourceFileName.trim().indexOf(' ') !== -1; if (!isInternalWebpackBootstrapCode) { onSourceClick = () => { // Keep this in sync with react-error-overlay/middleware.js @@ -312,7 +311,10 @@ function createFrame( let hasSource = false; if (!shouldCollapse) { if ( - compiled && scriptLines && scriptLines.length !== 0 && lineNumber != null + compiled && + scriptLines && + scriptLines.length !== 0 && + lineNumber != null ) { elem.appendChild( createCode( diff --git a/packages/react-error-overlay/src/components/overlay.js b/packages/react-error-overlay/src/components/overlay.js index 573db8def..69acf9ad4 100644 --- a/packages/react-error-overlay/src/components/overlay.js +++ b/packages/react-error-overlay/src/components/overlay.js @@ -60,9 +60,8 @@ function createOverlay( applyStyles(header, headerStyle); // Make message prettier - let finalMessage = message.match(/^\w*:/) || !name - ? message - : name + ': ' + message; + let finalMessage = + message.match(/^\w*:/) || !name ? message : name + ': ' + message; finalMessage = finalMessage // TODO: maybe remove this prefix from fbjs? diff --git a/packages/react-error-overlay/src/utils/isInternalFile.js b/packages/react-error-overlay/src/utils/isInternalFile.js index 71beea7cc..c78bbe3ed 100644 --- a/packages/react-error-overlay/src/utils/isInternalFile.js +++ b/packages/react-error-overlay/src/utils/isInternalFile.js @@ -9,13 +9,15 @@ /* @flow */ function isInternalFile(sourceFileName: ?string, fileName: ?string) { - return sourceFileName == null || + return ( + sourceFileName == null || sourceFileName === '' || sourceFileName.indexOf('/~/') !== -1 || sourceFileName.indexOf('/node_modules/') !== -1 || sourceFileName.trim().indexOf(' ') !== -1 || fileName == null || - fileName === ''; + fileName === '' + ); } export { isInternalFile }; diff --git a/packages/react-error-overlay/src/utils/unmapper.js b/packages/react-error-overlay/src/utils/unmapper.js index 74e389555..b01736d74 100644 --- a/packages/react-error-overlay/src/utils/unmapper.js +++ b/packages/react-error-overlay/src/utils/unmapper.js @@ -15,7 +15,8 @@ import path from 'path'; function count(search: string, string: string): number { // Count starts at -1 becuse a do-while loop always runs at least once - let count = -1, index = -1; + let count = -1, + index = -1; do { // First call or the while case evaluated true, meaning we have to make // count 0 or we found a character diff --git a/packages/react-scripts/config/env.js b/packages/react-scripts/config/env.js index e7d7f9f32..ebef79ed9 100644 --- a/packages/react-scripts/config/env.js +++ b/packages/react-scripts/config/env.js @@ -88,13 +88,10 @@ function getClientEnvironment(publicUrl) { ); // Stringify all values so we can feed into Webpack DefinePlugin const stringified = { - 'process.env': Object.keys(raw).reduce( - (env, key) => { - env[key] = JSON.stringify(raw[key]); - return env; - }, - {} - ), + 'process.env': Object.keys(raw).reduce((env, key) => { + env[key] = JSON.stringify(raw[key]); + return env; + }, {}), }; return { raw, stringified }; diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index 42ec8374a..94e399f0f 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -43,8 +43,8 @@ const getPublicUrl = appPackageJson => // like /todos/42/static/js/bundle.7289d.js. We have to know the root. function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); - const servedUrl = envPublicUrl || - (publicUrl ? url.parse(publicUrl).pathname : '/'); + const servedUrl = + envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); return ensureSlash(servedUrl, true); } @@ -89,7 +89,8 @@ module.exports = { const ownPackageJson = require('../package.json'); const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`); -const reactScriptsLinked = fs.existsSync(reactScriptsPath) && +const reactScriptsLinked = + fs.existsSync(reactScriptsPath) && fs.lstatSync(reactScriptsPath).isSymbolicLink(); // config before publish: we're in ./packages/react-scripts/config/ diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index cf7584e5b..2a351e668 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -36,8 +36,8 @@ module.exports = function(proxy, allowedHost) { // So we will disable the host check normally, but enable it if you have // specified the `proxy` setting. Finally, we let you override it if you // really know what you're doing with a special environment variable. - disableHostCheck: !proxy || - process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true', + disableHostCheck: + !proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true', // Enable gzip compression of generated files. compress: true, // Silence WebpackDevServer's own logs since they're generally not useful. diff --git a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js index 89d19fcf4..a7d4ff2a2 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js @@ -50,9 +50,10 @@ describe('Integration', () => { it('PUBLIC_URL', async () => { const doc = await initDOM('public-url'); - const prefix = process.env.NODE_ENV === 'development' - ? '' - : 'http://www.example.org/spa'; + const prefix = + process.env.NODE_ENV === 'development' + ? '' + : 'http://www.example.org/spa'; expect(doc.getElementById('feature-public-url').textContent).to.equal( `${prefix}.` ); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index 4d6f531ea..b865b5641 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -38,13 +38,14 @@ if (process.env.E2E_FILE) { ) ); } else if (process.env.E2E_URL) { - getMarkup = () => new Promise(resolve => { - http.get(process.env.E2E_URL, res => { - let rawData = ''; - res.on('data', chunk => rawData += chunk); - res.on('end', () => resolve(rawData)); + getMarkup = () => + new Promise(resolve => { + http.get(process.env.E2E_URL, res => { + let rawData = ''; + res.on('data', chunk => (rawData += chunk)); + res.on('end', () => resolve(rawData)); + }); }); - }); resourceLoader = (resource, callback) => resource.defaultFetch(callback); } else { @@ -58,21 +59,22 @@ if (process.env.E2E_FILE) { ); } -export default feature => new Promise(async resolve => { - const markup = await getMarkup(); - const host = process.env.E2E_URL || 'http://www.example.org/spa:3000'; - const doc = jsdom.jsdom(markup, { - features: { - FetchExternalResources: ['script', 'css'], - ProcessExternalResources: ['script'], - }, - created: (_, win) => - win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true), - deferClose: true, - resourceLoader, - url: `${host}#${feature}`, - virtualConsole: jsdom.createVirtualConsole().sendTo(console), - }); +export default feature => + new Promise(async resolve => { + const markup = await getMarkup(); + const host = process.env.E2E_URL || 'http://www.example.org/spa:3000'; + const doc = jsdom.jsdom(markup, { + features: { + FetchExternalResources: ['script', 'css'], + ProcessExternalResources: ['script'], + }, + created: (_, win) => + win.addEventListener('ReactFeatureDidMount', () => resolve(doc), true), + deferClose: true, + resourceLoader, + url: `${host}#${feature}`, + virtualConsole: jsdom.createVirtualConsole().sendTo(console), + }); - doc.close(); -}); + doc.close(); + }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index 3a1981a40..cb342b062 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -30,10 +30,7 @@ class BuiltEmitter extends Component { } render() { - const { - props: { feature }, - handleReady, - } = this; + const { props: { feature }, handleReady } = this; return ( <div> {createElement(feature, { @@ -57,114 +54,132 @@ class App extends Component { const feature = window.location.hash.slice(1); switch (feature) { case 'array-destructuring': - import( - './features/syntax/ArrayDestructuring' - ).then(f => this.setFeature(f.default)); + import('./features/syntax/ArrayDestructuring').then(f => + this.setFeature(f.default) + ); break; case 'array-spread': import('./features/syntax/ArraySpread').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'async-await': import('./features/syntax/AsyncAwait').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'class-properties': import('./features/syntax/ClassProperties').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'computed-properties': - import( - './features/syntax/ComputedProperties' - ).then(f => this.setFeature(f.default)); + import('./features/syntax/ComputedProperties').then(f => + this.setFeature(f.default) + ); break; case 'css-inclusion': import('./features/webpack/CssInclusion').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'custom-interpolation': - import( - './features/syntax/CustomInterpolation' - ).then(f => this.setFeature(f.default)); + import('./features/syntax/CustomInterpolation').then(f => + this.setFeature(f.default) + ); break; case 'default-parameters': import('./features/syntax/DefaultParameters').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'destructuring-and-await': - import( - './features/syntax/DestructuringAndAwait' - ).then(f => this.setFeature(f.default)); + import('./features/syntax/DestructuringAndAwait').then(f => + this.setFeature(f.default) + ); break; case 'file-env-variables': import('./features/env/FileEnvVariables').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'generators': import('./features/syntax/Generators').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'image-inclusion': import('./features/webpack/ImageInclusion').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'json-inclusion': import('./features/webpack/JsonInclusion').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'linked-modules': import('./features/webpack/LinkedModules').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'node-path': import('./features/env/NodePath').then(f => this.setFeature(f.default)); break; case 'no-ext-inclusion': import('./features/webpack/NoExtInclusion').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'object-destructuring': - import( - './features/syntax/ObjectDestructuring' - ).then(f => this.setFeature(f.default)); + import('./features/syntax/ObjectDestructuring').then(f => + this.setFeature(f.default) + ); break; case 'object-spread': import('./features/syntax/ObjectSpread').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'promises': import('./features/syntax/Promises').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'public-url': import('./features/env/PublicUrl').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'rest-and-default': import('./features/syntax/RestAndDefault').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'rest-parameters': import('./features/syntax/RestParameters').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'shell-env-variables': import('./features/env/ShellEnvVariables').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'svg-inclusion': import('./features/webpack/SvgInclusion').then(f => - this.setFeature(f.default)); + this.setFeature(f.default) + ); break; case 'template-interpolation': - import( - './features/syntax/TemplateInterpolation' - ).then(f => this.setFeature(f.default)); + import('./features/syntax/TemplateInterpolation').then(f => + this.setFeature(f.default) + ); break; case 'unknown-ext-inclusion': - import( - './features/webpack/UnknownExtInclusion' - ).then(f => this.setFeature(f.default)); + import('./features/webpack/UnknownExtInclusion').then(f => + this.setFeature(f.default) + ); break; default: throw new Error(`Missing feature "${feature}"`); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js index 55ae368e4..03d638471 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js @@ -9,7 +9,7 @@ import React from 'react'; -export default () => ( +export default () => <span> <span id="feature-file-env-original-1"> {process.env.REACT_APP_ORIGINAL_1} @@ -18,8 +18,10 @@ export default () => ( {process.env.REACT_APP_ORIGINAL_2} </span> <span id="feature-file-env"> - {process.env.REACT_APP_DEVELOPMENT}{process.env.REACT_APP_PRODUCTION} + {process.env.REACT_APP_DEVELOPMENT} + {process.env.REACT_APP_PRODUCTION} </span> - <span id="feature-file-env-x">{process.env.REACT_APP_X}</span> - </span> -); + <span id="feature-file-env-x"> + {process.env.REACT_APP_X} + </span> + </span>; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js index a039cefed..6d2437a64 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js @@ -33,7 +33,11 @@ export default class extends Component { render() { return ( <div id="feature-node-path"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js index 4ea9b96f8..af87748e6 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js @@ -9,6 +9,7 @@ import React from 'react'; -export default () => ( - <span id="feature-public-url">{process.env.PUBLIC_URL}.</span> -); +export default () => + <span id="feature-public-url"> + {process.env.PUBLIC_URL}. + </span>; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js index 8449097d6..400dfc013 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js @@ -9,8 +9,7 @@ import React from 'react'; -export default () => ( +export default () => <span id="feature-shell-env-variables"> {process.env.REACT_APP_SHELL_ENV_MESSAGE}. - </span> -); + </span>; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js index be6c39f90..de0576549 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js @@ -38,7 +38,11 @@ export default class extends Component { <div id="feature-array-destructuring"> {this.state.users.map(user => { const [id, name] = user; - return <div key={id}>{name}</div>; + return ( + <div key={id}> + {name} + </div> + ); })} </div> ); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js index eb7886aa4..ebf90ef6e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js @@ -41,7 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-array-spread"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js index a60633460..c91da311d 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js @@ -41,7 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-async-await"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js index ed96d4f8c..58ae10763 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js @@ -29,7 +29,11 @@ export default class extends Component { render() { return ( <div id="feature-class-properties"> - {this.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js index 38dc797a8..fcbf721e8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js @@ -41,9 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-computed-properties"> - {this.state.users.map(user => ( - <div key={user.id}>{user.user_name}</div> - ))} + {this.state.users.map(user => + <div key={user.id}> + {user.user_name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js index 1a0123391..ab648255a 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js @@ -53,9 +53,11 @@ export default class extends Component { return ( <div id="feature-custom-interpolation"> - {this.state.users.map(user => ( - <div key={user.id} style={veryInlineStyle}>{user.name}</div> - ))} + {this.state.users.map(user => + <div key={user.id} style={veryInlineStyle}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js index 0a519eba8..6ebabaec7 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js @@ -41,7 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-default-parameters"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js index d44f4cf22..aa8c9d7db 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js @@ -43,7 +43,11 @@ export default class extends Component { render() { return ( <div id="feature-destructuring-and-await"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js index 2fe473d13..44b2776e1 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js @@ -43,7 +43,11 @@ export default class extends Component { render() { return ( <div id="feature-generators"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js index 2994d14af..8a7b1095f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js @@ -43,7 +43,11 @@ export default class extends Component { <div id="feature-object-destructuring"> {this.state.users.map(user => { const { id, name } = user; - return <div key={id}>{name}</div>; + return ( + <div key={id}> + {name} + </div> + ); })} </div> ); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js index 65705f11b..5ff4e10ac 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js @@ -41,9 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-object-spread"> - {this.state.users.map(user => ( - <div key={user.id}>{user.name}: {user.age}</div> - ))} + {this.state.users.map(user => + <div key={user.id}> + {user.name}: {user.age} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js index e626de5d8..31ef2c9eb 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js @@ -42,7 +42,11 @@ export default class extends Component { render() { return ( <div id="feature-promises"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js index dc2a1563a..9e3e3fbab 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js @@ -41,7 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-rest-and-default"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js index e703a33cc..98a0e7edc 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js @@ -41,7 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-rest-parameters"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js index 5aba5da62..b69f7ede8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js @@ -41,7 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-template-interpolation"> - {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} + {this.state.users.map(user => + <div key={user.id}> + {user.name} + </div> + )} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js index a6ca7aaa8..8598d8d06 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js @@ -10,6 +10,5 @@ import React from 'react'; import tiniestCat from './assets/tiniest-cat.jpg'; -export default () => ( - <img id="feature-image-inclusion" src={tiniestCat} alt="tiniest cat" /> -); +export default () => + <img id="feature-image-inclusion" src={tiniestCat} alt="tiniest cat" />; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js index e81f76397..66425c66c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js @@ -10,4 +10,7 @@ import React from 'react'; import { abstract } from './assets/abstract.json'; -export default () => <summary id="feature-json-inclusion">{abstract}</summary>; +export default () => + <summary id="feature-json-inclusion"> + {abstract} + </summary>; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js index de8a5e4ab..395ebd7ed 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js @@ -16,5 +16,9 @@ export default () => { if (!test() || v !== '2.0.0') { throw new Error('Functionality test did not pass.'); } - return <p id="feature-linked-modules">{v}</p>; + return ( + <p id="feature-linked-modules"> + {v} + </p> + ); }; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js index 7f824c2f2..086885db2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js @@ -14,6 +14,7 @@ const text = aFileWithoutExt.includes('base64') ? atob(aFileWithoutExt.split('base64,')[1]).trim() : aFileWithoutExt; -export default () => ( - <a id="feature-no-ext-inclusion" href={text}>aFileWithoutExt</a> -); +export default () => + <a id="feature-no-ext-inclusion" href={text}> + aFileWithoutExt + </a>; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js index 70b046e95..c41a1e0c0 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js @@ -14,6 +14,7 @@ const text = aFileWithExtUnknown.includes('base64') ? atob(aFileWithExtUnknown.split('base64,')[1]).trim() : aFileWithExtUnknown; -export default () => ( - <a id="feature-unknown-ext-inclusion" href={text}>aFileWithExtUnknown</a> -); +export default () => + <a id="feature-unknown-ext-inclusion" href={text}> + aFileWithExtUnknown + </a>; diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 06eb0695d..b9b65f531 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -35,7 +35,8 @@ const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages'); const printHostingInstructions = require('react-dev-utils/printHostingInstructions'); const FileSizeReporter = require('react-dev-utils/FileSizeReporter'); -const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild; +const measureFileSizesBeforeBuild = + FileSizeReporter.measureFileSizesBeforeBuild; const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild; const useYarn = fs.existsSync(paths.yarnLockFile); diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 265511860..3d8d258cc 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -85,19 +85,16 @@ inquirer const folders = ['config', 'config/jest', 'scripts']; // Make shallow array of files paths - const files = folders.reduce( - (files, folder) => { - return files.concat( - fs - .readdirSync(path.join(ownPath, folder)) - // set full path - .map(file => path.join(ownPath, folder, file)) - // omit dirs from file list - .filter(file => fs.lstatSync(file).isFile()) - ); - }, - [] - ); + const files = folders.reduce((files, folder) => { + return files.concat( + fs + .readdirSync(path.join(ownPath, folder)) + // set full path + .map(file => path.join(ownPath, folder, file)) + // omit dirs from file list + .filter(file => fs.lstatSync(file).isFile()) + ); + }, []); // Ensure that the app folder is clean and we won't override any files folders.forEach(verifyAbsent); @@ -124,18 +121,19 @@ inquirer if (content.match(/\/\/ @remove-file-on-eject/)) { return; } - content = content - // Remove dead code from .js files on eject - .replace( - /\/\/ @remove-on-eject-begin([\s\S]*?)\/\/ @remove-on-eject-end/mg, - '' - ) - // Remove dead code from .applescript files on eject - .replace( - /-- @remove-on-eject-begin([\s\S]*?)-- @remove-on-eject-end/mg, - '' - ) - .trim() + '\n'; + content = + content + // Remove dead code from .js files on eject + .replace( + /\/\/ @remove-on-eject-begin([\s\S]*?)\/\/ @remove-on-eject-end/gm, + '' + ) + // Remove dead code from .applescript files on eject + .replace( + /-- @remove-on-eject-begin([\s\S]*?)-- @remove-on-eject-end/gm, + '' + ) + .trim() + '\n'; console.log(` Adding ${cyan(file.replace(ownPath, ''))} to the project`); fs.writeFileSync(file.replace(ownPath, appPath), content); }); @@ -187,7 +185,9 @@ inquirer 'node scripts/$1.js' ); console.log( - ` Replacing ${cyan(`"${binKey} ${key}"`)} with ${cyan(`"node scripts/${key}.js"`)}` + ` Replacing ${cyan(`"${binKey} ${key}"`)} with ${cyan( + `"node scripts/${key}.js"` + )}` ); }); }); diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 93e5b449a..0a62cc4a9 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -28,11 +28,8 @@ module.exports = function( originalDirectory, template ) { - const ownPackageName = require(path.join( - __dirname, - '..', - 'package.json' - )).name; + const ownPackageName = require(path.join(__dirname, '..', 'package.json')) + .name; const ownPath = path.join(appPath, 'node_modules', ownPackageName); const appPackage = require(path.join(appPath, 'package.json')); const useYarn = fs.existsSync(path.join(appPath, 'yarn.lock')); @@ -192,6 +189,8 @@ module.exports = function( function isReactInstalled(appPackage) { const dependencies = appPackage.dependencies || {}; - return typeof dependencies.react !== 'undefined' && - typeof dependencies['react-dom'] !== 'undefined'; + return ( + typeof dependencies.react !== 'undefined' && + typeof dependencies['react-dom'] !== 'undefined' + ); } From 31028774ea4405ea5932559c58face32d46e89c3 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 17:29:48 +0100 Subject: [PATCH 082/265] Changelog for 1.0.8 (#2664) * Add changelog for 1.0.8 * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9049c88fe..2e007f36c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,176 @@ +## 1.0.8 (June 28, 2017) + +#### :bug: Bug Fix +* `react-scripts` + + * [#2550](https://github.com/facebookincubator/create-react-app/pull/2550) Fix Node 8 compatibility. ([@josephfrazier](https://github.com/josephfrazier)) + * [#2610](https://github.com/facebookincubator/create-react-app/pull/2610) Fix sourcemap directory organization on Windows. ([@plusCubed](https://github.com/plusCubed)) + * [#2596](https://github.com/facebookincubator/create-react-app/pull/2596) Fix an issue with minifying emojis. ([@viankakrisna](https://github.com/viankakrisna)) + * [#2501](https://github.com/facebookincubator/create-react-app/pull/2501) Fix incorrect check if `CI` variable is set to true. ([@varnav](https://github.com/varnav)) + * [#2432](https://github.com/facebookincubator/create-react-app/pull/2432) In new projects, don't register service worker for projects using `PUBLIC_URL` for CDN. ([@jeffposnick](https://github.com/jeffposnick)) + * [#2470](https://github.com/facebookincubator/create-react-app/pull/2470) In new projects, prioritize `index.css` over `App.css`. ([@bryankang](https://github.com/bryankang)) + +* `react-dev-utils` + + * [#2405](https://github.com/facebookincubator/create-react-app/pull/2405) Fix detection of parent directory in `ModuleScopePlugin`. ([@diligiant](https://github.com/diligiant)) + * [#2562](https://github.com/facebookincubator/create-react-app/pull/2562) Fix eject command output. ([@paweljedrzejczyk](https://github.com/paweljedrzejczyk)) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#2648](https://github.com/facebookincubator/create-react-app/pull/2648) Warn about large bundle sizes. ([@gaearon](https://github.com/gaearon)) + * [#2511](https://github.com/facebookincubator/create-react-app/pull/2511) Support `.web.js` extension for React Native Web. ([@mini-eggs](https://github.com/mini-eggs)) + * [#2645](https://github.com/facebookincubator/create-react-app/pull/2645) Hide confusing "Skipping static resource" message. ([@gaearon](https://github.com/gaearon)) + * [#2389](https://github.com/facebookincubator/create-react-app/pull/2389) Silence unnecessary warning from Babel. ([@gaearon](https://github.com/gaearon)) + * [#2429](https://github.com/facebookincubator/create-react-app/pull/2429) Update `sw-precache-webpack-plugin` to lastest version. ([@goldhand](https://github.com/goldhand)) + * [#2600](https://github.com/facebookincubator/create-react-app/pull/2600) Add empty mock for `dgram` Node module. ([@micopiira](https://github.com/micopiira)) + * [#2458](https://github.com/facebookincubator/create-react-app/pull/2458) Add names to module factories in development. ([@Zaccc123](https://github.com/Zaccc123)) + * [#2551](https://github.com/facebookincubator/create-react-app/pull/2551) In new projects, unregister service worker and force reload if `service-worker.js` is not found. ([@ro-savage](https://github.com/ro-savage)) + +* `babel-preset-react-app`, `react-dev-utils`, `react-scripts` + + * [#2658](https://github.com/facebookincubator/create-react-app/pull/2658) Bump dependencies. ([@gaearon](https://github.com/gaearon)) + +* `create-react-app`, `react-scripts` + + * [#2657](https://github.com/facebookincubator/create-react-app/pull/2657) Put `react-scripts` in `dependencies`, not `devDependencies`. ([@gaearon](https://github.com/gaearon)) + * [#2635](https://github.com/facebookincubator/create-react-app/pull/2635) Silence unhelpful npm warnings. ([@gaearon](https://github.com/gaearon)) + +* `react-dev-utils` + + * [#2637](https://github.com/facebookincubator/create-react-app/pull/2637) Auto-detect Brackets editor from error overlay. ([@petetnt](https://github.com/petetnt)) + * [#2552](https://github.com/facebookincubator/create-react-app/pull/2552) Auto-detect running editor on Windows for error overlay. ([@levrik](https://github.com/levrik)) + * [#2622](https://github.com/facebookincubator/create-react-app/pull/2622) Support opening PhpStorm for error overlay. ([@miraage](https://github.com/miraage)) + * [#2414](https://github.com/facebookincubator/create-react-app/pull/2414) Support opening WebStorm 2017+ from error overlay. ([@wirmar](https://github.com/wirmar)) + * [#2518](https://github.com/facebookincubator/create-react-app/pull/2518) Warn when trying to run on port below 1024 without admin permissions under Linux/macOS. ([@levrik](https://github.com/levrik)) + * [#2385](https://github.com/facebookincubator/create-react-app/pull/2385) Suggest just `yarn build` in output. ([@gaearon](https://github.com/gaearon)) + +* `create-react-app` + + * [#1945](https://github.com/facebookincubator/create-react-app/pull/1945) Fix grammar in CLI output. ([@ColinEberhardt](https://github.com/ColinEberhardt)) + +#### :memo: Documentation + +* User Guide + + * [#2662](https://github.com/facebookincubator/create-react-app/pull/2662) Local testing docker links. ([@EnoahNetzach](https://github.com/EnoahNetzach)) + * [#2660](https://github.com/facebookincubator/create-react-app/pull/2660) Minor code style edits to user guide. ([@gaearon](https://github.com/gaearon)) + * [#2656](https://github.com/facebookincubator/create-react-app/pull/2656) Don't ask to install webpack for using Styleguidist. ([@gaearon](https://github.com/gaearon)) + * [#1641](https://github.com/facebookincubator/create-react-app/pull/1641) Add instructions to use `source-map-explorer`. ([@gr33nfury](https://github.com/gr33nfury)) + * [#2044](https://github.com/facebookincubator/create-react-app/pull/2044) Add React Styleguidist. ([@sapegin](https://github.com/sapegin)) + * [#2006](https://github.com/facebookincubator/create-react-app/pull/2006) Added instruction on how to install Prettier. ([@MrHus](https://github.com/MrHus)) + * [#1813](https://github.com/facebookincubator/create-react-app/pull/1813) Fix grammar. ([@iheng](https://github.com/iheng)) + * [#2060](https://github.com/facebookincubator/create-react-app/pull/2060) Add more info about OOM build failiure [docs]. ([@GAumala](https://github.com/GAumala)) + * [#2305](https://github.com/facebookincubator/create-react-app/pull/2305) Update docs with WebSocket proxy information. ([@jamesblight](https://github.com/jamesblight)) + * [#2445](https://github.com/facebookincubator/create-react-app/pull/2445) Document `REACT_EDITOR` environment variable. ([@wirmar](https://github.com/wirmar)) + * [#2362](https://github.com/facebookincubator/create-react-app/pull/2362) Add yarn example under "Installing a Dependency". ([@BrianDGLS](https://github.com/BrianDGLS)) + * [#2423](https://github.com/facebookincubator/create-react-app/pull/2423) Add docs for setting up CircleCI for CRA. ([@knowbody](https://github.com/knowbody)) + * [#2427](https://github.com/facebookincubator/create-react-app/pull/2427) Added link to tutorial on code splitting. ([@jayair](https://github.com/jayair)) + * [#2447](https://github.com/facebookincubator/create-react-app/pull/2447) Fix wrong comment on Proxy guide. ([@hellowin](https://github.com/hellowin)) + * [#2538](https://github.com/facebookincubator/create-react-app/pull/2538) Fix broken link to a tutorial. ([@romanyanke](https://github.com/romanyanke)) + * [#2522](https://github.com/facebookincubator/create-react-app/pull/2522) Flow init to run as command not flag. ([@khanglu](https://github.com/khanglu)) + * [#2521](https://github.com/facebookincubator/create-react-app/pull/2521) Fix broken link to Storybook docs. ([@shilman](https://github.com/shilman)) + * [#2500](https://github.com/facebookincubator/create-react-app/pull/2500) Fix minor typo. ([@AlexxNica](https://github.com/AlexxNica)) + * [#2331](https://github.com/facebookincubator/create-react-app/pull/2331) Re-add storybook && update the documentation and links. ([@ndelangen](https://github.com/ndelangen)) + * [#2454](https://github.com/facebookincubator/create-react-app/pull/2454) Update Travis CI Node versions in User Guide. ([@ryansully](https://github.com/ryansully)) + * [#2420](https://github.com/facebookincubator/create-react-app/pull/2420) Fix typo. ([@ruskakimov](https://github.com/ruskakimov)) + * [#2392](https://github.com/facebookincubator/create-react-app/pull/2392) Update `jest-enzyme` section. ([@luftywiranda13](https://github.com/luftywiranda13)) + +* README + + * [#2517](https://github.com/facebookincubator/create-react-app/pull/2517) Add Razzle to the alternatives. ([@kireerik](https://github.com/kireerik)) + * [#1931](https://github.com/facebookincubator/create-react-app/pull/1931) Updated README. ([@shaunwallace](https://github.com/shaunwallace)) + * [#2492](https://github.com/facebookincubator/create-react-app/pull/2492) Update webpack links to point to webpack 2. ([@laruiss](https://github.com/laruiss)) + +#### :house: Internal + +* Other + + * [#2465](https://github.com/facebookincubator/create-react-app/pull/2465) Update Prettier to v1. ([@ianschmitz](https://github.com/ianschmitz)) + * [#2489](https://github.com/facebookincubator/create-react-app/pull/2489) chore(templates): Move GitHub templates to hidden .github folder. ([@glennreyes](https://github.com/glennreyes)) + * [#2400](https://github.com/facebookincubator/create-react-app/pull/2400) Added cache clear to e2e scripts. ([@ro-savage](https://github.com/ro-savage)) + * [#2397](https://github.com/facebookincubator/create-react-app/pull/2397) Fix command in e2e-kitchensink.sh cleanup. ([@ro-savage](https://github.com/ro-savage)) + * [#2388](https://github.com/facebookincubator/create-react-app/pull/2388) Fix wrong path expansion in end-to-end test. ([@gaearon](https://github.com/gaearon)) + * [#2387](https://github.com/facebookincubator/create-react-app/pull/2387) Catch "No tests found" during CI. ([@EnoahNetzach](https://github.com/EnoahNetzach)) + +* `react-scripts` + + * [#2408](https://github.com/facebookincubator/create-react-app/pull/2408) E2E testing enhancements. ([@EnoahNetzach](https://github.com/EnoahNetzach)) + * [#2430](https://github.com/facebookincubator/create-react-app/pull/2430) Remove an unnecessary webpack option. ([@andykenward](https://github.com/andykenward)) + +* `react-dev-utils` + + * [#2483](https://github.com/facebookincubator/create-react-app/pull/2483) Remove a scoped package dependency. ([@Timer](https://github.com/Timer)) + +#### Committers: 46 +- Ade Viankakrisna Fadlil ([viankakrisna](https://github.com/viankakrisna)) +- Alexandre Nicastro ([AlexxNica](https://github.com/AlexxNica)) +- Andi N. Dirgantara ([hellowin](https://github.com/hellowin)) +- Andy Kenward ([andykenward](https://github.com/andykenward)) +- Artem Sapegin ([sapegin](https://github.com/sapegin)) +- Ashton ([ashtonsix](https://github.com/ashtonsix)) +- Brian Douglas ([BrianDGLS](https://github.com/BrianDGLS)) +- Colin Eberhardt ([ColinEberhardt](https://github.com/ColinEberhardt)) +- Colin Galindo ([gr33nfury](https://github.com/gr33nfury)) +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Daniel Ciao ([plusCubed](https://github.com/plusCubed)) +- Erik Engi ([kireerik](https://github.com/kireerik)) +- Evan Jones ([mini-eggs](https://github.com/mini-eggs)) +- Fabrizio Castellarin ([EnoahNetzach](https://github.com/EnoahNetzach)) +- Frédéric Miserey ([diligiant](https://github.com/diligiant)) +- Gabriel Aumala ([GAumala](https://github.com/GAumala)) +- Glenn Reyes ([glennreyes](https://github.com/glennreyes)) +- Heng Li ([iheng](https://github.com/iheng)) +- Ian Schmitz ([ianschmitz](https://github.com/ianschmitz)) +- James Blight ([jamesblight](https://github.com/jamesblight)) +- Jay V ([jayair](https://github.com/jayair)) +- Jeffrey Posnick ([jeffposnick](https://github.com/jeffposnick)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Joseph Frazier ([josephfrazier](https://github.com/josephfrazier)) +- Khang Lu ([khanglu](https://github.com/khanglu)) +- Levin Rickert ([levrik](https://github.com/levrik)) +- Lufty Wiranda ([luftywiranda13](https://github.com/luftywiranda13)) +- Maarten Hus ([MrHus](https://github.com/MrHus)) +- Marius Wirtherle ([wirmar](https://github.com/wirmar)) +- Mateusz Zatorski ([knowbody](https://github.com/knowbody)) +- Michael Shilman ([shilman](https://github.com/shilman)) +- Mico Piira ([micopiira](https://github.com/micopiira)) +- Mikhail Osher ([miraage](https://github.com/miraage)) +- Norbert de Langen ([ndelangen](https://github.com/ndelangen)) +- Paweł Jędrzejczyk ([paweljedrzejczyk](https://github.com/paweljedrzejczyk)) +- Pete Nykänen ([petetnt](https://github.com/petetnt)) +- Ro Savage ([ro-savage](https://github.com/ro-savage)) +- Roman ([romanyanke](https://github.com/romanyanke)) +- Rustem Kakimov ([ruskakimov](https://github.com/ruskakimov)) +- Ryan Sullivan ([ryansully](https://github.com/ryansully)) +- Stanislas Ormières ([laruiss](https://github.com/laruiss)) +- Will Farley ([goldhand](https://github.com/goldhand)) +- Zac Kwan ([Zaccc123](https://github.com/Zaccc123)) +- [bryankang](https://github.com/bryankang) +- [varnav](https://github.com/varnav) +- shaun wallace ([shaunwallace](https://github.com/shaunwallace)) + +### Migrating from 1.0.7 to 1.0.8 + +Inside any created project that has not been ejected, run: + +``` +npm install --save-dev --save-exact react-scripts@1.0.8 +``` + +or + +``` +yarn add --dev --exact react-scripts@1.0.8 +``` + +You may optionally then move `react-scripts` from `devDependencies` to `dependencies` since that’s how we’ll structure newly created projects. It is not necessary though. + +If you left the service worker integration enabled and didn’t change how it works, you can replace `src/registerServiceWorker.js` with [this updated version](https://raw.githubusercontent.com/facebookincubator/create-react-app/895c475d3fc218c65dcac9a3ef3f2c0ea746a1ed/packages/react-scripts/template/src/registerServiceWorker.js). + +If you haven't changed the default CSS organization, you may want to apply [this fix](https://github.com/facebookincubator/create-react-app/pull/2470/files) that makes `index.css` take precedence over `App.css` in your project. + ## 1.0.7 (May 27, 2017) #### :bug: Bug Fix From 7796c94d79519f1632b89739040c154b5b66176a Mon Sep 17 00:00:00 2001 From: Dan Abramov <gaearon@fb.com> Date: Wed, 28 Jun 2017 17:30:24 +0100 Subject: [PATCH 083/265] Publish - babel-preset-react-app@3.0.1 - create-react-app@1.3.2 - eslint-config-react-app@1.0.5 - react-dev-utils@3.0.1 - react-error-overlay@1.0.8 - react-scripts@1.0.8 --- packages/babel-preset-react-app/package.json | 2 +- packages/create-react-app/package.json | 2 +- packages/eslint-config-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 8 ++++---- packages/react-scripts/package.json | 10 +++++----- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index f56a804ea..d10188fda 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-react-app", - "version": "3.0.0", + "version": "3.0.1", "description": "Babel preset used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 13a567fa7..613007b40 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,6 +1,6 @@ { "name": "create-react-app", - "version": "1.3.1", + "version": "1.3.2", "keywords": [ "react" ], diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 87b63c5b6..cd36a70e5 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-react-app", - "version": "1.0.4", + "version": "1.0.5", "description": "ESLint configuration used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 75b39399e..4b01b465d 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "3.0.0", + "version": "3.0.1", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 88c909e11..f29aedd0f 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "1.0.7", + "version": "1.0.8", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { @@ -34,17 +34,17 @@ "anser": "1.2.5", "babel-code-frame": "6.22.0", "babel-runtime": "6.23.0", - "react-dev-utils": "^3.0.0", + "react-dev-utils": "^3.0.1", "settle-promise": "1.0.0", "source-map": "0.5.6" }, "devDependencies": { "babel-cli": "6.24.1", "babel-eslint": "7.2.3", - "babel-preset-react-app": "^3.0.0", + "babel-preset-react-app": "^3.0.1", "cross-env": "5.0.0", "eslint": "3.19.0", - "eslint-config-react-app": "^1.0.4", + "eslint-config-react-app": "^1.0.5", "eslint-plugin-flowtype": "2.33.0", "eslint-plugin-import": "2.2.0", "eslint-plugin-jsx-a11y": "5.0.3", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index c441460aa..f3750a16a 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.7", + "version": "1.0.8", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -26,14 +26,14 @@ "babel-eslint": "7.2.3", "babel-jest": "20.0.3", "babel-loader": "7.0.0", - "babel-preset-react-app": "^3.0.0", + "babel-preset-react-app": "^3.0.1", "babel-runtime": "6.23.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", "css-loader": "0.28.4", "dotenv": "4.0.0", "eslint": "3.19.0", - "eslint-config-react-app": "^1.0.4", + "eslint-config-react-app": "^1.0.5", "eslint-loader": "1.7.1", "eslint-plugin-flowtype": "2.34.0", "eslint-plugin-import": "2.2.0", @@ -48,8 +48,8 @@ "postcss-flexbugs-fixes": "3.0.0", "postcss-loader": "2.0.6", "promise": "7.1.1", - "react-dev-utils": "^3.0.0", - "react-error-overlay": "^1.0.7", + "react-dev-utils": "^3.0.1", + "react-error-overlay": "^1.0.8", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.3", "url-loader": "0.5.9", From 76ad76e313b838a02fbd4e32e9fa5448e121abcf Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 28 Jun 2017 18:19:19 +0100 Subject: [PATCH 084/265] Add a note about fixed vulnerability in 1.0.8 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e007f36c..2a5ef6906 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -165,6 +165,8 @@ or yarn add --dev --exact react-scripts@1.0.8 ``` +**If you previously used `HTTPS=true` environment variable in development**, make sure you aren't affected by a now-fixed vulnerability in Webpack by [visiting this page](http://badcert.mike.works/). You can read more about the vulnerability [here](https://medium.com/@mikenorth/webpack-preact-cli-vulnerability-961572624c54). + You may optionally then move `react-scripts` from `devDependencies` to `dependencies` since that’s how we’ll structure newly created projects. It is not necessary though. If you left the service worker integration enabled and didn’t change how it works, you can replace `src/registerServiceWorker.js` with [this updated version](https://raw.githubusercontent.com/facebookincubator/create-react-app/895c475d3fc218c65dcac9a3ef3f2c0ea746a1ed/packages/react-scripts/template/src/registerServiceWorker.js). From d0aa6b239239067e4506eed75f46449db0255e1f Mon Sep 17 00:00:00 2001 From: Jaco Bovenschen <jaco1994bovenschen@gmail.com> Date: Wed, 28 Jun 2017 21:35:20 +0200 Subject: [PATCH 085/265] Add json and css to lint-staged in template README (#2671) * Add json and css to lint-staged in template README This changes the proposed way about using prettier inside the README.md, because prettier supports css since the 1.4.0 release and json since the 1.5.0 release. Was not sure if it was a good idea to add different regexes for json and css inside the README.md don't have a real opinion about it myself, could maybe easier for starters to do so if they wan't to add things like eslint or stylelint the the commit hooks. * Use capitalization for Javascript, CSS and JSON * Change 'Javascript to JavaScript' --- packages/react-scripts/template/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index aa2ab4340..e23305bd3 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -271,7 +271,7 @@ Start your app by running `npm start`, and start debugging in VS Code by pressin ## Formatting Code Automatically -Prettier is an opinionated JavaScript formatter. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). +Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). To format our code whenever we make a commit in git, we need to install the following dependencies: @@ -307,7 +307,7 @@ Next we add a 'lint-staged' field to the `package.json`, for example: // ... }, + "lint-staged": { -+ "src/**/*.{js,jsx}": [ ++ "src/**/*.{js,jsx,json,css}": [ + "prettier --single-quote --write", + "git add" + ] @@ -2094,7 +2094,7 @@ There are also reports that *uninstalling* Watchman fixes the issue. So if nothi ### `npm run build` exits too early -It is reported that `npm run build` can fail on machines with limited memory and no swap space, which is common in cloud environments. Even with small projects this command can increase RAM usage in your system by hundreds of megabytes, so if you have less than 1 GB of available memory your build is likely to fail with the following message: +It is reported that `npm run build` can fail on machines with limited memory and no swap space, which is common in cloud environments. Even with small projects this command can increase RAM usage in your system by hundreds of megabytes, so if you have less than 1 GB of available memory your build is likely to fail with the following message: > The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process. From 657b3fd6c09160930b4cf1bcc32a4ae3b8dd537c Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Thu, 29 Jun 2017 00:09:13 +0100 Subject: [PATCH 086/265] Test Node 8 on Travis (#2659) * Test Node 8 on Travis We still test Node 7 on AppVeyor * Update e2e-installs.sh * Update e2e-kitchensink.sh * Update e2e-simple.sh * Update e2e-installs.sh * Update e2e-kitchensink.sh * Update e2e-installs.sh * Update e2e-simple.sh * Update e2e-simple.sh * Update e2e-kitchensink.sh * Update e2e-installs.sh --- .travis.yml | 2 +- tasks/e2e-installs.sh | 6 +++++- tasks/e2e-kitchensink.sh | 6 +++++- tasks/e2e-simple.sh | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c60bc267..b08d2bf6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: node_js node_js: - 6 - - 7 + - 8 cache: directories: - node_modules diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 7ea70fac6..073fc8df6 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -95,7 +95,11 @@ fi if hash npm 2>/dev/null then - npm cache clean + # npm 5 is too buggy right now + if [ $(npm -v | head -c 1) -eq 5 ]; then + npm i -g npm@^4.x + fi; + npm cache clean || npm cache verify fi # Prevent lerna bootstrap, we only want top-level dependencies diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index fcd687e4b..7f97fdc44 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -87,7 +87,11 @@ fi if hash npm 2>/dev/null then - npm cache clean + # npm 5 is too buggy right now + if [ $(npm -v | head -c 1) -eq 5 ]; then + npm i -g npm@^4.x + fi; + npm cache clean || npm cache verify fi # Prevent lerna bootstrap, we only want top-level dependencies diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 163bec081..cdcf4a63d 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -86,7 +86,11 @@ fi if hash npm 2>/dev/null then - npm cache clean + # npm 5 is too buggy right now + if [ $(npm -v | head -c 1) -eq 5 ]; then + npm i -g npm@^4.x + fi; + npm cache clean || npm cache verify fi # Prevent lerna bootstrap, we only want top-level dependencies From a0bc9493b47775b2fd9954cbba961250af4aaf54 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Thu, 29 Jun 2017 11:14:16 +0700 Subject: [PATCH 087/265] Add more info about apache client side routing (#2666) * Add more info about apache client side routing After a revelation in https://github.com/facebookincubator/create-react-app/issues/2593#issuecomment-311729534 * Update README.md --- packages/react-scripts/template/README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index e23305bd3..1ad816245 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1751,7 +1751,7 @@ This is because when there is a fresh page load for a `/todos/42`, the server lo }); ``` -If you’re using [Apache](https://httpd.apache.org/), you need to create a `.htaccess` file in the `public` folder that looks like this: +If you’re using [Apache HTTP Server](https://httpd.apache.org/), you need to create a `.htaccess` file in the `public` folder that looks like this: ``` Options -MultiViews @@ -1760,7 +1760,9 @@ If you’re using [Apache](https://httpd.apache.org/), you need to create a `.ht RewriteRule ^ index.html [QSA,L] ``` -It will get copied to the `build` folder when you run `npm run build`. +It will get copied to the `build` folder when you run `npm run build`. + +If you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow [this Stack Overflow answer](https://stackoverflow.com/a/41249464/4878474). Now requests to `/todos/42` will be handled correctly both in development and in production. From aad5987a0317508562138a8454bb83dd22b8b18f Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Thu, 29 Jun 2017 00:45:45 -0400 Subject: [PATCH 088/265] Bootstrap with Yarn when available (#2673) * Bootstrap with Yarn if we can * Update test scripts * Check OS and npm concurrency ability * Windows support * Update bootstrap.js * Install yarn before bootstrap --- bootstrap.js | 67 ++++++++++++++++++++++++++++++++++++++++ lerna.json | 2 +- package.json | 4 +-- tasks/e2e-installs.sh | 8 ++--- tasks/e2e-kitchensink.sh | 8 ++--- tasks/e2e-simple.sh | 12 +++---- 6 files changed, 84 insertions(+), 17 deletions(-) create mode 100644 bootstrap.js diff --git a/bootstrap.js b/bootstrap.js new file mode 100644 index 000000000..b54a1ed9f --- /dev/null +++ b/bootstrap.js @@ -0,0 +1,67 @@ +'use strict'; + +const { execSync, spawn } = require('child_process'); +const { resolve } = require('path'); +const { existsSync } = require('fs'); +const { platform } = require('os'); + +function shouldUseYarn() { + try { + execSync('yarnpkg --version', { stdio: 'ignore' }); + return true; + } catch (e) { + return false; + } +} + +function shouldUseNpmConcurrently() { + try { + const versionString = execSync('npm --version'); + const m = /^(\d+)[.]/.exec(versionString); + // NPM >= 5 support concurrent installs + return Number(m[1]) >= 5; + } catch (e) { + return false; + } +} + +const yarn = shouldUseYarn(); +const windows = platform() === 'win32'; +const lerna = resolve( + __dirname, + 'node_modules', + '.bin', + windows ? 'lerna.cmd' : 'lerna' +); + +if (!existsSync(lerna)) { + if (yarn) { + console.log('Cannot find lerna. Please run `yarn --check-files`.'); + } else { + console.log( + 'Cannot find lerna. Please remove `node_modules` and run `npm install`.' + ); + } + process.exit(1); +} + +let child; +if (yarn) { + // Yarn does not support concurrency + child = spawn(lerna, ['bootstrap', '--npm-client=yarn', '--concurrency=1'], { + stdio: 'inherit', + }); +} else { + let args = ['bootstrap']; + if ( + // The Windows filesystem does not handle concurrency well + windows || + // Only newer npm versions support concurrency + !shouldUseNpmConcurrently() + ) { + args.push('--concurrency=1'); + } + child = spawn(lerna, args, { stdio: 'inherit' }); +} + +child.on('close', code => process.exit(code)); diff --git a/lerna.json b/lerna.json index e2429777d..7ca916a85 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "lerna": "2.0.0-beta.38", + "lerna": "2.0.0-rc.5", "version": "independent", "changelog": { "repo": "facebookincubator/create-react-app", diff --git a/package.json b/package.json index 0cef9dc02..b9abb1ce8 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "create-react-app": "tasks/cra.sh", "e2e": "tasks/e2e-simple.sh", "e2e:docker": "tasks/local-test.sh", - "postinstall": "lerna bootstrap && cd packages/react-error-overlay/ && npm run build:prod", + "postinstall": "node bootstrap.js && cd packages/react-error-overlay/ && npm run build:prod", "publish": "tasks/release.sh", "start": "node packages/react-scripts/scripts/start.js", "test": "node packages/react-scripts/scripts/test.js --env=jsdom", @@ -16,7 +16,7 @@ "devDependencies": { "eslint": "3.19.0", "husky": "^0.13.2", - "lerna": "2.0.0-beta.38", + "lerna": "2.0.0-rc.5", "lerna-changelog": "^0.2.3", "lint-staged": "^3.3.1", "prettier": "^1.5.2" diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 073fc8df6..588642632 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -80,7 +80,7 @@ then # AppVeyor uses an old version of yarn. # Once updated to 0.24.3 or above, the workaround can be removed # and replaced with `yarnpkg cache clean` - # Issues: + # Issues: # https://github.com/yarnpkg/yarn/issues/2591 # https://github.com/appveyor/ci/issues/1576 # https://github.com/facebookincubator/create-react-app/pull/2400 @@ -102,9 +102,9 @@ then npm cache clean || npm cache verify fi -# Prevent lerna bootstrap, we only want top-level dependencies +# Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak -grep -v "lerna bootstrap" package.json > temp && mv temp package.json +grep -v "postinstall" package.json > temp && mv temp package.json npm install mv package.json.bak package.json @@ -116,7 +116,7 @@ then fi # We removed the postinstall, so do it manually -./node_modules/.bin/lerna bootstrap --concurrency=1 +node bootstrap.js cd packages/react-error-overlay/ npm run build:prod diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 7f97fdc44..ebbac271e 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -72,7 +72,7 @@ then # AppVeyor uses an old version of yarn. # Once updated to 0.24.3 or above, the workaround can be removed # and replaced with `yarnpkg cache clean` - # Issues: + # Issues: # https://github.com/yarnpkg/yarn/issues/2591 # https://github.com/appveyor/ci/issues/1576 # https://github.com/facebookincubator/create-react-app/pull/2400 @@ -94,9 +94,9 @@ then npm cache clean || npm cache verify fi -# Prevent lerna bootstrap, we only want top-level dependencies +# Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak -grep -v "lerna bootstrap" package.json > temp && mv temp package.json +grep -v "postinstall" package.json > temp && mv temp package.json npm install mv package.json.bak package.json @@ -108,7 +108,7 @@ then fi # We removed the postinstall, so do it manually -./node_modules/.bin/lerna bootstrap --concurrency=1 +node bootstrap.js cd packages/react-error-overlay/ npm run build:prod diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index cdcf4a63d..48d705eef 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -71,7 +71,7 @@ then # AppVeyor uses an old version of yarn. # Once updated to 0.24.3 or above, the workaround can be removed # and replaced with `yarnpkg cache clean` - # Issues: + # Issues: # https://github.com/yarnpkg/yarn/issues/2591 # https://github.com/appveyor/ci/issues/1576 # https://github.com/facebookincubator/create-react-app/pull/2400 @@ -93,9 +93,9 @@ then npm cache clean || npm cache verify fi -# Prevent lerna bootstrap, we only want top-level dependencies +# Prevent bootstrap, we only want top-level dependencies cp package.json package.json.bak -grep -v "lerna bootstrap" package.json > temp && mv temp package.json +grep -v "postinstall" package.json > temp && mv temp package.json npm install mv package.json.bak package.json @@ -115,9 +115,6 @@ then [[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1 fi -# We removed the postinstall, so do it manually here -./node_modules/.bin/lerna bootstrap --concurrency=1 - if [ "$USE_YARN" = "yes" ] then # Install Yarn so that the test can use it to install packages. @@ -125,6 +122,9 @@ then yarn cache clean fi +# We removed the postinstall, so do it manually here +node bootstrap.js + # Lint own code ./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/ ./node_modules/.bin/eslint --max-warnings 0 packages/create-react-app/ From 7b5a589f3da80c20a318717665b6002b7429dd1b Mon Sep 17 00:00:00 2001 From: Daniel Banck <dbanck@users.noreply.github.com> Date: Thu, 29 Jun 2017 12:33:20 +0200 Subject: [PATCH 089/265] Fix minor typo (#2679) "Styleguidist combines of a style guide, ..." --> "Styleguidist combines a style guide, ..." --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 1ad816245..577502840 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1507,7 +1507,7 @@ Learn more about React Storybook: ### Getting Started with Styleguidist -Styleguidist combines of a style guide, where all your components are presented on a single page with their props documentation and usage examples, with an environment for developing components in isolation, similar to Storybook. In Styleguidist you write examples in Markdown, where each code snippet is rendered as a live editable playground. +Styleguidist combines a style guide, where all your components are presented on a single page with their props documentation and usage examples, with an environment for developing components in isolation, similar to Storybook. In Styleguidist you write examples in Markdown, where each code snippet is rendered as a live editable playground. First, install Styleguidist: From 567d981ee28188a78731b4c45aedaa60b22a03bd Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Thu, 29 Jun 2017 12:59:49 +0100 Subject: [PATCH 090/265] Fix external CSS imports (#2680) * Fix external CSS imports * Add external CSS import to integration test * Fix assertion --- packages/react-scripts/config/webpack.config.dev.js | 3 +++ packages/react-scripts/config/webpack.config.prod.js | 3 +++ .../fixtures/kitchensink/.template.dependencies.json | 1 + .../fixtures/kitchensink/integration/webpack.test.js | 3 +++ .../kitchensink/src/features/webpack/assets/style.css | 6 ++++++ 5 files changed, 16 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 7536b1389..987e7a357 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -219,6 +219,9 @@ module.exports = { { loader: require.resolve('postcss-loader'), options: { + // Necessary for external CSS imports to work + // https://github.com/facebookincubator/create-react-app/issues/2677 + ident: 'postcss', plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index f31fd3ebf..1ba1307bb 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -228,6 +228,9 @@ module.exports = { { loader: require.resolve('postcss-loader'), options: { + // Necessary for external CSS imports to work + // https://github.com/facebookincubator/create-react-app/issues/2677 + ident: 'postcss', plugins: () => [ require('postcss-flexbugs-fixes'), autoprefixer({ diff --git a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json index 63ecaf90d..b8500f804 100644 --- a/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json +++ b/packages/react-scripts/fixtures/kitchensink/.template.dependencies.json @@ -6,6 +6,7 @@ "chai": "3.5.0", "jsdom": "9.8.3", "mocha": "3.2.0", + "normalize.css": "7.0.0", "prop-types": "15.5.6", "test-integrity": "1.0.0" } diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index bda69cc61..e3845e79e 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -17,6 +17,9 @@ describe('Integration', () => { expect( doc.getElementsByTagName('style')[0].textContent.replace(/\s/g, '') + ).to.match(/html\{/); + expect( + doc.getElementsByTagName('style')[1].textContent.replace(/\s/g, '') ).to.match(/#feature-css-inclusion\{background:.+;color:.+}/); }); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/style.css b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/style.css index c399d1aca..9502cfaa1 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/style.css +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/assets/style.css @@ -1,3 +1,9 @@ +/* + * Ensure CSS inclusion doesn't regress + * https://github.com/facebookincubator/create-react-app/issues/2677 + */ +@import '~normalize.css/normalize.css'; + #feature-css-inclusion { background: palevioletred; color: papayawhip; From 29df7290b903252f5ecd9d4567001e0cab179257 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Thu, 29 Jun 2017 13:06:42 +0100 Subject: [PATCH 091/265] Changelog for 1.0.9 (#2682) --- CHANGELOG.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5ef6906..08b661de6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,48 @@ +## 1.0.9 (June 29, 2017) + +#### :bug: Bug Fix + +* `react-scripts` + + * [#2680](https://github.com/facebookincubator/create-react-app/pull/2680) Fix external CSS imports. ([@gaearon](https://github.com/gaearon)) + +#### :memo: Documentation + +* `react-scripts` + + * [#2679](https://github.com/facebookincubator/create-react-app/pull/2679) Fix minor typo. ([@dbanck](https://github.com/dbanck)) + * [#2666](https://github.com/facebookincubator/create-react-app/pull/2666) Add more info about Apache client side routing. ([@viankakrisna](https://github.com/viankakrisna)) + * [#2671](https://github.com/facebookincubator/create-react-app/pull/2671) Add JSON and CSS to Prettier instructions. ([@jbovenschen](https://github.com/jbovenschen)) + +#### :house: Internal + +* Other + + * [#2673](https://github.com/facebookincubator/create-react-app/pull/2673) Bootstrap with Yarn. ([@Timer](https://github.com/Timer)) + * [#2659](https://github.com/facebookincubator/create-react-app/pull/2659) Test Node 8 on Travis. ([@gaearon](https://github.com/gaearon)) + +#### Committers: 5 + +- Ade Viankakrisna Fadlil ([viankakrisna](https://github.com/viankakrisna)) +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Daniel Banck ([dbanck](https://github.com/dbanck)) +- Jaco Bovenschen ([jbovenschen](https://github.com/jbovenschen)) +- Joe Haddad ([Timer](https://github.com/Timer)) + +### Migrating from 1.0.8 to 1.0.9 + +Inside any created project that has not been ejected, run: + +``` +npm install --save-dev --save-exact react-scripts@1.0.9 +``` + +or + +``` +yarn add --dev --exact react-scripts@1.0.9 +``` + ## 1.0.8 (June 28, 2017) #### :bug: Bug Fix From adf334f88690596b5ffd3bb62e25cec7797e3b34 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Thu, 29 Jun 2017 13:11:46 +0100 Subject: [PATCH 092/265] Publish - react-scripts@1.0.9 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index f3750a16a..ef3ba4881 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.8", + "version": "1.0.9", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", From 29888fcc7a5a6d658f41dc58fb2a7fa617b719e0 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay <forbes@lindesay.co.uk> Date: Thu, 29 Jun 2017 14:00:10 +0100 Subject: [PATCH 093/265] Fix typo in README link (#2684) --- .github/ISSUE_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index eec13d075..dc3c02df8 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -64,7 +64,7 @@ Please scan these few sections for common problems. Additionally, you can search the User Guide itself for something you're having issues with: - https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.me + https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md If you didn't find the solution, please share which words you searched for. This helps us improve documentation for future readers who might encounter the same problem. From f9f812571542cb10550abab428e084aa4114bfa1 Mon Sep 17 00:00:00 2001 From: Ben Brostoff <ben.brostoff@gmail.com> Date: Thu, 29 Jun 2017 13:06:40 -0400 Subject: [PATCH 094/265] Fix typo (#2683) --- packages/create-react-app/createReactApp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 9dc7b4ff3..4509b4978 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -169,7 +169,7 @@ function createApp(name, verbose, version, template) { if (!semver.satisfies(process.version, '>=6.0.0')) { console.log( chalk.yellow( - `You are using Node ${process.version} so the project will be boostrapped with an old unsupported version of tools.\n\n` + + `You are using Node ${process.version} so the project will be bootstrapped with an old unsupported version of tools.\n\n` + `Please update to Node 6 or higher for a better, fully supported experience.\n` ) ); From 5e11b48b38c78509200aabe3994130d80e80e901 Mon Sep 17 00:00:00 2001 From: Patrick Hooper <patrick.d.hooper@gmail.com> Date: Thu, 29 Jun 2017 13:07:04 -0400 Subject: [PATCH 095/265] Downgrade `strip-ansi` package to 3.0.1 (#2692) --- packages/react-dev-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 4b01b465d..9fbbd7640 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -49,7 +49,7 @@ "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", - "strip-ansi": "4.0.0", + "strip-ansi": "3.0.1", "text-table": "0.2.0" } } From d3518d6254939751dc89f5b0faa9f537dbd1b6d4 Mon Sep 17 00:00:00 2001 From: JoeCortopassi <joe@joecortopassi.com> Date: Thu, 29 Jun 2017 10:37:26 -0700 Subject: [PATCH 096/265] Added `gluestick` to the alternatives section (#2402) Added `gluestick` to the alternatives section --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0c428ef65..9f40a4d98 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ Notable alternatives also include: * [react-app](https://github.com/kriasoft/react-app) * [dev-toolkit](https://github.com/stoikerty/dev-toolkit) * [sku](https://github.com/seek-oss/sku) +* [gluestick](https://github.com/TrueCar/gluestick) You can also use module bundlers like [webpack](http://webpack.js.org) and [Browserify](http://browserify.org/) directly.<br> React documentation includes [a walkthrough](https://facebook.github.io/react/docs/package-management.html) on this topic. From 82ed81a03cae32e45b405478cfb7aa54585c5e48 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Thu, 29 Jun 2017 13:39:24 -0400 Subject: [PATCH 097/265] Upgrade flow (#2693) Resolves #2670 --- packages/react-error-overlay/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index f29aedd0f..dff62a584 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -49,7 +49,7 @@ "eslint-plugin-import": "2.2.0", "eslint-plugin-jsx-a11y": "5.0.3", "eslint-plugin-react": "7.0.1", - "flow-bin": "0.46.0", + "flow-bin": "0.49.1", "jest": "20.0.1", "jest-fetch-mock": "1.1.1" }, From 19ba8874109b2323044f13bc639abfd870c134c3 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Thu, 29 Jun 2017 18:58:19 +0100 Subject: [PATCH 098/265] Update CHANGELOG.md --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08b661de6..3bd982362 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,13 +34,13 @@ Inside any created project that has not been ejected, run: ``` -npm install --save-dev --save-exact react-scripts@1.0.9 +npm install --save --save-exact react-scripts@1.0.9 ``` or ``` -yarn add --dev --exact react-scripts@1.0.9 +yarn add --exact react-scripts@1.0.9 ``` ## 1.0.8 (June 28, 2017) From c1221eb1109906965d4d87f91dd6593d9db5eb7f Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Thu, 29 Jun 2017 19:01:37 +0100 Subject: [PATCH 099/265] Changelog for 1.0.10 (#2694) * Add changelog for 1.0.10 * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd982362..0e2c349eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,41 @@ +## 1.0.10 (June 29, 2017) + +#### :bug: Bug Fix + +* `react-dev-utils` + + * [#2692](https://github.com/facebookincubator/create-react-app/pull/2692) Fix IE11 crash in development. ([@pdhoopr](https://github.com/pdhoopr)) + +* `create-react-app` + * [#2683](https://github.com/facebookincubator/create-react-app/pull/2683) Fix a typo. ([@BenBrostoff](https://github.com/BenBrostoff)) + +#### :memo: Documentation + +* README + + * [#2402](https://github.com/facebookincubator/create-react-app/pull/2402) Added `gluestick` to the alternatives section. ([@JoeCortopassi](https://github.com/JoeCortopassi)) + +#### Committers: 5 +- Ben Brostoff ([BenBrostoff](https://github.com/BenBrostoff)) +- Forbes Lindesay ([ForbesLindesay](https://github.com/ForbesLindesay)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Patrick Hooper ([pdhoopr](https://github.com/pdhoopr)) +- [JoeCortopassi](https://github.com/JoeCortopassi) + +### Migrating from 1.0.9 to 1.0.10 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.10 +``` + +or + +``` +yarn add --exact react-scripts@1.0.10 +``` + ## 1.0.9 (June 29, 2017) #### :bug: Bug Fix From ad35fd1d13f6497bd4b4244896e3c9e88ccef419 Mon Sep 17 00:00:00 2001 From: Dan Abramov <gaearon@fb.com> Date: Thu, 29 Jun 2017 19:03:41 +0100 Subject: [PATCH 100/265] Publish - create-react-app@1.3.3 - react-dev-utils@3.0.2 - react-error-overlay@1.0.9 - react-scripts@1.0.10 --- packages/create-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 4 ++-- packages/react-scripts/package.json | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 613007b40..28502ca07 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,6 +1,6 @@ { "name": "create-react-app", - "version": "1.3.2", + "version": "1.3.3", "keywords": [ "react" ], diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 9fbbd7640..b4539788d 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "3.0.1", + "version": "3.0.2", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index dff62a584..15bf9e484 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "1.0.8", + "version": "1.0.9", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { @@ -34,7 +34,7 @@ "anser": "1.2.5", "babel-code-frame": "6.22.0", "babel-runtime": "6.23.0", - "react-dev-utils": "^3.0.1", + "react-dev-utils": "^3.0.2", "settle-promise": "1.0.0", "source-map": "0.5.6" }, diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index ef3ba4881..5c1225e1d 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.9", + "version": "1.0.10", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -48,8 +48,8 @@ "postcss-flexbugs-fixes": "3.0.0", "postcss-loader": "2.0.6", "promise": "7.1.1", - "react-dev-utils": "^3.0.1", - "react-error-overlay": "^1.0.8", + "react-dev-utils": "^3.0.2", + "react-error-overlay": "^1.0.9", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.3", "url-loader": "0.5.9", From b0cd28663d1e4a744c35549dd7dc3c4f2c6fc62d Mon Sep 17 00:00:00 2001 From: Alexey Raspopov <oleksii.raspopov@gmail.com> Date: Sat, 1 Jul 2017 02:05:25 +0300 Subject: [PATCH 101/265] Issue template: fix env list ordering (#2697) --- .github/ISSUE_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index dc3c02df8..ca97a668b 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -81,8 +81,8 @@ 1. `node -v`: 2. `npm -v`: -4. `yarn --version` (if you use Yarn): -3. `npm ls react-scripts` (if you haven’t ejected): +3. `yarn --version` (if you use Yarn): +4. `npm ls react-scripts` (if you haven’t ejected): Then, specify: From df00d8071abf8dac07510d76beb09b3f15b6f721 Mon Sep 17 00:00:00 2001 From: Kristoffer <denkristoffer@users.noreply.github.com> Date: Sat, 1 Jul 2017 16:49:49 +0200 Subject: [PATCH 102/265] allowTaggedTemplates to avoid warnings from SC's (#2701) --- packages/eslint-config-react-app/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 7298a8c3b..a8b900f94 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -185,6 +185,7 @@ module.exports = { { allowShortCircuit: true, allowTernary: true, + allowTaggedTemplates: true, }, ], 'no-unused-labels': 'warn', From 85a9bc8590528bd1e5bab186918721feb64c7d78 Mon Sep 17 00:00:00 2001 From: Danny Ho <danho123@gmail.com> Date: Mon, 3 Jul 2017 13:03:00 -0700 Subject: [PATCH 103/265] Remove Windows note for source-map-explorer (#2719) Glob support has been added in source-map-explorer@1.4+ --- packages/react-scripts/template/README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 577502840..6df4d43d7 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1671,16 +1671,6 @@ Then in `package.json`, add the following line to `scripts`: "test": "react-scripts test --env=jsdom", ``` ->**Note:** -> ->This doesn't quite work on Windows because it doesn't automatically expand `*` in the filepath. For now, the workaround is to look at the full hashed filename in `build/static/js` (e.g. `main.89b7e95a.js`) and copy it into `package.json` when you're running the analyzer. For example: -> ->```diff ->+ "analyze": "source-map-explorer build/static/js/main.89b7e95a.js", ->``` -> ->Unfortunately it will be different after every build. You can express support for fixing this on Windows [in this issue](https://github.com/danvk/source-map-explorer/issues/52). - Then to analyze the bundle run the production build then run the analyze script. From f495c15578403cf2dbac211493ae8fb6ac742415 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge <trygveaa@gmail.com> Date: Wed, 5 Jul 2017 00:44:55 +0200 Subject: [PATCH 104/265] Reorder vim arguments in launchEditor so --remote works (#2723) This allows you to set REACT_EDITOR to 'vim --remote', so the file can be opened in an already running vim process. When using vim without remote, it works in the same way as before. When launching vim without --remote, the order of the line and path arguments doesn't matter. However, when using --remote the line argument has to precede the path. This happens to be the same as joe and emacs uses, so the vim cases were just moved there. I haven't tested this with mvim, but the documentation says the same as the vim documentation, so I assume it works the same. --- packages/react-dev-utils/launchEditor.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index bcf0a5060..6f623dcf8 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -58,9 +58,6 @@ function addWorkspaceToArgumentsIfExists(args, workspace) { function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { const editorBasename = path.basename(editor).replace(/\.(exe|cmd|bat)$/i, ''); switch (editorBasename) { - case 'vim': - case 'mvim': - return [fileName, '+' + lineNumber]; case 'atom': case 'Atom': case 'Atom Beta': @@ -74,6 +71,8 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { return [fileName + ':' + lineNumber]; case 'notepad++': return ['-n' + lineNumber, fileName]; + case 'vim': + case 'mvim': case 'joe': case 'emacs': case 'emacsclient': From 8442cf313b351dab840fedf348785b61e87572ea Mon Sep 17 00:00:00 2001 From: Forbes Lindesay <forbes@lindesay.co.uk> Date: Thu, 6 Jul 2017 16:47:41 +0100 Subject: [PATCH 105/265] Update link to issue blocking JSX hoisting (#2732) --- packages/babel-preset-react-app/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index c8f20dde6..f6102dc05 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -129,10 +129,7 @@ if (env === 'test') { if (env === 'production') { // Optimization: hoist JSX that never changes out of render() - // Disabled because of issues: - // * https://github.com/facebookincubator/create-react-app/issues/525 - // * https://phabricator.babeljs.io/search/query/pCNlnC2xzwzx/ - // * https://github.com/babel/babel/issues/4516 + // 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') From 804ac0009548cdddebb571a899c718572be08406 Mon Sep 17 00:00:00 2001 From: Dan Ristea <danraduristea@gmail.com> Date: Fri, 7 Jul 2017 11:34:56 +0100 Subject: [PATCH 106/265] Support PyCharm in launchEditor (#2740) PyCharm has the same signature as WebStorm and PhpStorm `<editor> <projectPath> --line <number> <filePath>` so it can reuse the logic from those. https://www.jetbrains.com/help/pycharm/opening-files-from-command-line.html Tested with PyCharm Pro 2017.1.4 on MacOS 10.12 --- packages/react-dev-utils/launchEditor.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index 6f623dcf8..bc1bd4d6e 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -91,6 +91,8 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { case 'webstorm64': case 'phpstorm': case 'phpstorm64': + case 'pycharm': + case 'pycharm64': return addWorkspaceToArgumentsIfExists( ['--line', lineNumber, fileName], workspace From 16f0d4a56cbfd1525de6da52005f73ce7a5eafc6 Mon Sep 17 00:00:00 2001 From: Mostafa Hajizadeh <mostafa.h@gmail.com> Date: Fri, 7 Jul 2017 15:07:32 +0430 Subject: [PATCH 107/265] Add "node" to Jest's moduleFileExtensions (#2738) Jest's default value for this option is ["js", "json", "jsx", "node"]. CRA's current value is ["web.js", "js", "json", "web.jsx", "jsx"], which is missing one of default ones: "node". This change fixes that. This "node" extension is used in packages that use native code. --- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index de74958ef..bc4ebf822 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -43,7 +43,7 @@ module.exports = (resolve, rootDir, isEjecting) => { moduleNameMapper: { '^react-native$': 'react-native-web', }, - moduleFileExtensions: ['web.js', 'js', 'json', 'web.jsx', 'jsx'], + moduleFileExtensions: ['web.js', 'js', 'json', 'web.jsx', 'jsx', 'node'], }; if (rootDir) { config.rootDir = rootDir; From bbbc15dc8ebdcb1b5a631b9b5537e26c28c146cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=90inh=20Quang=20Trung?= <trungdq88@gmail.com> Date: Fri, 7 Jul 2017 17:40:29 +0700 Subject: [PATCH 108/265] ESLint 4 (#2735) * Update eslint-loader 1.7.1 -> 1.9.0 * Add eslintPath option * Update eslint 3.19.0 -> 4.1.1 * Update peer dependencies * Move eslintPath config to outside @remove-on-eject --- packages/eslint-config-react-app/package.json | 2 +- packages/react-scripts/config/webpack.config.dev.js | 1 + packages/react-scripts/config/webpack.config.prod.js | 1 + packages/react-scripts/package.json | 8 ++++---- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index cd36a70e5..559e78b25 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -12,7 +12,7 @@ ], "peerDependencies": { "babel-eslint": "^7.2.3", - "eslint": "^3.19.0", + "eslint": "^4.1.1", "eslint-plugin-flowtype": "^2.33.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^5.0.3", diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 987e7a357..ea749495b 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -136,6 +136,7 @@ module.exports = { { options: { formatter: eslintFormatter, + eslintPath: require.resolve('eslint'), // @remove-on-eject-begin baseConfig: { extends: [require.resolve('eslint-config-react-app')], diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 1ba1307bb..f943ef9ec 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -136,6 +136,7 @@ module.exports = { { options: { formatter: eslintFormatter, + eslintPath: require.resolve('eslint'), // @remove-on-eject-begin // TODO: consider separate config for production, // e.g. to enable no-console and no-debugger only in production. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 5c1225e1d..d0eddad69 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -32,12 +32,12 @@ "chalk": "1.1.3", "css-loader": "0.28.4", "dotenv": "4.0.0", - "eslint": "3.19.0", + "eslint": "4.1.1", "eslint-config-react-app": "^1.0.5", - "eslint-loader": "1.7.1", + "eslint-loader": "1.9.0", "eslint-plugin-flowtype": "2.34.0", - "eslint-plugin-import": "2.2.0", - "eslint-plugin-jsx-a11y": "5.0.3", + "eslint-plugin-import": "2.7.0", + "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.1.0", "extract-text-webpack-plugin": "2.1.2", "file-loader": "0.11.2", From a08eb3b44b47b3a1c9776e0859943f610ab50085 Mon Sep 17 00:00:00 2001 From: Andreas Hoffmann <furizaa@gmail.com> Date: Sun, 9 Jul 2017 22:59:19 +0200 Subject: [PATCH 109/265] Use Rule.oneOf to resolve correct loader (#2747) * Use oneOf to resolve correct loader * Add html and json fallthrough again * Use oneOf to resolve correct loader in dev * Document file-loaders `js` exclusion * Remove `jsx` from exclusion in prod config --- .../config/webpack.config.dev.js | 154 +++++++------- .../config/webpack.config.prod.js | 192 +++++++++--------- 2 files changed, 171 insertions(+), 175 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index ea749495b..253bc34f0 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -150,97 +150,95 @@ module.exports = { ], include: paths.appSrc, }, - // ** ADDING/UPDATING LOADERS ** - // The "file" loader handles all assets unless explicitly excluded. - // The `exclude` list *must* be updated with every change to loader extensions. - // When adding a new loader, you must add its `test` - // as a new entry in the `exclude` list for "file" loader. - - // "file" loader makes sure those assets get served by WebpackDevServer. - // When you `import` an asset, you get its (virtual) filename. - // In production, they would get copied to the `build` folder. - { - exclude: [ - /\.html$/, - /\.(js|jsx)$/, - /\.css$/, - /\.json$/, - /\.bmp$/, - /\.gif$/, - /\.jpe?g$/, - /\.png$/, - ], - loader: require.resolve('file-loader'), - options: { - name: 'static/media/[name].[hash:8].[ext]', - }, - }, - // "url" loader works like "file" loader except that it embeds assets - // smaller than specified limit in bytes as data URLs to avoid requests. - // A missing `test` is equivalent to a match. - { - test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], - loader: require.resolve('url-loader'), - options: { - limit: 10000, - name: 'static/media/[name].[hash:8].[ext]', - }, - }, - // Process JS with Babel. { - test: /\.(js|jsx)$/, - include: paths.appSrc, - loader: require.resolve('babel-loader'), - options: { - // @remove-on-eject-begin - babelrc: false, - presets: [require.resolve('babel-preset-react-app')], - // @remove-on-eject-end - // This is a feature of `babel-loader` for webpack (not Babel itself). - // It enables caching results in ./node_modules/.cache/babel-loader/ - // directory for faster rebuilds. - cacheDirectory: true, - }, - }, - // "postcss" loader applies autoprefixer to our CSS. - // "css" loader resolves paths in CSS and adds assets as dependencies. - // "style" loader turns CSS into JS modules that inject <style> tags. - // In production, we use a plugin to extract that CSS to a file, but - // in development "style" loader enables hot editing of CSS. - { - test: /\.css$/, - use: [ - require.resolve('style-loader'), + // "oneOf" will traverse all following loaders until one will + // match the requirements. When no loader matches it will fall + // back to the "file" loader at the end of the loader list. + oneOf: [ + // "url" loader works like "file" loader except that it embeds assets + // smaller than specified limit in bytes as data URLs to avoid requests. + // A missing `test` is equivalent to a match. { - loader: require.resolve('css-loader'), + test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], + loader: require.resolve('url-loader'), options: { - importLoaders: 1, + limit: 10000, + name: 'static/media/[name].[hash:8].[ext]', }, }, + // Process JS with Babel. { - loader: require.resolve('postcss-loader'), + test: /\.(js|jsx)$/, + include: paths.appSrc, + loader: require.resolve('babel-loader'), options: { - // Necessary for external CSS imports to work - // https://github.com/facebookincubator/create-react-app/issues/2677 - ident: 'postcss', - plugins: () => [ - require('postcss-flexbugs-fixes'), - autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway + // @remove-on-eject-begin + babelrc: false, + presets: [require.resolve('babel-preset-react-app')], + // @remove-on-eject-end + // This is a feature of `babel-loader` for webpack (not Babel itself). + // It enables caching results in ./node_modules/.cache/babel-loader/ + // directory for faster rebuilds. + cacheDirectory: true, + }, + }, + // "postcss" loader applies autoprefixer to our CSS. + // "css" loader resolves paths in CSS and adds assets as dependencies. + // "style" loader turns CSS into JS modules that inject <style> tags. + // In production, we use a plugin to extract that CSS to a file, but + // in development "style" loader enables hot editing of CSS. + { + test: /\.css$/, + use: [ + require.resolve('style-loader'), + { + loader: require.resolve('css-loader'), + options: { + importLoaders: 1, + }, + }, + { + loader: require.resolve('postcss-loader'), + options: { + // Necessary for external CSS imports to work + // https://github.com/facebookincubator/create-react-app/issues/2677 + ident: 'postcss', + 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', + }), ], - flexbox: 'no-2009', - }), - ], + }, + }, + ], + }, + // "file" loader makes sure those assets get served by WebpackDevServer. + // When you `import` an asset, you get its (virtual) filename. + // In production, they would get copied to the `build` folder. + // This loader don't uses a "test" so it will catch all modules + // that fall through the other loaders. + { + // Exclude `js` files to keep "css" loader working as it injects + // it's runtime that would otherwise processed through "file" loader. + // Also exclude `html` and `json` extensions so they get processed + // by webpacks internal loaders. + exclude: [/\.js$/, /\.html$/, /\.json$/], + loader: require.resolve('file-loader'), + options: { + name: 'static/media/[name].[hash:8].[ext]', }, }, ], }, // ** STOP ** Are you adding a new loader? - // Remember to add the new extension(s) to the "file" loader exclusion list. + // Make sure to add the new loader(s) before the "file" loader. ], }, plugins: [ diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index f943ef9ec..0077c34a3 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -152,109 +152,107 @@ module.exports = { ], include: paths.appSrc, }, - // ** ADDING/UPDATING LOADERS ** - // The "file" loader handles all assets unless explicitly excluded. - // The `exclude` list *must* be updated with every change to loader extensions. - // When adding a new loader, you must add its `test` - // as a new entry in the `exclude` list in the "file" loader. - - // "file" loader makes sure those assets end up in the `build` folder. - // When you `import` an asset, you get its filename. - { - exclude: [ - /\.html$/, - /\.(js|jsx)$/, - /\.css$/, - /\.json$/, - /\.bmp$/, - /\.gif$/, - /\.jpe?g$/, - /\.png$/, - ], - loader: require.resolve('file-loader'), - options: { - name: 'static/media/[name].[hash:8].[ext]', - }, - }, - // "url" loader works just like "file" loader but it also embeds - // assets smaller than specified size as data URLs to avoid requests. - { - test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], - loader: require.resolve('url-loader'), - options: { - limit: 10000, - name: 'static/media/[name].[hash:8].[ext]', - }, - }, - // Process JS with Babel. - { - test: /\.(js|jsx)$/, - include: paths.appSrc, - loader: require.resolve('babel-loader'), - options: { - // @remove-on-eject-begin - babelrc: false, - presets: [require.resolve('babel-preset-react-app')], - // @remove-on-eject-end - compact: true, - }, - }, - // The notation here is somewhat confusing. - // "postcss" loader applies autoprefixer to our CSS. - // "css" loader resolves paths in CSS and adds assets as dependencies. - // "style" loader normally turns CSS into JS modules injecting <style>, - // but unlike in development configuration, we do something different. - // `ExtractTextPlugin` first applies the "postcss" and "css" loaders - // (second argument), then grabs the result CSS and puts it into a - // separate file in our build process. This way we actually ship - // a single CSS file in production instead of JS code injecting <style> - // tags. If you use code splitting, however, any async bundles will still - // use the "style" loader inside the async code so CSS from them won't be - // in the main CSS file. { - test: /\.css$/, - loader: ExtractTextPlugin.extract( - Object.assign( - { - fallback: require.resolve('style-loader'), - use: [ - { - loader: require.resolve('css-loader'), - options: { - importLoaders: 1, - minimize: true, - sourceMap: true, - }, - }, + // "oneOf" will traverse all following loaders until one will + // match the requirements. When no loader matches it will fall + // back to the "file" loader at the end of the loader list. + oneOf: [ + // "url" loader works just like "file" loader but it also embeds + // assets smaller than specified size as data URLs to avoid requests. + { + test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/], + loader: require.resolve('url-loader'), + options: { + limit: 10000, + name: 'static/media/[name].[hash:8].[ext]', + }, + }, + // Process JS with Babel. + { + test: /\.(js|jsx)$/, + include: paths.appSrc, + loader: require.resolve('babel-loader'), + options: { + // @remove-on-eject-begin + babelrc: false, + presets: [require.resolve('babel-preset-react-app')], + // @remove-on-eject-end + compact: true, + }, + }, + // The notation here is somewhat confusing. + // "postcss" loader applies autoprefixer to our CSS. + // "css" loader resolves paths in CSS and adds assets as dependencies. + // "style" loader normally turns CSS into JS modules injecting <style>, + // but unlike in development configuration, we do something different. + // `ExtractTextPlugin` first applies the "postcss" and "css" loaders + // (second argument), then grabs the result CSS and puts it into a + // separate file in our build process. This way we actually ship + // a single CSS file in production instead of JS code injecting <style> + // tags. If you use code splitting, however, any async bundles will still + // use the "style" loader inside the async code so CSS from them won't be + // in the main CSS file. + { + test: /\.css$/, + loader: ExtractTextPlugin.extract( + Object.assign( { - loader: require.resolve('postcss-loader'), - options: { - // Necessary for external CSS imports to work - // https://github.com/facebookincubator/create-react-app/issues/2677 - ident: 'postcss', - plugins: () => [ - require('postcss-flexbugs-fixes'), - autoprefixer({ - browsers: [ - '>1%', - 'last 4 versions', - 'Firefox ESR', - 'not ie < 9', // React doesn't support IE8 anyway + fallback: require.resolve('style-loader'), + use: [ + { + loader: require.resolve('css-loader'), + options: { + importLoaders: 1, + minimize: true, + sourceMap: true, + }, + }, + { + loader: require.resolve('postcss-loader'), + options: { + // Necessary for external CSS imports to work + // https://github.com/facebookincubator/create-react-app/issues/2677 + ident: 'postcss', + 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', + }), ], - flexbox: 'no-2009', - }), - ], - }, + }, + }, + ], }, - ], + extractTextPluginOptions + ) + ), + // Note: this won't work without `new ExtractTextPlugin()` in `plugins`. + }, + // "file" loader makes sure assets end up in the `build` folder. + // When you `import` an asset, you get its filename. + // This loader don't uses a "test" so it will catch all modules + // that fall through the other loaders. + { + loader: require.resolve('file-loader'), + // Exclude `js` files to keep "css" loader working as it injects + // it's runtime that would otherwise processed through "file" loader. + // Also exclude `html` and `json` extensions so they get processed + // by webpacks internal loaders. + exclude: [/\.js$/, /\.html$/, /\.json$/], + options: { + name: 'static/media/[name].[hash:8].[ext]', }, - extractTextPluginOptions - ) - ), - // Note: this won't work without `new ExtractTextPlugin()` in `plugins`. + }, + // ** STOP ** Are you adding a new loader? + // Make sure to add the new loader(s) before the "file" loader. + ], }, - // ** STOP ** Are you adding a new loader? - // Remember to add the new extension(s) to the "file" loader exclusion list. ], }, plugins: [ From 3ca6bae25f43b01f87129fb59a96ef0c23e05473 Mon Sep 17 00:00:00 2001 From: Dan Ristea <danraduristea@gmail.com> Date: Sun, 9 Jul 2017 22:15:43 +0100 Subject: [PATCH 110/265] Autodetect JetBrains IDEs (#2754) Autodetect PyCharm (Pro and CE), WebStorm, PhpStorm, IntelliJ IDEA, RubyMine, CLion, and AppCode Added IntelliJ IDEA, RubyMine, CLion, and AppCode to list of IDEs. It has the same signature as WebStorm and PhpStorm `<editor> <projectPath> --line <number> <filePath>` so it can reuse the logic from those. Removed older integrations of AppCode, IntelliJ IDEA https://www.jetbrains.com/help/idea/opening-files-from-command-line.html https://www.jetbrains.com/help/pycharm/opening-files-from-command-line.html https://www.jetbrains.com/help/phpstorm/opening-files-from-command-line.html https://www.jetbrains.com/help/ruby/opening-files-from-command-line.html https://www.jetbrains.com/help/webstorm/opening-files-from-command-line.html Tested with Appcode 2017.1.3, CLion 2017.1.3, Intellij Idea 2017.1.5, PhpStorm 2017.1.4, PyCharm (Pro and CE) 2017.1.4, RubyMine 2017.1.5, and WebStorm 2017.1.4 on MacOS 10.12 Tested with 64-bit CLion 2017.1.3, Intellij Idea 2017.1.5, PhpStorm 2017.1.4, PyCharm (Pro and CE) 2017.1.4, RubyMine 2017.1.5, and WebStorm 2017.1.4 on a Windows 10 VM Relates to #2636 --- packages/react-dev-utils/launchEditor.js | 41 +++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index bc1bd4d6e..e1ea29c88 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -38,6 +38,22 @@ const COMMON_EDITORS_OSX = { '/Applications/Sublime Text 2.app/Contents/MacOS/Sublime Text 2': '/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl', '/Applications/Visual Studio Code.app/Contents/MacOS/Electron': 'code', + '/Applications/AppCode.app/Contents/MacOS/appcode': + '/Applications/AppCode.app/Contents/MacOS/appcode', + '/Applications/CLion.app/Contents/MacOS/clion': + '/Applications/CLion.app/Contents/MacOS/clion', + '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea': + '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea', + '/Applications/PhpStorm.app/Contents/MacOS/phpstorm': + '/Applications/PhpStorm.app/Contents/MacOS/phpstorm', + '/Applications/PyCharm.app/Contents/MacOS/pycharm': + '/Applications/PyCharm.app/Contents/MacOS/pycharm', + '/Applications/PyCharm CE.app/Contents/MacOS/pycharm': + '/Applications/PyCharm CE.app/Contents/MacOS/pycharm', + '/Applications/RubyMine.app/Contents/MacOS/rubymine': + '/Applications/RubyMine.app/Contents/MacOS/rubymine', + '/Applications/WebStorm.app/Contents/MacOS/webstorm': + '/Applications/WebStorm.app/Contents/MacOS/webstorm', }; const COMMON_EDITORS_WIN = [ @@ -46,6 +62,18 @@ const COMMON_EDITORS_WIN = [ 'atom.exe', 'sublime_text.exe', 'notepad++.exe', + 'clion.exe', + 'clion64.exe', + 'idea.exe', + 'idea64.exe', + 'phpstorm.exe', + 'phpstorm64.exe', + 'pycharm.exe', + 'pycharm64.exe', + 'rubymine.exe', + 'rubymine64.exe', + 'webstorm.exe', + 'webstorm64.exe', ]; function addWorkspaceToArgumentsIfExists(args, workspace) { @@ -65,9 +93,7 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { case 'sublime': case 'sublime_text': case 'wstorm': - case 'appcode': case 'charm': - case 'idea': return [fileName + ':' + lineNumber]; case 'notepad++': return ['-n' + lineNumber, fileName]; @@ -87,12 +113,19 @@ function getArgumentsForLineNumber(editor, fileName, lineNumber, workspace) { ['-g', fileName + ':' + lineNumber], workspace ); - case 'webstorm': - case 'webstorm64': + case 'appcode': + case 'clion': + case 'clion64': + case 'idea': + case 'idea64': case 'phpstorm': case 'phpstorm64': case 'pycharm': case 'pycharm64': + case 'rubymine': + case 'rubymine64': + case 'webstorm': + case 'webstorm64': return addWorkspaceToArgumentsIfExists( ['--line', lineNumber, fileName], workspace From 36904959996d2b5a32b737af43635fffad91181c Mon Sep 17 00:00:00 2001 From: Owen Flood <owenhflood@gmail.com> Date: Mon, 10 Jul 2017 16:43:17 -0700 Subject: [PATCH 111/265] Don't prompt to install serve if already installed (#2761) * dont prompt if serve is already installed * change name for readability * Pin the version --- packages/react-dev-utils/package.json | 1 + packages/react-dev-utils/printHostingInstructions.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index b4539788d..e09e990d0 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -41,6 +41,7 @@ "detect-port-alt": "1.1.3", "escape-string-regexp": "1.0.5", "filesize": "3.3.0", + "global-modules": "1.0.0", "gzip-size": "3.0.0", "html-entities": "1.2.1", "inquirer": "3.1.1", diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js index f9882d44a..2ef25767a 100644 --- a/packages/react-dev-utils/printHostingInstructions.js +++ b/packages/react-dev-utils/printHostingInstructions.js @@ -11,6 +11,8 @@ const chalk = require('chalk'); const url = require('url'); +const globalModules = require('global-modules'); +const fs = require('fs'); function printHostingInstructions( appPackage, @@ -121,10 +123,12 @@ function printHostingInstructions( ); console.log('You may serve it with a static server:'); console.log(); - if (useYarn) { - console.log(` ${chalk.cyan('yarn')} global add serve`); - } else { - console.log(` ${chalk.cyan('npm')} install -g serve`); + if (!fs.existsSync(`${globalModules}/serve`)) { + if (useYarn) { + console.log(` ${chalk.cyan('yarn')} global add serve`); + } else { + console.log(` ${chalk.cyan('npm')} install -g serve`); + } } console.log(` ${chalk.cyan('serve')} -s ${buildFolder}`); console.log(); From a7e71442c65f739b71513156c758098412fa2977 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Thu, 13 Jul 2017 02:49:43 +0700 Subject: [PATCH 112/265] Docs for react-router v4 basename feature (#2668) * Docs for react-router v4 basename feature Fix https://github.com/facebookincubator/create-react-app/issues/2593 * Update README.md * Update README.md * Update README.md * Update README.md --- packages/react-scripts/template/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 6df4d43d7..0783e878e 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1776,6 +1776,15 @@ To override this, specify the `homepage` in your `package.json`, for example: This will let Create React App correctly infer the root path to use in the generated HTML file. +**Note**: If you are using `react-router@^4`, you can root `<Link>`s using the `basename` prop on any `<Router>`.<br> +More information [here](https://reacttraining.com/react-router/web/api/BrowserRouter/basename-string).<br> +<br> +For example: +```js +<BrowserRouter basename="/calendar"/> +<Link to="/today"/> // renders <a href="/calendar/today"> +``` + #### Serving the Same Build from Different Paths >Note: this feature is available with `react-scripts@0.9.0` and higher. From 3ffad55e68a26e23fce2a2e1646f24fd88c004e2 Mon Sep 17 00:00:00 2001 From: zeel <kshah215@gmail.com> Date: Thu, 13 Jul 2017 20:58:12 +0530 Subject: [PATCH 113/265] Moved npm run build before npm test (#2725) Closes #2713 --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 0783e878e..82642ca3a 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1379,8 +1379,8 @@ cache: directories: - node_modules script: - - npm test - npm run build + - npm test ``` 1. Trigger your first build with a git push. 1. [Customize your Travis CI Build](https://docs.travis-ci.com/user/customizing-the-build/) if needed. From 3354ab938ccc2f2aeda115589f05c49c4b90e826 Mon Sep 17 00:00:00 2001 From: Owen Flood <owenhflood@gmail.com> Date: Thu, 13 Jul 2017 20:19:44 -0700 Subject: [PATCH 114/265] List conflicting files when initializing app (#2785) * change error wording and list conflicting files when initializing app * update code * Update createReactApp.js --- packages/create-react-app/createReactApp.js | 31 ++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 4509b4978..07b083a5f 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -143,11 +143,7 @@ function createApp(name, verbose, version, template) { checkAppName(appName); fs.ensureDirSync(name); - if (!isSafeToCreateProjectIn(root)) { - console.log( - `The directory ${chalk.green(name)} contains files that could conflict.` - ); - console.log('Try using a new directory name.'); + if (!isSafeToCreateProjectIn(root, name)) { process.exit(1); } @@ -571,7 +567,7 @@ function setCaretRangeForRuntimeDeps(packageName) { // If project only contains files generated by GH, it’s safe. // We also special case IJ-based products .idea because it integrates with CRA: // https://github.com/facebookincubator/create-react-app/pull/368#issuecomment-243446094 -function isSafeToCreateProjectIn(root) { +function isSafeToCreateProjectIn(root, name) { const validFiles = [ '.DS_Store', 'Thumbs.db', @@ -585,7 +581,28 @@ function isSafeToCreateProjectIn(root) { '.hgignore', '.hgcheck', ]; - return fs.readdirSync(root).every(file => validFiles.indexOf(file) >= 0); + console.log(); + + const conflicts = fs + .readdirSync(root) + .filter(file => !validFiles.includes(file)); + if (conflicts.length < 1) { + return true; + } + + console.log( + `The directory ${chalk.green(name)} contains files that could conflict:` + ); + console.log(); + for (const file of conflicts) { + console.log(` ${file}`); + } + console.log(); + console.log( + 'Either try using a new directory name, or remove the files listed above.' + ); + + return false; } function checkIfOnline(useYarn) { From 10918769c064cfea28bad73d847b4ab4834eb638 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Fri, 14 Jul 2017 20:32:41 +0700 Subject: [PATCH 115/265] Update link for motion (#2788) They moved it to pundle monorepo 2 months ago --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f40a4d98..5d525e077 100644 --- a/README.md +++ b/README.md @@ -243,7 +243,7 @@ Some of the more popular and actively maintained ones are: Notable alternatives also include: * [enclave](https://github.com/eanplatter/enclave) -* [motion](https://github.com/motion/motion) +* [motion](https://github.com/steelbrain/pundle/tree/master/packages/motion) * [quik](https://github.com/satya164/quik) * [sagui](https://github.com/saguijs/sagui) * [roc](https://github.com/rocjs/roc) From 04820587241a350869707484badcffab515ffd8e Mon Sep 17 00:00:00 2001 From: Christian Bundy <christianbundy@fraction.io> Date: Mon, 17 Jul 2017 23:16:38 -0700 Subject: [PATCH 116/265] Upgrade webpack-dev-server (#2806) --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index d0eddad69..6ea3873c7 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -54,7 +54,7 @@ "sw-precache-webpack-plugin": "0.11.3", "url-loader": "0.5.9", "webpack": "2.6.1", - "webpack-dev-server": "2.5.0", + "webpack-dev-server": "2.5.1", "webpack-manifest-plugin": "1.1.0", "whatwg-fetch": "2.0.3" }, From d679843d050e53764e1a02f597c36d1052ba25e0 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Wed, 19 Jul 2017 18:19:18 +0100 Subject: [PATCH 117/265] Add explicit "Opting Out of Caching" header (#2822) --- packages/react-scripts/template/README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 82642ca3a..55960e2b9 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -68,6 +68,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Getting Started with Storybook](#getting-started-with-storybook) - [Getting Started with Styleguidist](#getting-started-with-styleguidist) - [Making a Progressive Web App](#making-a-progressive-web-app) + - [Opting Out of Caching](#opting-out-of-caching) - [Offline-First Considerations](#offline-first-considerations) - [Progressive Web App Metadata](#progressive-web-app-metadata) - [Analyzing the Bundle Size](#analyzing-the-bundle-size) @@ -1562,6 +1563,8 @@ The service worker will use a [cache-first strategy](https://developers.google.c 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. +### Opting Out of Caching + If you would prefer not to enable service workers prior to your initial production deployment, then remove the call to `serviceWorkerRegistration.register()` from [`src/index.js`](src/index.js). @@ -1571,7 +1574,8 @@ have decided that you would like to disable them for all your existing users, you can swap out the call to `serviceWorkerRegistration.register()` in [`src/index.js`](src/index.js) with a call to `serviceWorkerRegistration.unregister()`. After the user visits a page that has `serviceWorkerRegistration.unregister()`, -the service worker will be uninstalled. +the service worker will be uninstalled. Note that depending on how `/service-worker.js` is served, +it make take up to 24 hours for the cache to be invalidated. ### Offline-First Considerations From bc82755aff3bb31e4cf3b4a89de06e587f69bdde Mon Sep 17 00:00:00 2001 From: themre <mtrebizan@gmail.com> Date: Tue, 25 Jul 2017 21:28:45 +0200 Subject: [PATCH 118/265] Feature/webpack3 (#2574) * Add source-map-loader to support source maps of dependencies * merge with latest develop * add ModuleConcatenationPlugin * revert source-map-loader * bump to 3.1 and update dev-server * rebase to master * rebase again * bump webpack * remove ModuleConcatenationPlugin, downgraded react packages, bump etwp * ETWP rc1 only for testing * bump ETWP and webpack 3 * bump WP3 * revert to 3.2.0 * bump sw-precache-webpack-plugin * bump back to 3.3.0 * bump dev-server and manifest --- packages/react-scripts/package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 6ea3873c7..ce7b10ebd 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -39,7 +39,7 @@ "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.1.0", - "extract-text-webpack-plugin": "2.1.2", + "extract-text-webpack-plugin": "3.0.0", "file-loader": "0.11.2", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", @@ -47,15 +47,15 @@ "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.0.0", "postcss-loader": "2.0.6", - "promise": "7.1.1", + "promise": "8.0.1", "react-dev-utils": "^3.0.2", "react-error-overlay": "^1.0.9", "style-loader": "0.18.2", - "sw-precache-webpack-plugin": "0.11.3", + "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", - "webpack": "2.6.1", - "webpack-dev-server": "2.5.1", - "webpack-manifest-plugin": "1.1.0", + "webpack": "3.3.0", + "webpack-dev-server": "2.6.1", + "webpack-manifest-plugin": "1.2.1", "whatwg-fetch": "2.0.3" }, "devDependencies": { From b1c12241e455572db4440de77d20ed9a53202b56 Mon Sep 17 00:00:00 2001 From: themre <mtrebizan@gmail.com> Date: Wed, 26 Jul 2017 10:58:42 +0200 Subject: [PATCH 119/265] Bump Webpack 3.4 (#2850) * bump wp3 * try bump babel-loader --- packages/react-scripts/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index ce7b10ebd..e618bf0a0 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -25,7 +25,7 @@ "babel-core": "6.25.0", "babel-eslint": "7.2.3", "babel-jest": "20.0.3", - "babel-loader": "7.0.0", + "babel-loader": "7.1.1", "babel-preset-react-app": "^3.0.1", "babel-runtime": "6.23.0", "case-sensitive-paths-webpack-plugin": "2.1.1", @@ -53,7 +53,7 @@ "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", - "webpack": "3.3.0", + "webpack": "3.4.0", "webpack-dev-server": "2.6.1", "webpack-manifest-plugin": "1.2.1", "whatwg-fetch": "2.0.3" From ea9427bdfe742f353aa32938ade22c1c0bede93d Mon Sep 17 00:00:00 2001 From: Wiley Bennett <wileybenet@users.noreply.github.com> Date: Tue, 1 Aug 2017 17:10:55 -0700 Subject: [PATCH 120/265] Allow use of scoped packages with a pinned version (#2853) Fixes #2883 --- packages/create-react-app/createReactApp.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 07b083a5f..6fd6c75ac 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -441,7 +441,7 @@ function getPackageName(installPackage) { // git+https://github.com/mycompany/react-scripts.git // git+ssh://github.com/mycompany/react-scripts.git#v1.2.3 return Promise.resolve(installPackage.match(/([^\/]+)\.git(#.*)?$/)[1]); - } else if (installPackage.indexOf('@') > 0) { + } else if (installPackage.match(/.+@/)) { // Do not match @scope/ when stripping off @version or @tag return Promise.resolve( installPackage.charAt(0) + installPackage.substr(1).split('@')[0] From a73252f06f4fce747e94e60e2d5ce5282a62ef73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kiho=20=C2=B7=20Cham?= <monkindey@163.com> Date: Wed, 2 Aug 2017 09:04:25 +0800 Subject: [PATCH 121/265] Use modern syntax feature (#2873) The create-react-app need node >= 6, and node version 6 support a lot of ES6, and let's switch using '+' to concat string with template string. --- packages/react-scripts/bin/react-scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index cb52fe71b..abb2741f8 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -21,7 +21,7 @@ switch (script) { case 'test': { const result = spawn.sync( 'node', - [require.resolve('../scripts/' + script)].concat(args), + [require.resolve(`../scripts/${script}`)].concat(args), { stdio: 'inherit' } ); if (result.signal) { From 13c73603ce24e13a8c04092e8b535905e4a2b230 Mon Sep 17 00:00:00 2001 From: Forbes Lindesay <forbes@lindesay.co.uk> Date: Wed, 2 Aug 2017 02:19:40 +0100 Subject: [PATCH 122/265] Update webpack version note (#2798) * Remove note about webpackHotDevClient being webpack 1.0 only It must work in webpack 2 since create-react-app is still using it and is using webpack 2 now. It would be great if you could add some kind of note about how it differs from the default webpack hot reloaders. * Update README.md * Update README.md --- packages/react-dev-utils/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/README.md b/packages/react-dev-utils/README.md index 166e1bfae..540338747 100644 --- a/packages/react-dev-utils/README.md +++ b/packages/react-dev-utils/README.md @@ -295,7 +295,7 @@ Returns an object with local and remote URLs for the development server. Pass th This is an alternative client for [WebpackDevServer](https://github.com/webpack/webpack-dev-server) that shows a syntax error overlay. -It currently supports only Webpack 1.x. +It currently supports only Webpack 3.x. ```js // Webpack development config From cff167f068f98a3bf453dee263282eacc6838c70 Mon Sep 17 00:00:00 2001 From: 864907600cc <h@ccloli.com> Date: Wed, 2 Aug 2017 09:21:07 +0800 Subject: [PATCH 123/265] Fix parsing HTML/JSX tags to real elements (#2796) * Fix parsing HTML/JSX tags to real elements * Use `html-entities` to escape instead of pure `replace()` * Remove unnecessary HTML entity replacing --- packages/react-dev-utils/ansiHTML.js | 4 +++- packages/react-dev-utils/webpackHotDevClient.js | 4 +--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/ansiHTML.js b/packages/react-dev-utils/ansiHTML.js index 9f53cea67..90bf70374 100644 --- a/packages/react-dev-utils/ansiHTML.js +++ b/packages/react-dev-utils/ansiHTML.js @@ -10,6 +10,8 @@ 'use strict'; var Anser = require('anser'); +var Entities = require('html-entities').AllHtmlEntities; +var entities = new Entities(); // Color scheme inspired by https://chriskempson.github.io/base16/css/base16-github.css // var base00 = 'ffffff'; // Default Background @@ -61,7 +63,7 @@ var anserMap = { }; function ansiHTML(txt) { - var arr = new Anser().ansiToJson(txt, { + var arr = new Anser().ansiToJson(entities.encode(txt), { use_classes: true, }); diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 78002b28e..f2f206a5c 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -22,9 +22,7 @@ var SockJS = require('sockjs-client'); var stripAnsi = require('strip-ansi'); var url = require('url'); var formatWebpackMessages = require('./formatWebpackMessages'); -var Entities = require('html-entities').AllHtmlEntities; var ansiHTML = require('./ansiHTML'); -var entities = new Entities(); function createOverlayIframe(onIframeLoad) { var iframe = document.createElement('iframe'); @@ -138,7 +136,7 @@ function showErrorOverlay(message) { 'margin-bottom: 0.5em; overflow-x: auto; white-space: pre-wrap; ' + 'border-radius: 0.25rem; background-color: rgba(206, 17, 38, 0.05)">' + '<code style="font-family: Consolas, Menlo, monospace;">' + - ansiHTML(entities.encode(message)) + + ansiHTML(message) + '</code></pre>' + '<div style="' + 'font-family: sans-serif; color: rgb(135, 142, 145); margin-top: 0.5rem; ' + From 88dfd497f63bdc9e3089b26c8f16092f831c0ffb Mon Sep 17 00:00:00 2001 From: Animesh Dutta <ani.dee@gmail.com> Date: Tue, 1 Aug 2017 18:25:10 -0700 Subject: [PATCH 124/265] Add Electrode to alternatives (#2728) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 5d525e077..8f38e73c7 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,7 @@ Some of the more popular and actively maintained ones are: * [NYTimes/kyt](https://github.com/NYTimes/kyt) * [zeit/next.js](https://github.com/zeit/next.js) * [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby) +* [electrode-io/electrode](https://github.com/electrode-io/electrode) Notable alternatives also include: From 6443441bd5407cd08527a19dacad9b030ba6c8c6 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 1 Aug 2017 21:47:01 -0400 Subject: [PATCH 125/265] Update README.md --- packages/react-scripts/template/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 55960e2b9..a4fcd82b6 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -2056,6 +2056,7 @@ HTTPS | :white_check_mark: | :x: | When set to `true`, Create React App will run PUBLIC_URL | :x: | :white_check_mark: | Create React App assumes your application is hosted at the serving web server's root or a subpath as specified in [`package.json` (`homepage`)](#building-for-relative-paths). Normally, Create React App ignores the hostname. You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). This may be particularly useful when using a CDN to host your application. CI | :large_orange_diamond: | :white_check_mark: | When set to `true`, Create React App treats warnings as failures in the build. It also makes the test runner non-watching. Most CIs set this flag by default. REACT_EDITOR | :white_check_mark: | :x: | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebookincubator/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable points to your editor’s bin folder. +CHOKIDAR_USEPOLLING | :white_check_mark: | :x: | Switches the watcher into polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. ## Troubleshooting From 57f2cd70f71d146a1882325fda1643e541a6d930 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 1 Aug 2017 21:49:01 -0400 Subject: [PATCH 126/265] Update README.md --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index a4fcd82b6..cba7691f5 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -2056,7 +2056,7 @@ HTTPS | :white_check_mark: | :x: | When set to `true`, Create React App will run PUBLIC_URL | :x: | :white_check_mark: | Create React App assumes your application is hosted at the serving web server's root or a subpath as specified in [`package.json` (`homepage`)](#building-for-relative-paths). Normally, Create React App ignores the hostname. You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). This may be particularly useful when using a CDN to host your application. CI | :large_orange_diamond: | :white_check_mark: | When set to `true`, Create React App treats warnings as failures in the build. It also makes the test runner non-watching. Most CIs set this flag by default. REACT_EDITOR | :white_check_mark: | :x: | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebookincubator/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable points to your editor’s bin folder. -CHOKIDAR_USEPOLLING | :white_check_mark: | :x: | Switches the watcher into polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. +CHOKIDAR_USEPOLLING | :white_check_mark: | :x: | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. ## Troubleshooting From 20c953d091c1450fe89e3171aaace90b2d7a5afb Mon Sep 17 00:00:00 2001 From: Jon Crenshaw <jdcrensh@gmail.com> Date: Tue, 1 Aug 2017 18:52:26 -0700 Subject: [PATCH 127/265] Unstage yarn.lock pre-commit (#2700) Since yarn.lock shouldn't be added to the repo, nor excluded via .gitignore, lets take advantage of lint-staged to remove any staged yarn.lock files before they can even be committed. --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index b9abb1ce8..1c343bdc0 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,9 @@ "*.js": [ "prettier --trailing-comma es5 --single-quote --write", "git add" + ], + "yarn.lock": [ + "git rm --cached" ] } } From b643f5710a20fc1fff061f89a540d18a9df3aea0 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Wed, 2 Aug 2017 08:57:50 +0700 Subject: [PATCH 128/265] Format UglifyJs error (#2650) * format UglifyJs error * move formatBuildError to react-dev-utils * fix readme * use regex for plucking the path from stack * make path human readable and fallback to show error if regex not matched * rename to printBuildError and add link to the docs * fix link indentation * improve readibility + shorten link --- packages/react-dev-utils/README.md | 14 ++++++ packages/react-dev-utils/package.json | 3 +- packages/react-dev-utils/printBuildError.js | 50 +++++++++++++++++++++ packages/react-scripts/scripts/build.js | 3 +- packages/react-scripts/template/README.md | 11 +++++ 5 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 packages/react-dev-utils/printBuildError.js diff --git a/packages/react-dev-utils/README.md b/packages/react-dev-utils/README.md index 540338747..9206f3e8c 100644 --- a/packages/react-dev-utils/README.md +++ b/packages/react-dev-utils/README.md @@ -220,6 +220,20 @@ compiler.plugin('done', function(stats) { }); ``` +#### `printBuildError(error: Object): void` + +Prettify some known build errors. +Pass an Error object to log a prettified error message in the console. + +``` + const printBuildError = require('react-dev-utils/printBuildError') + try { + build() + } catch(e) { + printBuildError(e) // logs prettified message + } +``` + #### `getProcessForPort(port: number): string` Finds the currently running process on `port`. diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index e09e990d0..77d515609 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -18,13 +18,14 @@ "crossSpawn.js", "eslintFormatter.js", "FileSizeReporter.js", + "printBuildError.js", "formatWebpackMessages.js", "getProcessForPort.js", "inquirer.js", "InterpolateHtmlPlugin.js", "launchEditor.js", - "noopServiceWorkerMiddleware.js", "ModuleScopePlugin.js", + "noopServiceWorkerMiddleware.js", "openBrowser.js", "openChrome.applescript", "printHostingInstructions.js", diff --git a/packages/react-dev-utils/printBuildError.js b/packages/react-dev-utils/printBuildError.js new file mode 100644 index 000000000..5efbaa97d --- /dev/null +++ b/packages/react-dev-utils/printBuildError.js @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +'use strict'; + +const get = require('lodash/get'); +const chalk = require('chalk'); + +module.exports = function printBuildError(err) { + const message = get(err, 'message'); + const stack = get(err, 'stack'); + + // Add more helpful message for UglifyJs error + if ( + stack && + typeof message === 'string' && + message.indexOf('from UglifyJs') !== -1 + ) { + try { + const matched = /Unexpected token:(.+)\[(.+)\:(.+)\,(.+)\]\[.+\]/.exec( + stack + ); + if (!matched) { + throw new Error( + "The regex pattern is not matched. Maybe UglifyJs changed it's message?" + ); + } + const problemPath = matched[2]; + const line = matched[3]; + const column = matched[4]; + console.log( + 'Failed to minify the code from this file: \n\n', + chalk.yellow(`${problemPath} line ${line}:${column}`), + '\n' + ); + } catch (ignored) { + console.log('Failed to minify the code.', err); + } + console.log('Read more here: http://bit.ly/2tRViJ9'); + } else { + console.log((message || err) + '\n'); + } + console.log(); +}; diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index b9b65f531..5ad12ab12 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -34,6 +34,7 @@ const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages'); const printHostingInstructions = require('react-dev-utils/printHostingInstructions'); const FileSizeReporter = require('react-dev-utils/FileSizeReporter'); +const printBuildError = require('react-dev-utils/printBuildError'); const measureFileSizesBeforeBuild = FileSizeReporter.measureFileSizesBeforeBuild; @@ -104,7 +105,7 @@ measureFileSizesBeforeBuild(paths.appBuild) }, err => { console.log(chalk.red('Failed to compile.\n')); - console.log((err.message || err) + '\n'); + printBuildError(err); process.exit(1); } ); diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index cba7691f5..bdfb9189d 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -92,6 +92,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra) - [`npm run build` exits too early](#npm-run-build-exits-too-early) - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku) + - [`npm run build` fails to minify](#npm-run-build-fails-to-minify) - [Moment.js locales are missing](#momentjs-locales-are-missing) - [Something Missing?](#something-missing) @@ -2137,6 +2138,16 @@ moment.locale('fr'); This will only work for locales that have been explicitly imported before. +### `npm run build` fails to minify + +You may occasionally find a package you depend on needs compiled or ships code for a non-browser environment.<br> +This is considered poor practice in the ecosystem and does not have an escape hatch in Create React App.<br> +<br> +To resolve this: +1. Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled (retaining ES6 Modules). +2. Fork the package and publish a corrected version yourself. +3. If the dependency is small enough, copy it to your `src/` folder and treat it as application code. + ## Something Missing? If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md) From 664b7651ae6f4b003ffb0f7e43074c86533584e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oskar=20K=C3=B6=C3=B6k?= <oskarkook@maatriks.ee> Date: Wed, 2 Aug 2017 05:35:06 +0300 Subject: [PATCH 129/265] Re-enable flowtype warning (#2718) * Re-enable flowtype warning * Update eslint-plugin-flowtype dependency --- packages/eslint-config-react-app/index.js | 3 +-- packages/eslint-config-react-app/package.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index a8b900f94..4e94e650c 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -291,8 +291,7 @@ module.exports = { // https://github.com/gajus/eslint-plugin-flowtype 'flowtype/define-flow-type': 'warn', - // TODO: Reenable once https://github.com/gajus/eslint-plugin-flowtype/issues/165 is fixed - //'flowtype/require-valid-file-annotation': 'warn', + 'flowtype/require-valid-file-annotation': 'warn', 'flowtype/use-flow-type': 'warn', }, }; diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 559e78b25..33395bc86 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -13,7 +13,7 @@ "peerDependencies": { "babel-eslint": "^7.2.3", "eslint": "^4.1.1", - "eslint-plugin-flowtype": "^2.33.0", + "eslint-plugin-flowtype": "^2.34.1", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^5.0.3", "eslint-plugin-react": "^7.0.1" From 24b18aedd9befc603bd024225ae2429347b293f1 Mon Sep 17 00:00:00 2001 From: iamdoron <iamdoron@users.noreply.github.com> Date: Wed, 2 Aug 2017 05:50:58 +0300 Subject: [PATCH 130/265] Allow importing package.json (#2468) * Allow importing package.json * Remove package.json import from App.js template * fix importing package.json * Rename variable to reflect path is relative to root * Check for both package & package.json in ModuleScopePlugin * Use regex to check relative path to package.json * Strictly enforce package.json extension on scope plugin * Add allowedPaths to ModuleScopePlugin ctor and use it to allow app package.json * Remove package.json import from App.js template * Add package.json to react-scripts/template, show package version and name in the template * Remove import package.json from template * Remove template/package.json and its references in code * Update ModuleScopePlugin.js * Update README.md --- packages/react-dev-utils/ModuleScopePlugin.js | 18 ++++++++++-------- packages/react-dev-utils/README.md | 4 ++-- .../react-scripts/config/webpack.config.dev.js | 2 +- .../config/webpack.config.prod.js | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js index f630a0279..3a10904d3 100644 --- a/packages/react-dev-utils/ModuleScopePlugin.js +++ b/packages/react-dev-utils/ModuleScopePlugin.js @@ -13,8 +13,9 @@ const chalk = require('chalk'); const path = require('path'); class ModuleScopePlugin { - constructor(appSrc) { + constructor(appSrc, allowedFiles = []) { this.appSrc = appSrc; + this.allowedFiles = new Set(allowedFiles); } apply(resolver) { @@ -40,15 +41,16 @@ class ModuleScopePlugin { if (relative.startsWith('../') || relative.startsWith('..\\')) { return callback(); } - // Find path from src to the requested file - const requestRelative = path.relative( - appSrc, - path.resolve( - path.dirname(request.context.issuer), - request.__innerRequest_request - ) + const requestFullPath = path.resolve( + path.dirname(request.context.issuer), + request.__innerRequest_request ); + if (this.allowedFiles.has(requestFullPath)) { + return callback(); + } + // Find path from src to the requested file // Error if in a parent directory of src/ + const requestRelative = path.relative(appSrc, requestFullPath); if ( requestRelative.startsWith('../') || requestRelative.startsWith('..\\') diff --git a/packages/react-dev-utils/README.md b/packages/react-dev-utils/README.md index 9206f3e8c..e23f0a294 100644 --- a/packages/react-dev-utils/README.md +++ b/packages/react-dev-utils/README.md @@ -57,7 +57,7 @@ module.exports = { ``` -#### `new ModuleScopePlugin(appSrc: string)` +#### `new ModuleScopePlugin(appSrc: string, allowedFiles?: string[])` This Webpack plugin ensures that relative imports from app's source directory don't reach outside of it. @@ -71,7 +71,7 @@ module.exports = { resolve: { // ... plugins: [ - new ModuleScopePlugin(paths.appSrc), + new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), // ... ], // ... diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 253bc34f0..e9f985909 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -117,7 +117,7 @@ module.exports = { // To fix this, we prevent you from importing files out of src/ -- if you'd like to, // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. - new ModuleScopePlugin(paths.appSrc), + new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), ], }, module: { diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 0077c34a3..4c541e804 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -117,7 +117,7 @@ module.exports = { // To fix this, we prevent you from importing files out of src/ -- if you'd like to, // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. - new ModuleScopePlugin(paths.appSrc), + new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), ], }, module: { From e12d053c273037c5ec75971ddcd117b3e9858cdf Mon Sep 17 00:00:00 2001 From: themre <mtrebizan@gmail.com> Date: Wed, 2 Aug 2017 11:33:13 +0200 Subject: [PATCH 131/265] Feature/webpack 3 4 (#2875) * bump wp3 * try bump babel-loader * bump 3.4.1 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index e618bf0a0..805555889 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,7 +53,7 @@ "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", - "webpack": "3.4.0", + "webpack": "3.4.1", "webpack-dev-server": "2.6.1", "webpack-manifest-plugin": "1.2.1", "whatwg-fetch": "2.0.3" From 2766bbd1ffacd9a587f6c362438f0ff4ceda991f Mon Sep 17 00:00:00 2001 From: Konstantin Tarkus <koistya@gmail.com> Date: Wed, 9 Aug 2017 04:35:26 +0300 Subject: [PATCH 132/265] Fix the order of arguments in spawned child proc (#2913) * Fix the order of arguments in spawned child proc * Update react-scripts.js * Remove a comma * Update react-scripts.js --- packages/react-scripts/bin/react-scripts.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index abb2741f8..1261de6be 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -11,8 +11,12 @@ 'use strict'; const spawn = require('react-dev-utils/crossSpawn'); -const script = process.argv[2]; -const args = process.argv.slice(3); +const args = process.argv.slice(2); + +const scriptIndex = args.findIndex(x => + x === 'build' || x === 'eject' || x === 'start' || x === 'test'); +const script = scriptIndex === -1 ? args[0] : args[scriptIndex]; +const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []; switch (script) { case 'build': @@ -21,7 +25,9 @@ switch (script) { case 'test': { const result = spawn.sync( 'node', - [require.resolve(`../scripts/${script}`)].concat(args), + nodeArgs + .concat(require.resolve('../scripts/' + script)) + .concat(args.slice(scriptIndex + 1)), { stdio: 'inherit' } ); if (result.signal) { From d009a9909453380a5d39bb5e0c5d4cbb02f1f7d0 Mon Sep 17 00:00:00 2001 From: Ben Sykes <ben@bensykes.com> Date: Tue, 8 Aug 2017 18:36:32 -0700 Subject: [PATCH 133/265] Adjust the `checkIfOnline` check if in a corporate proxy environment (#2884) * Adjust the `checkIfOnline` check if in a corporate proxy environment If the environment variable `https_proxy` is set, test that the proxy name is resolveable rather than 'registry.yarnpkg.com'. This fixes #2832. * Adjust to check yarnpkg.com first, then check the proxy address only if that failed --- packages/create-react-app/createReactApp.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 6fd6c75ac..9fa0f0771 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -47,6 +47,7 @@ const semver = require('semver'); const dns = require('dns'); const tmp = require('tmp'); const unpack = require('tar-pack').unpack; +const url = require('url'); const hyperquest = require('hyperquest'); const packageJson = require('./package.json'); @@ -614,7 +615,15 @@ function checkIfOnline(useYarn) { return new Promise(resolve => { dns.lookup('registry.yarnpkg.com', err => { - resolve(err === null); + if (err != null && process.env.https_proxy) { + // If a proxy is defined, we likely can't resolve external hostnames. + // Try to resolve the proxy name as an indication of a connection. + dns.lookup(url.parse(process.env.https_proxy).hostname, proxyErr => { + resolve(proxyErr == null); + }); + } else { + resolve(err == null); + } }); }); } From badfc2a8d9a697731f67a472a291bb52fe8ee776 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Goetz?= <onigoetz@onigoetz.ch> Date: Wed, 9 Aug 2017 03:37:04 +0200 Subject: [PATCH 134/265] Make formatWebpackMessages return all messages (#2834) * Move the reduction of the messages to a single place in the place it is used. * Fix variable name --- packages/react-dev-utils/WebpackDevServerUtils.js | 5 +++++ packages/react-dev-utils/formatWebpackMessages.js | 5 ----- packages/react-scripts/scripts/build.js | 5 +++++ 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 8a66b15ec..1cd060592 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -164,6 +164,11 @@ function createCompiler(webpack, config, appName, urls, useYarn) { // If errors exist, only show errors. if (messages.errors.length) { + // Only keep the first error. Others are often indicative + // of the same problem, but confuse the reader with noise. + if (messages.errors.length > 1) { + messages.errors.length = 1; + } console.log(chalk.red('Failed to compile.\n')); console.log(messages.errors.join('\n\n')); return; diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index 5dfd099c6..a5176b920 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -121,11 +121,6 @@ function formatWebpackMessages(json) { // preceding a much more useful Babel syntax error. result.errors = result.errors.filter(isLikelyASyntaxError); } - // Only keep the first error. Others are often indicative - // of the same problem, but confuse the reader with noise. - if (result.errors.length > 1) { - result.errors.length = 1; - } return result; } diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 5ad12ab12..7691bfd52 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -122,6 +122,11 @@ function build(previousFileSizes) { } const messages = formatWebpackMessages(stats.toJson({}, true)); if (messages.errors.length) { + // Only keep the first error. Others are often indicative + // of the same problem, but confuse the reader with noise. + if (messages.errors.length > 1) { + messages.errors.length = 1; + } return reject(new Error(messages.errors.join('\n\n'))); } if ( From 1e3a64fa43e9df90310d57f6a05b5d923c0deef1 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Wed, 9 Aug 2017 08:53:37 +0700 Subject: [PATCH 135/265] Use env variable to disable source maps (#2818) * use env variable to disable source maps * Rename to use SOURCE_MAP with explicit value * Update webpack.config.prod.js --- packages/react-scripts/config/webpack.config.prod.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 4c541e804..449643461 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -29,6 +29,8 @@ const publicPath = paths.servedPath; // Some apps do not use client-side routing with pushState. // For these, "homepage" can be set to "." to enable relative asset paths. const shouldUseRelativeAssetPaths = publicPath === './'; +// Source maps are resource heavy and can cause out of memory issue for large source files. +const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false'; // `publicUrl` is just like `publicPath`, but we will provide it to our app // as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript. // Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz. @@ -62,7 +64,7 @@ module.exports = { bail: true, // We generate sourcemaps in production. This is slow but gives good results. // You can exclude the *.map files from the build during deployment. - devtool: 'source-map', + devtool: shouldUseSourceMap ? 'source-map' : false, // In production, we only want to load the polyfills and the app code. entry: [require.resolve('./polyfills'), paths.appIndexJs], output: { @@ -204,7 +206,7 @@ module.exports = { options: { importLoaders: 1, minimize: true, - sourceMap: true, + sourceMap: shouldUseSourceMap, }, }, { @@ -300,7 +302,7 @@ module.exports = { // https://github.com/facebookincubator/create-react-app/issues/2488 ascii_only: true, }, - sourceMap: true, + sourceMap: shouldUseSourceMap, }), // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`. new ExtractTextPlugin({ From 4cdd5ac427f11b203192bdcdc4386df820ac065d Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 8 Aug 2017 21:55:13 -0400 Subject: [PATCH 136/265] Update README.md --- packages/react-scripts/template/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index bdfb9189d..36496641f 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -2058,6 +2058,7 @@ PUBLIC_URL | :x: | :white_check_mark: | Create React App assumes your applicatio CI | :large_orange_diamond: | :white_check_mark: | When set to `true`, Create React App treats warnings as failures in the build. It also makes the test runner non-watching. Most CIs set this flag by default. REACT_EDITOR | :white_check_mark: | :x: | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebookincubator/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable points to your editor’s bin folder. CHOKIDAR_USEPOLLING | :white_check_mark: | :x: | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. +GENERATE_SOURCEMAP | :x: | :white_check_mark: | When set to `false`, source maps are not generated for a production build. This solves OOM issues on some smaller machines. ## Troubleshooting From 9b23be825a4f2ef1f3b5e9d7a2b5dcec49d38af2 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 8 Aug 2017 23:15:34 -0400 Subject: [PATCH 137/265] Update dev deps (#2923) * Bump deps * Fix linter errors * Whoops * Try to bump webpack * Update peer deps to min for eslint 4.x --- lerna.json | 2 +- package.json | 6 +++--- packages/create-react-app/createReactApp.js | 2 +- packages/eslint-config-react-app/package.json | 6 +++--- .../react-dev-utils/formatWebpackMessages.js | 2 +- packages/react-dev-utils/package.json | 6 +++--- packages/react-dev-utils/printBuildError.js | 2 +- packages/react-error-overlay/package.json | 20 +++++++++---------- packages/react-scripts/package.json | 12 +++++------ 9 files changed, 29 insertions(+), 29 deletions(-) diff --git a/lerna.json b/lerna.json index 7ca916a85..1673f8a31 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "lerna": "2.0.0-rc.5", + "lerna": "2.0.0", "version": "independent", "changelog": { "repo": "facebookincubator/create-react-app", diff --git a/package.json b/package.json index 1c343bdc0..c3dd6404b 100644 --- a/package.json +++ b/package.json @@ -14,10 +14,10 @@ "precommit": "lint-staged" }, "devDependencies": { - "eslint": "3.19.0", + "eslint": "^4.4.1", "husky": "^0.13.2", - "lerna": "2.0.0-rc.5", - "lerna-changelog": "^0.2.3", + "lerna": "^2.0.0", + "lerna-changelog": "^0.6.0", "lint-staged": "^3.3.1", "prettier": "^1.5.2" }, diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 9fa0f0771..4a1b7901d 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -441,7 +441,7 @@ function getPackageName(installPackage) { // Pull package name out of git urls e.g: // git+https://github.com/mycompany/react-scripts.git // git+ssh://github.com/mycompany/react-scripts.git#v1.2.3 - return Promise.resolve(installPackage.match(/([^\/]+)\.git(#.*)?$/)[1]); + return Promise.resolve(installPackage.match(/([^/]+)\.git(#.*)?$/)[1]); } else if (installPackage.match(/.+@/)) { // Do not match @scope/ when stripping off @version or @tag return Promise.resolve( diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 33395bc86..5f80b9d77 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -14,8 +14,8 @@ "babel-eslint": "^7.2.3", "eslint": "^4.1.1", "eslint-plugin-flowtype": "^2.34.1", - "eslint-plugin-import": "^2.2.0", - "eslint-plugin-jsx-a11y": "^5.0.3", - "eslint-plugin-react": "^7.0.1" + "eslint-plugin-import": "^2.6.0", + "eslint-plugin-jsx-a11y": "^5.1.1", + "eslint-plugin-react": "^7.1.0" } } diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index a5176b920..1f22a0059 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -97,7 +97,7 @@ function formatMessage(message, isError) { // from user code generated by WebPack. For more information see // https://github.com/facebookincubator/create-react-app/pull/1050 message = message.replace( - /^\s*at\s((?!webpack:).)*:\d+:\d+[\s\)]*(\n|$)/gm, + /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, '' ); // at ... ...:x:y diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 77d515609..bb3ebb50b 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -38,14 +38,14 @@ "anser": "1.4.1", "babel-code-frame": "6.22.0", "chalk": "1.1.3", - "cross-spawn": "4.0.2", + "cross-spawn": "5.1.0", "detect-port-alt": "1.1.3", "escape-string-regexp": "1.0.5", - "filesize": "3.3.0", + "filesize": "3.5.10", "global-modules": "1.0.0", "gzip-size": "3.0.0", "html-entities": "1.2.1", - "inquirer": "3.1.1", + "inquirer": "3.2.1", "is-root": "1.0.0", "opn": "5.1.0", "recursive-readdir": "2.2.1", diff --git a/packages/react-dev-utils/printBuildError.js b/packages/react-dev-utils/printBuildError.js index 5efbaa97d..208c708e1 100644 --- a/packages/react-dev-utils/printBuildError.js +++ b/packages/react-dev-utils/printBuildError.js @@ -23,7 +23,7 @@ module.exports = function printBuildError(err) { message.indexOf('from UglifyJs') !== -1 ) { try { - const matched = /Unexpected token:(.+)\[(.+)\:(.+)\,(.+)\]\[.+\]/.exec( + const matched = /Unexpected token:(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec( stack ); if (!matched) { diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 15bf9e484..db55d559d 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -31,7 +31,7 @@ "middleware.js" ], "dependencies": { - "anser": "1.2.5", + "anser": "1.4.1", "babel-code-frame": "6.22.0", "babel-runtime": "6.23.0", "react-dev-utils": "^3.0.2", @@ -42,16 +42,16 @@ "babel-cli": "6.24.1", "babel-eslint": "7.2.3", "babel-preset-react-app": "^3.0.1", - "cross-env": "5.0.0", - "eslint": "3.19.0", + "cross-env": "5.0.5", + "eslint": "4.4.1", "eslint-config-react-app": "^1.0.5", - "eslint-plugin-flowtype": "2.33.0", - "eslint-plugin-import": "2.2.0", - "eslint-plugin-jsx-a11y": "5.0.3", - "eslint-plugin-react": "7.0.1", - "flow-bin": "0.49.1", - "jest": "20.0.1", - "jest-fetch-mock": "1.1.1" + "eslint-plugin-flowtype": "2.35.0", + "eslint-plugin-import": "2.7.0", + "eslint-plugin-jsx-a11y": "5.1.1", + "eslint-plugin-react": "7.1.0", + "flow-bin": "0.52.0", + "jest": "20.0.4", + "jest-fetch-mock": "1.2.1" }, "jest": { "setupFiles": [ diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 805555889..f02244424 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -21,7 +21,7 @@ "react-scripts": "./bin/react-scripts.js" }, "dependencies": { - "autoprefixer": "7.1.1", + "autoprefixer": "7.1.2", "babel-core": "6.25.0", "babel-eslint": "7.2.3", "babel-jest": "20.0.3", @@ -32,10 +32,10 @@ "chalk": "1.1.3", "css-loader": "0.28.4", "dotenv": "4.0.0", - "eslint": "4.1.1", + "eslint": "4.4.1", "eslint-config-react-app": "^1.0.5", "eslint-loader": "1.9.0", - "eslint-plugin-flowtype": "2.34.0", + "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.1.0", @@ -45,7 +45,7 @@ "html-webpack-plugin": "2.29.0", "jest": "20.0.4", "object-assign": "4.1.1", - "postcss-flexbugs-fixes": "3.0.0", + "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", "react-dev-utils": "^3.0.2", @@ -53,8 +53,8 @@ "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", - "webpack": "3.4.1", - "webpack-dev-server": "2.6.1", + "webpack": "3.5.1", + "webpack-dev-server": "2.7.1", "webpack-manifest-plugin": "1.2.1", "whatwg-fetch": "2.0.3" }, From 77265f31b14cea2835b799f586bc7de8bd9d5934 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 8 Aug 2017 23:37:21 -0400 Subject: [PATCH 138/265] Prepare for 1.0.11 release (#2924) * Prepare for release * Make sure there's a break --- CHANGELOG.md | 119 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 115 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e2c349eb..b82304032 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,114 @@ +## 1.0.11 (2017-08-09) + +#### :bug: Bug Fix +* `create-react-app` + * [#2884](https://github.com/facebookincubator/create-react-app/pull/2884) Improve offline heuristic for proxied environments. ([@bsyk](https://github.com/bsyk)) + + When a Yarn proxy is set, we will check its connectivity if we cannot reach Yarn's registry. This is often the case when DNS lookups must be made through the proxy. + + * [#2853](https://github.com/facebookincubator/create-react-app/pull/2853) Allow use of scoped packages with a pinned version. ([@wileybenet](https://github.com/wileybenet)) +* `react-dev-utils` + * [#2796](https://github.com/facebookincubator/create-react-app/pull/2796) Properly escape HTML tags in error overlay. ([@ccloli](https://github.com/ccloli)) + + Elements printed in their entirety would sometimes render as HTML. This should no longer happen and should properly render as text. + +* `react-dev-utils`, `react-scripts` + * [#2834](https://github.com/facebookincubator/create-react-app/pull/2834) Make `formatWebpackMessages` return all messages ([@onigoetz](https://github.com/onigoetz)) +* `react-scripts` + * [#2806](https://github.com/facebookincubator/create-react-app/pull/2806) Fix SockJS version compatibility. ([@christianbundy](https://github.com/christianbundy)) + * [#2738](https://github.com/facebookincubator/create-react-app/pull/2738) Fix Jest `node` file resolution. ([@mostafah](https://github.com/mostafah)) + +#### :nail_care: Enhancement +* `react-scripts` + * [#2818](https://github.com/facebookincubator/create-react-app/pull/2818) Allow sourcemaps to be disabled. ([@viankakrisna](https://github.com/viankakrisna)) + + As applications grow more complex, it is possible webpack may run out of memory while generating source maps. They may now be disabled by setting `GENERATE_SOURCEMAP=false`. + + * [#2913](https://github.com/facebookincubator/create-react-app/pull/2913) Allow flags to be passed to node when running `react-scripts`. ([@koistya](https://github.com/koistya)) + * [#2574](https://github.com/facebookincubator/create-react-app/pull/2574) Upgrade to `webpack@3`. ([@themre](https://github.com/themre)) + * [#2747](https://github.com/facebookincubator/create-react-app/pull/2747) Simplify webpack configuration using `Rule.oneOf`. ([@Furizaa](https://github.com/Furizaa)) +* `react-dev-utils`, `react-scripts` + * [#2468](https://github.com/facebookincubator/create-react-app/pull/2468) Allow importing `package.json`. ([@iamdoron](https://github.com/iamdoron)) + * [#2650](https://github.com/facebookincubator/create-react-app/pull/2650) Make UglifyJS error friendlier. ([@viankakrisna](https://github.com/viankakrisna)) +* `create-react-app` + * [#2785](https://github.com/facebookincubator/create-react-app/pull/2785) Change error wording and list conflicting files when initializing app. ([@OwenFlood](https://github.com/OwenFlood)) +* `react-dev-utils` + * [#2761](https://github.com/facebookincubator/create-react-app/pull/2761) Don't prompt to install serve if already installed. ([@OwenFlood](https://github.com/OwenFlood)) + * [#2754](https://github.com/facebookincubator/create-react-app/pull/2754) Auto-detect JetBrains IDEs. ([@danrr](https://github.com/danrr)) + * [#2740](https://github.com/facebookincubator/create-react-app/pull/2740) Support PyCharm in `launchEditor`. ([@danrr](https://github.com/danrr)) + * [#2723](https://github.com/facebookincubator/create-react-app/pull/2723) Reorder vim arguments in `launchEditor` so `--remote` works. ([@trygveaa](https://github.com/trygveaa)) +* `eslint-config-react-app`, `react-scripts` + * [#2735](https://github.com/facebookincubator/create-react-app/pull/2735) Upgrade to `eslint@4`. ([@trungdq88](https://github.com/trungdq88)) +* `eslint-config-react-app` + * [#2701](https://github.com/facebookincubator/create-react-app/pull/2701) Set `allowTaggedTemplates` to true (eslint). ([@denkristoffer](https://github.com/denkristoffer)) + +#### :memo: Documentation +* Other + * [#2728](https://github.com/facebookincubator/create-react-app/pull/2728) Add Electrode to alternatives. ([@animesh10](https://github.com/animesh10)) + * [#2788](https://github.com/facebookincubator/create-react-app/pull/2788) Update link for motion. ([@viankakrisna](https://github.com/viankakrisna)) + * [#2697](https://github.com/facebookincubator/create-react-app/pull/2697) Fix env list ordering. ([@alexeyraspopov](https://github.com/alexeyraspopov)) +* `react-dev-utils` + * [#2798](https://github.com/facebookincubator/create-react-app/pull/2798) Update note about `webpackHotDevClient` support. ([@ForbesLindesay](https://github.com/ForbesLindesay)) +* `react-scripts` + * [#2822](https://github.com/facebookincubator/create-react-app/pull/2822) Add explicit "Opting Out of Caching" header. ([@gaearon](https://github.com/gaearon)) + * [#2725](https://github.com/facebookincubator/create-react-app/pull/2725) Fixed typo. ([@zeel](https://github.com/zeel)) + * [#2668](https://github.com/facebookincubator/create-react-app/pull/2668) Document `basename` feature in `react-router`. ([@viankakrisna](https://github.com/viankakrisna)) + * [#2719](https://github.com/facebookincubator/create-react-app/pull/2719) Remove Windows note for `source-map-explorer`. ([@hodanny](https://github.com/hodanny)) +* `babel-preset-react-app` + * [#2732](https://github.com/facebookincubator/create-react-app/pull/2732) Update link to issue blocking JSX hoisting. ([@ForbesLindesay](https://github.com/ForbesLindesay)) + +#### :house: Internal +* `create-react-app`, `eslint-config-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts` + * [#2923](https://github.com/facebookincubator/create-react-app/pull/2923) Update deps. ([@Timer](https://github.com/Timer)) +* `eslint-config-react-app` + * [#2718](https://github.com/facebookincubator/create-react-app/pull/2718) Re-enable flowtype warning. ([@oskarkook](https://github.com/oskarkook)) +* Other + * [#2700](https://github.com/facebookincubator/create-react-app/pull/2700) Unstage `yarn.lock` pre-commit. ([@jdcrensh](https://github.com/jdcrensh)) +* `react-scripts` + * [#2873](https://github.com/facebookincubator/create-react-app/pull/2873) Use template strings. ([@monkindey](https://github.com/monkindey)) + +#### Committers: 26 +- 864907600cc ([ccloli](https://github.com/ccloli)) +- Ade Viankakrisna Fadlil ([viankakrisna](https://github.com/viankakrisna)) +- Alexey Raspopov ([alexeyraspopov](https://github.com/alexeyraspopov)) +- Andreas Hoffmann ([Furizaa](https://github.com/Furizaa)) +- Animesh Dutta ([animesh10](https://github.com/animesh10)) +- Ben Sykes ([bsyk](https://github.com/bsyk)) +- Christian Bundy ([christianbundy](https://github.com/christianbundy)) +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Dan Ristea ([danrr](https://github.com/danrr)) +- Danny Ho ([hodanny](https://github.com/hodanny)) +- Forbes Lindesay ([ForbesLindesay](https://github.com/ForbesLindesay)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Jon Crenshaw ([jdcrensh](https://github.com/jdcrensh)) +- Kiho · Cham ([monkindey](https://github.com/monkindey)) +- Konstantin Tarkus ([koistya](https://github.com/koistya)) +- Kristoffer ([denkristoffer](https://github.com/denkristoffer)) +- Mostafa Hajizadeh ([mostafah](https://github.com/mostafah)) +- Oskar Köök ([oskarkook](https://github.com/oskarkook)) +- Owen Flood ([OwenFlood](https://github.com/OwenFlood)) +- Stéphane Goetz ([onigoetz](https://github.com/onigoetz)) +- Trygve Aaberge ([trygveaa](https://github.com/trygveaa)) +- Wiley Bennett ([wileybenet](https://github.com/wileybenet)) +- [iamdoron](https://github.com/iamdoron) +- [themre](https://github.com/themre) +- zeel ([zeel](https://github.com/zeel)) +- Đinh Quang Trung ([trungdq88](https://github.com/trungdq88)) + +### Migrating from 1.0.10 to 1.0.11 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.11 +``` + +or + +``` +yarn add --exact react-scripts@1.0.11 +``` + ## 1.0.10 (June 29, 2017) #### :bug: Bug Fix @@ -110,7 +221,7 @@ yarn add --exact react-scripts@1.0.9 * [#2600](https://github.com/facebookincubator/create-react-app/pull/2600) Add empty mock for `dgram` Node module. ([@micopiira](https://github.com/micopiira)) * [#2458](https://github.com/facebookincubator/create-react-app/pull/2458) Add names to module factories in development. ([@Zaccc123](https://github.com/Zaccc123)) * [#2551](https://github.com/facebookincubator/create-react-app/pull/2551) In new projects, unregister service worker and force reload if `service-worker.js` is not found. ([@ro-savage](https://github.com/ro-savage)) - + * `babel-preset-react-app`, `react-dev-utils`, `react-scripts` * [#2658](https://github.com/facebookincubator/create-react-app/pull/2658) Bump dependencies. ([@gaearon](https://github.com/gaearon)) @@ -119,7 +230,7 @@ yarn add --exact react-scripts@1.0.9 * [#2657](https://github.com/facebookincubator/create-react-app/pull/2657) Put `react-scripts` in `dependencies`, not `devDependencies`. ([@gaearon](https://github.com/gaearon)) * [#2635](https://github.com/facebookincubator/create-react-app/pull/2635) Silence unhelpful npm warnings. ([@gaearon](https://github.com/gaearon)) - + * `react-dev-utils` * [#2637](https://github.com/facebookincubator/create-react-app/pull/2637) Auto-detect Brackets editor from error overlay. ([@petetnt](https://github.com/petetnt)) @@ -176,7 +287,7 @@ yarn add --exact react-scripts@1.0.9 * [#2397](https://github.com/facebookincubator/create-react-app/pull/2397) Fix command in e2e-kitchensink.sh cleanup. ([@ro-savage](https://github.com/ro-savage)) * [#2388](https://github.com/facebookincubator/create-react-app/pull/2388) Fix wrong path expansion in end-to-end test. ([@gaearon](https://github.com/gaearon)) * [#2387](https://github.com/facebookincubator/create-react-app/pull/2387) Catch "No tests found" during CI. ([@EnoahNetzach](https://github.com/EnoahNetzach)) - + * `react-scripts` * [#2408](https://github.com/facebookincubator/create-react-app/pull/2408) E2E testing enhancements. ([@EnoahNetzach](https://github.com/EnoahNetzach)) @@ -573,7 +684,7 @@ yarn add --dev --exact react-scripts@1.0.1 We’ve been working on this release for the past few months, and there are many big impovements, from migrating to webpack 2 to a brand new runtime error overlay and built-in support for Progressive Web Apps. -So instead of just enumerating them here, we decided to write a blog post about all the new features. +So instead of just enumerating them here, we decided to write a blog post about all the new features.<br> Check it out: **[What’s New in Create React App](https://facebook.github.io/react/blog/2017/05/18/whats-new-in-create-react-app.html)**. Have you read it? Now let's see how to update your app to the latest version. From bfaee410c502a95076a6bd89721c76ca08e15f7b Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 8 Aug 2017 23:39:58 -0400 Subject: [PATCH 139/265] Publish - babel-preset-react-app@3.0.2 - create-react-app@1.4.0 - eslint-config-react-app@2.0.0 - react-dev-utils@3.1.0 - react-error-overlay@1.0.10 - react-scripts@1.0.11 --- packages/babel-preset-react-app/package.json | 2 +- packages/create-react-app/package.json | 2 +- packages/eslint-config-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-error-overlay/package.json | 8 ++++---- packages/react-scripts/package.json | 10 +++++----- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index d10188fda..dce674298 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-react-app", - "version": "3.0.1", + "version": "3.0.2", "description": "Babel preset used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 28502ca07..42ee3497e 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,6 +1,6 @@ { "name": "create-react-app", - "version": "1.3.3", + "version": "1.4.0", "keywords": [ "react" ], diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 5f80b9d77..375c9f54b 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-react-app", - "version": "1.0.5", + "version": "2.0.0", "description": "ESLint configuration used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index bb3ebb50b..0e4e135f8 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "3.0.2", + "version": "3.1.0", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index db55d559d..5a9e864c5 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "1.0.9", + "version": "1.0.10", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { @@ -34,17 +34,17 @@ "anser": "1.4.1", "babel-code-frame": "6.22.0", "babel-runtime": "6.23.0", - "react-dev-utils": "^3.0.2", + "react-dev-utils": "^3.1.0", "settle-promise": "1.0.0", "source-map": "0.5.6" }, "devDependencies": { "babel-cli": "6.24.1", "babel-eslint": "7.2.3", - "babel-preset-react-app": "^3.0.1", + "babel-preset-react-app": "^3.0.2", "cross-env": "5.0.5", "eslint": "4.4.1", - "eslint-config-react-app": "^1.0.5", + "eslint-config-react-app": "^2.0.0", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index f02244424..bf6c6be48 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.10", + "version": "1.0.11", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -26,14 +26,14 @@ "babel-eslint": "7.2.3", "babel-jest": "20.0.3", "babel-loader": "7.1.1", - "babel-preset-react-app": "^3.0.1", + "babel-preset-react-app": "^3.0.2", "babel-runtime": "6.23.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", "css-loader": "0.28.4", "dotenv": "4.0.0", "eslint": "4.4.1", - "eslint-config-react-app": "^1.0.5", + "eslint-config-react-app": "^2.0.0", "eslint-loader": "1.9.0", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", @@ -48,8 +48,8 @@ "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", - "react-dev-utils": "^3.0.2", - "react-error-overlay": "^1.0.9", + "react-dev-utils": "^3.1.0", + "react-error-overlay": "^1.0.10", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", From 10c1f577da211d65bcc278f94198ef75f00f0277 Mon Sep 17 00:00:00 2001 From: Thomas Bassetto <tbassetto@users.noreply.github.com> Date: Wed, 9 Aug 2017 14:57:37 +0200 Subject: [PATCH 140/265] Update README.md (#2927) Fixing a small typo. --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 36496641f..3f0dff117 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1576,7 +1576,7 @@ you can swap out the call to `serviceWorkerRegistration.register()` in [`src/index.js`](src/index.js) with a call to `serviceWorkerRegistration.unregister()`. After the user visits a page that has `serviceWorkerRegistration.unregister()`, the service worker will be uninstalled. Note that depending on how `/service-worker.js` is served, -it make take up to 24 hours for the cache to be invalidated. +it may take up to 24 hours for the cache to be invalidated. ### Offline-First Considerations From 93029f8368f346bc97a12a3d2d9b0b13d8c5a713 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Thu, 10 Aug 2017 16:18:13 -0700 Subject: [PATCH 141/265] Remove superfluous lodash usage (#2938) --- packages/react-dev-utils/printBuildError.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/react-dev-utils/printBuildError.js b/packages/react-dev-utils/printBuildError.js index 208c708e1..eadfff471 100644 --- a/packages/react-dev-utils/printBuildError.js +++ b/packages/react-dev-utils/printBuildError.js @@ -9,12 +9,11 @@ 'use strict'; -const get = require('lodash/get'); const chalk = require('chalk'); module.exports = function printBuildError(err) { - const message = get(err, 'message'); - const stack = get(err, 'stack'); + const message = err != null && err.message; + const stack = err != null && err.stack; // Add more helpful message for UglifyJs error if ( @@ -23,24 +22,22 @@ module.exports = function printBuildError(err) { message.indexOf('from UglifyJs') !== -1 ) { try { - const matched = /Unexpected token:(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec( - stack - ); + const matched = /(.+)\[(.+):(.+),(.+)\]\[.+\]/.exec(stack); if (!matched) { - throw new Error( - "The regex pattern is not matched. Maybe UglifyJs changed it's message?" - ); + throw new Error('Using errors for control flow is bad.'); } const problemPath = matched[2]; const line = matched[3]; const column = matched[4]; console.log( 'Failed to minify the code from this file: \n\n', - chalk.yellow(`${problemPath} line ${line}:${column}`), + chalk.yellow( + `\t${problemPath}:${line}${column !== '0' ? ':' + column : ''}` + ), '\n' ); } catch (ignored) { - console.log('Failed to minify the code.', err); + console.log('Failed to minify the bundle.', err); } console.log('Read more here: http://bit.ly/2tRViJ9'); } else { From 6efab2e12dcd242377364f471c902119b9e9d2bd Mon Sep 17 00:00:00 2001 From: Pier-Luc Gendreau <Zertz@users.noreply.github.com> Date: Mon, 14 Aug 2017 05:51:38 -0400 Subject: [PATCH 142/265] Remove Modulus from user guide (#2948) The service was rebranded to xervo.io and was completely shut down in April 2017 --- packages/react-scripts/template/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 3f0dff117..71d6b25d3 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -81,7 +81,6 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Firebase](#firebase) - [GitHub Pages](#github-pages) - [Heroku](#heroku) - - [Modulus](#modulus) - [Netlify](#netlify) - [Now](#now) - [S3 and CloudFront](#s3-and-cloudfront) @@ -1975,10 +1974,6 @@ remote: npm ERR! argv "/tmp/build_a2875fc163b209225122d68916f1d4df/.heroku/node/ In this case, ensure that the file is there with the proper lettercase and that’s not ignored on your local `.gitignore` or `~/.gitignore_global`. -### Modulus - -See the [Modulus blog post](http://blog.modulus.io/deploying-react-apps-on-modulus) on how to deploy your react app to Modulus. - ### Netlify **To do a manual deploy to Netlify’s CDN:** From e8a3e4b2995f4c6e49c0a7ed653a1646a7b5e515 Mon Sep 17 00:00:00 2001 From: Yann Pringault <yann.pringault@gmail.com> Date: Wed, 16 Aug 2017 02:17:37 +0200 Subject: [PATCH 143/265] Fix docs for `printFileSizesAfterBuild` (#2942) * Fix docs for `printFileSizesAfterBuild` * Add optionals parameters for `printFileSizesAfterBuild` --- packages/react-dev-utils/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/README.md b/packages/react-dev-utils/README.md index e23f0a294..034790c22 100644 --- a/packages/react-dev-utils/README.md +++ b/packages/react-dev-utils/README.md @@ -170,9 +170,9 @@ module: { Captures JS and CSS asset sizes inside the passed `buildFolder`. Save the result value to compare it after the build. -##### `printFileSizesAfterBuild(webpackStats: WebpackStats, previousFileSizes: OpaqueFileSizes)` +##### `printFileSizesAfterBuild(webpackStats: WebpackStats, previousFileSizes: OpaqueFileSizes, buildFolder: string, maxBundleGzipSize?: number, maxChunkGzipSize?: number)` -Prints the JS and CSS asset sizes after the build, and includes a size comparison with `previousFileSizes` that were captured earlier using `measureFileSizesBeforeBuild()`. +Prints the JS and CSS asset sizes after the build, and includes a size comparison with `previousFileSizes` that were captured earlier using `measureFileSizesBeforeBuild()`. `maxBundleGzipSize` and `maxChunkGzipSizemay` may optionally be specified to display a warning when the main bundle or a chunk exceeds the specified size (in bytes). ```js var { @@ -182,7 +182,7 @@ var { measureFileSizesBeforeBuild(buildFolder).then(previousFileSizes => { return cleanAndRebuild().then(webpackStats => { - printFileSizesAfterBuild(webpackStats, previousFileSizes); + printFileSizesAfterBuild(webpackStats, previousFileSizes, buildFolder); }); }); ``` From 5ea6de91c2f291376578392e453c575785c5b67f Mon Sep 17 00:00:00 2001 From: Ekaterina Prigara <ekaterina@prigara.com> Date: Mon, 21 Aug 2017 17:40:52 +0200 Subject: [PATCH 144/265] Docs: debugging in WebStorm (#2986) * Debugging in WebStorm * Fixed formatting for shortcuts * Added note about default URL --- packages/react-scripts/template/README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 71d6b25d3..c55ccdf94 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -243,9 +243,11 @@ If you want to enforce a coding style for your project, consider using [Prettier ## Debugging in the Editor -**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) editor.** +**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).** -Visual Studio Code supports debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools. +Visual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools. + +### Visual Studio Code You would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed. @@ -267,9 +269,22 @@ Then add the block below to your `launch.json` file and put it inside the `.vsco }] } ``` +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. +### WebStorm + +You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed. + +In the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration. + +>Note: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration). + +Start your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm. + +The same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine. + ## Formatting Code Automatically Prettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/). From 5c010e0335db4098f97b39f61bd143112bfa6990 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sat, 26 Aug 2017 17:35:25 -0600 Subject: [PATCH 145/265] Fix module function name in error overlay (#3012) --- packages/react-error-overlay/src/components/frame.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-error-overlay/src/components/frame.js b/packages/react-error-overlay/src/components/frame.js index 43d0d4043..4087f4d9c 100644 --- a/packages/react-error-overlay/src/components/frame.js +++ b/packages/react-error-overlay/src/components/frame.js @@ -101,13 +101,13 @@ function frameDiv( const frame = document.createElement('div'); const frameFunctionName = document.createElement('div'); - let cleanedFunctionName; - if (!functionName || functionName === 'Object.<anonymous>') { - cleanedFunctionName = '(anonymous function)'; - } else { - cleanedFunctionName = functionName; + if (functionName && functionName.indexOf('Object.') === 0) { + functionName = functionName.slice('Object.'.length); } - + if (functionName === '<anonymous>') { + functionName = null; + } + const cleanedFunctionName = functionName || '(anonymous function)'; const cleanedUrl = url.replace('webpack://', '.'); if (internalUrl) { From 3b9174821ebed4c9892ad416f19768df27b7c6d2 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Thu, 10 Aug 2017 16:20:03 -0700 Subject: [PATCH 146/265] Bump react-dev-utils --- packages/react-dev-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 0e4e135f8..8816e4009 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "3.1.0", + "version": "3.1.1", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", From ecd1f0544b6f8a05a4061712932cd0055d6e34c9 Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara <tharaka.nw@gmail.com> Date: Mon, 28 Aug 2017 01:45:55 +0000 Subject: [PATCH 147/265] Convert react-error-overlay to React (#2515) * Convert react-error-overlay to React * Update compile-time error overlay to use react-error-overlay components * Refactor react-error-overlay components to container and presentational components. * Make the compile-time error overlay a part of react-error-overlay package. * Use react-error-overlay as dependency in react-dev-utils to show compile-time errors. * Run Prettier * Move the function name fix into StackFrame itself * Fix clicking on source code snippet to open the code in editor * Use exact objects + minor style tweak * Don't linkify frames that don't exist on the disk * Fix lint * Consolidate iframe rendering logic * Remove circular dependency between react-dev-utils and react-error-overlay * Fix lint * Fix decoupling of react-dev-utils and react-error-overlay by moving middleware * Deduplicate identical errors --- .../errorOverlayMiddleware.js} | 6 +- .../launchEditorEndpoint.js} | 12 +- packages/react-dev-utils/package.json | 6 +- .../react-dev-utils/webpackHotDevClient.js | 158 ++------ packages/react-error-overlay/.flowconfig | 1 + .../react-error-overlay/fixtures/bundle.json | 28 +- packages/react-error-overlay/package.json | 4 +- .../src/__tests__/stack-frame.js | 4 +- .../src/components/CloseButton.js | 38 ++ .../src/components/CodeBlock.js | 54 +++ .../src/components/Collapsible.js | 78 ++++ .../src/components/Footer.js | 36 ++ .../src/components/Header.js | 39 ++ .../src/components/NavigationBar.js | 70 ++++ .../src/components/Overlay.js | 74 ++++ .../src/components/additional.js | 72 ---- .../src/components/close.js | 35 -- .../src/components/footer.js | 31 -- .../src/components/frame.js | 355 ------------------ .../src/components/frames.js | 132 ------- .../src/components/overlay.js | 95 ----- .../src/containers/CompileErrorContainer.js | 31 ++ .../src/containers/RuntimeError.js | 68 ++++ .../src/containers/RuntimeErrorContainer.js | 77 ++++ .../src/containers/StackFrame.js | 188 ++++++++++ .../StackFrameCodeBlock.js} | 50 +-- .../src/containers/StackTrace.js | 95 +++++ .../src/effects/shortcuts.js | 53 --- packages/react-error-overlay/src/index.js | 157 +++++++- .../src/listenToRuntimeErrors.js | 83 ++++ packages/react-error-overlay/src/overlay.js | 235 ------------ packages/react-error-overlay/src/styles.js | 180 +-------- .../src/utils/dom/enableTabClick.js | 24 -- .../src/utils/generateAnsiHTML.js} | 11 +- .../src/utils/getLinesAround.js | 2 +- .../src/utils/getPrettyURL.js | 49 +++ .../src/utils/getSourceMap.js | 2 +- .../{errorRegister.js => getStackFrames.js} | 40 +- .../src/utils/isBultinErrorName.js | 27 ++ .../react-error-overlay/src/utils/mapper.js | 2 +- .../react-error-overlay/src/utils/parser.js | 2 +- .../src/utils/stack-frame.js | 28 +- .../react-error-overlay/src/utils/unmapper.js | 2 +- .../react-error-overlay/src/utils/warnings.js | 2 +- packages/react-scripts/bin/react-scripts.js | 5 +- .../config/webpack.config.dev.js | 2 - .../config/webpackDevServer.config.js | 2 +- packages/react-scripts/package.json | 1 - 48 files changed, 1273 insertions(+), 1473 deletions(-) rename packages/{react-error-overlay/middleware.js => react-dev-utils/errorOverlayMiddleware.js} (76%) rename packages/{react-error-overlay/src/utils/dom/consumeEvent.js => react-dev-utils/launchEditorEndpoint.js} (65%) create mode 100644 packages/react-error-overlay/src/components/CloseButton.js create mode 100644 packages/react-error-overlay/src/components/CodeBlock.js create mode 100644 packages/react-error-overlay/src/components/Collapsible.js create mode 100644 packages/react-error-overlay/src/components/Footer.js create mode 100644 packages/react-error-overlay/src/components/Header.js create mode 100644 packages/react-error-overlay/src/components/NavigationBar.js create mode 100644 packages/react-error-overlay/src/components/Overlay.js delete mode 100644 packages/react-error-overlay/src/components/additional.js delete mode 100644 packages/react-error-overlay/src/components/close.js delete mode 100644 packages/react-error-overlay/src/components/footer.js delete mode 100644 packages/react-error-overlay/src/components/frame.js delete mode 100644 packages/react-error-overlay/src/components/frames.js delete mode 100644 packages/react-error-overlay/src/components/overlay.js create mode 100644 packages/react-error-overlay/src/containers/CompileErrorContainer.js create mode 100644 packages/react-error-overlay/src/containers/RuntimeError.js create mode 100644 packages/react-error-overlay/src/containers/RuntimeErrorContainer.js create mode 100644 packages/react-error-overlay/src/containers/StackFrame.js rename packages/react-error-overlay/src/{components/code.js => containers/StackFrameCodeBlock.js} (71%) create mode 100644 packages/react-error-overlay/src/containers/StackTrace.js delete mode 100644 packages/react-error-overlay/src/effects/shortcuts.js create mode 100644 packages/react-error-overlay/src/listenToRuntimeErrors.js delete mode 100644 packages/react-error-overlay/src/overlay.js delete mode 100644 packages/react-error-overlay/src/utils/dom/enableTabClick.js rename packages/{react-dev-utils/ansiHTML.js => react-error-overlay/src/utils/generateAnsiHTML.js} (95%) create mode 100644 packages/react-error-overlay/src/utils/getPrettyURL.js rename packages/react-error-overlay/src/utils/{errorRegister.js => getStackFrames.js} (59%) create mode 100644 packages/react-error-overlay/src/utils/isBultinErrorName.js diff --git a/packages/react-error-overlay/middleware.js b/packages/react-dev-utils/errorOverlayMiddleware.js similarity index 76% rename from packages/react-error-overlay/middleware.js rename to packages/react-dev-utils/errorOverlayMiddleware.js index d4fd0d399..b2a857d6e 100644 --- a/packages/react-error-overlay/middleware.js +++ b/packages/react-dev-utils/errorOverlayMiddleware.js @@ -8,12 +8,12 @@ */ 'use strict'; -const launchEditor = require('react-dev-utils/launchEditor'); +const launchEditor = require('./launchEditor'); +const launchEditorEndpoint = require('./launchEditorEndpoint'); module.exports = function createLaunchEditorMiddleware() { return function launchEditorMiddleware(req, res, next) { - // Keep this in sync with react-error-overlay - if (req.url.startsWith('/__open-stack-frame-in-editor')) { + if (req.url.startsWith(launchEditorEndpoint)) { launchEditor(req.query.fileName, req.query.lineNumber); res.end(); } else { diff --git a/packages/react-error-overlay/src/utils/dom/consumeEvent.js b/packages/react-dev-utils/launchEditorEndpoint.js similarity index 65% rename from packages/react-error-overlay/src/utils/dom/consumeEvent.js rename to packages/react-dev-utils/launchEditorEndpoint.js index 90bb9d1e8..e21870be9 100644 --- a/packages/react-error-overlay/src/utils/dom/consumeEvent.js +++ b/packages/react-dev-utils/launchEditorEndpoint.js @@ -6,13 +6,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. */ +'use strict'; -/* @flow */ -function consumeEvent(e: Event) { - e.preventDefault(); - if (typeof e.target.blur === 'function') { - e.target.blur(); - } -} - -export { consumeEvent }; +// TODO: we might want to make this injectable to support DEV-time non-root URLs. +module.exports = '/__open-stack-frame-in-editor'; diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 8816e4009..ccc22bf63 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -11,12 +11,12 @@ "node": ">=6" }, "files": [ - "ansiHTML.js", "checkRequiredFiles.js", "clearConsole.js", "crashOverlay.js", "crossSpawn.js", "eslintFormatter.js", + "errorOverlayMiddleware.js", "FileSizeReporter.js", "printBuildError.js", "formatWebpackMessages.js", @@ -24,6 +24,7 @@ "inquirer.js", "InterpolateHtmlPlugin.js", "launchEditor.js", + "launchEditorEndpoint.js", "ModuleScopePlugin.js", "noopServiceWorkerMiddleware.js", "openBrowser.js", @@ -35,7 +36,6 @@ ], "dependencies": { "address": "1.0.2", - "anser": "1.4.1", "babel-code-frame": "6.22.0", "chalk": "1.1.3", "cross-spawn": "5.1.0", @@ -44,10 +44,10 @@ "filesize": "3.5.10", "global-modules": "1.0.0", "gzip-size": "3.0.0", - "html-entities": "1.2.1", "inquirer": "3.2.1", "is-root": "1.0.0", "opn": "5.1.0", + "react-error-overlay": "^1.0.9", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index f2f206a5c..b6effe718 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -21,143 +21,27 @@ var SockJS = require('sockjs-client'); var stripAnsi = require('strip-ansi'); var url = require('url'); +var launchEditorEndpoint = require('./launchEditorEndpoint'); var formatWebpackMessages = require('./formatWebpackMessages'); -var ansiHTML = require('./ansiHTML'); - -function createOverlayIframe(onIframeLoad) { - var iframe = document.createElement('iframe'); - iframe.id = 'react-dev-utils-webpack-hot-dev-client-overlay'; - iframe.src = 'about:blank'; - iframe.style.position = 'fixed'; - iframe.style.left = 0; - iframe.style.top = 0; - iframe.style.right = 0; - iframe.style.bottom = 0; - iframe.style.width = '100vw'; - iframe.style.height = '100vh'; - iframe.style.border = 'none'; - iframe.style.zIndex = 2147483647; - iframe.onload = onIframeLoad; - return iframe; -} - -function addOverlayDivTo(iframe) { - // TODO: unify these styles with react-error-overlay - iframe.contentDocument.body.style.margin = 0; - iframe.contentDocument.body.style.maxWidth = '100vw'; - - var outerDiv = iframe.contentDocument.createElement('div'); - outerDiv.id = 'react-dev-utils-webpack-hot-dev-client-overlay-div'; - outerDiv.style.width = '100%'; - outerDiv.style.height = '100%'; - outerDiv.style.boxSizing = 'border-box'; - outerDiv.style.textAlign = 'center'; - outerDiv.style.backgroundColor = 'rgb(255, 255, 255)'; - - var div = iframe.contentDocument.createElement('div'); - div.style.position = 'relative'; - div.style.display = 'inline-flex'; - div.style.flexDirection = 'column'; - div.style.height = '100%'; - div.style.width = '1024px'; - div.style.maxWidth = '100%'; - div.style.overflowX = 'hidden'; - div.style.overflowY = 'auto'; - div.style.padding = '0.5rem'; - div.style.boxSizing = 'border-box'; - div.style.textAlign = 'left'; - div.style.fontFamily = 'Consolas, Menlo, monospace'; - div.style.fontSize = '11px'; - div.style.whiteSpace = 'pre-wrap'; - div.style.wordBreak = 'break-word'; - div.style.lineHeight = '1.5'; - div.style.color = 'rgb(41, 50, 56)'; - - outerDiv.appendChild(div); - iframe.contentDocument.body.appendChild(outerDiv); - return div; -} - -function overlayHeaderStyle() { - return ( - 'font-size: 2em;' + - 'font-family: sans-serif;' + - 'color: rgb(206, 17, 38);' + - 'white-space: pre-wrap;' + - 'margin: 0 2rem 0.75rem 0px;' + - 'flex: 0 0 auto;' + - 'max-height: 35%;' + - 'overflow: auto;' - ); -} - -var overlayIframe = null; -var overlayDiv = null; -var lastOnOverlayDivReady = null; - -function ensureOverlayDivExists(onOverlayDivReady) { - if (overlayDiv) { - // Everything is ready, call the callback right away. - onOverlayDivReady(overlayDiv); - return; - } - - // Creating an iframe may be asynchronous so we'll schedule the callback. - // In case of multiple calls, last callback wins. - lastOnOverlayDivReady = onOverlayDivReady; - - if (overlayIframe) { - // We're already creating it. - return; - } - - // Create iframe and, when it is ready, a div inside it. - overlayIframe = createOverlayIframe(function onIframeLoad() { - overlayDiv = addOverlayDivTo(overlayIframe); - // Now we can talk! - lastOnOverlayDivReady(overlayDiv); - }); - - // Zalgo alert: onIframeLoad() will be called either synchronously - // or asynchronously depending on the browser. - // We delay adding it so `overlayIframe` is set when `onIframeLoad` fires. - document.body.appendChild(overlayIframe); -} +var ErrorOverlay = require('react-error-overlay'); + +ErrorOverlay.startReportingRuntimeErrors({ + launchEditorEndpoint: launchEditorEndpoint, + onError: function() { + // TODO: why do we need this? + if (module.hot && typeof module.hot.decline === 'function') { + module.hot.decline(); + } + }, +}); -function showErrorOverlay(message) { - ensureOverlayDivExists(function onOverlayDivReady(overlayDiv) { - // TODO: unify this with our runtime overlay - overlayDiv.innerHTML = - '<div style="' + - overlayHeaderStyle() + - '">Failed to compile</div>' + - '<pre style="' + - 'display: block; padding: 0.5em; margin-top: 0; ' + - 'margin-bottom: 0.5em; overflow-x: auto; white-space: pre-wrap; ' + - 'border-radius: 0.25rem; background-color: rgba(206, 17, 38, 0.05)">' + - '<code style="font-family: Consolas, Menlo, monospace;">' + - ansiHTML(message) + - '</code></pre>' + - '<div style="' + - 'font-family: sans-serif; color: rgb(135, 142, 145); margin-top: 0.5rem; ' + - 'flex: 0 0 auto">' + - 'This error occurred during the build time and cannot be dismissed.</div>'; +if (module.hot && typeof module.hot.dispose === 'function') { + module.hot.dispose(function() { + // TODO: why do we need this? + ErrorOverlay.stopReportingRuntimeErrors(); }); } -function destroyErrorOverlay() { - if (!overlayDiv) { - // It is not there in the first place. - return; - } - - // Clean up and reset internal state. - document.body.removeChild(overlayIframe); - overlayDiv = null; - overlayIframe = null; - lastOnOverlayDivReady = null; -} - // Connect to WebpackDevServer via a socket. var connection = new SockJS( url.format({ @@ -205,9 +89,9 @@ function handleSuccess() { // Attempt to apply hot updates or reload. if (isHotUpdate) { tryApplyUpdates(function onHotUpdateSuccess() { - // Only destroy it when we're sure it's a hot update. + // Only dismiss it when we're sure it's a hot update. // Otherwise it would flicker right before the reload. - destroyErrorOverlay(); + ErrorOverlay.dismissBuildError(); }); } } @@ -247,9 +131,9 @@ function handleWarnings(warnings) { // Only print warnings if we aren't refreshing the page. // Otherwise they'll disappear right away anyway. printWarnings(); - // Only destroy it when we're sure it's a hot update. + // Only dismiss it when we're sure it's a hot update. // Otherwise it would flicker right before the reload. - destroyErrorOverlay(); + ErrorOverlay.dismissBuildError(); }); } else { // Print initial warnings immediately. @@ -271,7 +155,7 @@ function handleErrors(errors) { }); // Only show the first error. - showErrorOverlay(formatted.errors[0]); + ErrorOverlay.reportBuildError(formatted.errors[0]); // Also log them to the console. if (typeof console !== 'undefined' && typeof console.error === 'function') { diff --git a/packages/react-error-overlay/.flowconfig b/packages/react-error-overlay/.flowconfig index 261b8646f..8d7de784e 100644 --- a/packages/react-error-overlay/.flowconfig +++ b/packages/react-error-overlay/.flowconfig @@ -1,4 +1,5 @@ [ignore] +.*/node_modules/eslint-plugin-jsx-a11y/.* [include] src/**/*.js diff --git a/packages/react-error-overlay/fixtures/bundle.json b/packages/react-error-overlay/fixtures/bundle.json index 7dfd31f58..16670f623 100644 --- a/packages/react-error-overlay/fixtures/bundle.json +++ b/packages/react-error-overlay/fixtures/bundle.json @@ -240,11 +240,11 @@ ] }, { - "functionName": "Object.batchedUpdates", + "functionName": "batchedUpdates", "fileName": "http://localhost:3000/static/js/bundle.js", "lineNumber": 33900, "columnNumber": 26, - "_originalFunctionName": "Object.batchedUpdates", + "_originalFunctionName": "batchedUpdates", "_originalFileName": "webpack:///packages/react-scripts/~/react-dom/lib/ReactDefaultBatchingStrategy.js", "_originalLineNumber": 62, "_originalColumnNumber": 0, @@ -264,11 +264,11 @@ ] }, { - "functionName": "Object.batchedUpdates", + "functionName": "batchedUpdates", "fileName": "http://localhost:3000/static/js/bundle.js", "lineNumber": 2181, "columnNumber": 27, - "_originalFunctionName": "Object.batchedUpdates", + "_originalFunctionName": "batchedUpdates", "_originalFileName": "webpack:///packages/react-scripts/~/react-dom/lib/ReactUpdates.js", "_originalLineNumber": 97, "_originalColumnNumber": 0, @@ -288,11 +288,11 @@ ] }, { - "functionName": "Object._renderNewRootComponent", + "functionName": "_renderNewRootComponent", "fileName": "http://localhost:3000/static/js/bundle.js", "lineNumber": 14398, "columnNumber": 18, - "_originalFunctionName": "Object._renderNewRootComponent", + "_originalFunctionName": "_renderNewRootComponent", "_originalFileName": "webpack:///packages/react-scripts/~/react-dom/lib/ReactMount.js", "_originalLineNumber": 320, "_originalColumnNumber": 0, @@ -312,11 +312,11 @@ ] }, { - "functionName": "Object._renderSubtreeIntoContainer", + "functionName": "_renderSubtreeIntoContainer", "fileName": "http://localhost:3000/static/js/bundle.js", "lineNumber": 14479, "columnNumber": 32, - "_originalFunctionName": "Object._renderSubtreeIntoContainer", + "_originalFunctionName": "_renderSubtreeIntoContainer", "_originalFileName": "webpack:///packages/react-scripts/~/react-dom/lib/ReactMount.js", "_originalLineNumber": 401, "_originalColumnNumber": 0, @@ -336,11 +336,11 @@ ] }, { - "functionName": "Object.render", + "functionName": "render", "fileName": "http://localhost:3000/static/js/bundle.js", "lineNumber": 14500, "columnNumber": 23, - "_originalFunctionName": "Object.render", + "_originalFunctionName": "render", "_originalFileName": "webpack:///packages/react-scripts/~/react-dom/lib/ReactMount.js", "_originalLineNumber": 422, "_originalColumnNumber": 0, @@ -360,11 +360,11 @@ ] }, { - "functionName": "Object.friendlySyntaxErrorLabel", + "functionName": null, "fileName": "http://localhost:3000/static/js/bundle.js", "lineNumber": 17287, "columnNumber": 20, - "_originalFunctionName": "Object.friendlySyntaxErrorLabel", + "_originalFunctionName": null, "_originalFileName": "webpack:///packages/react-scripts/template/src/index.js", "_originalLineNumber": 6, "_originalColumnNumber": 0, @@ -432,11 +432,11 @@ ] }, { - "functionName": "Object.<anonymous>", + "functionName": null, "fileName": "http://localhost:3000/static/js/bundle.js", "lineNumber": 41219, "columnNumber": 18, - "_originalFunctionName": "Object.<anonymous>", + "_originalFunctionName": null, "_originalFileName": null, "_originalLineNumber": null, "_originalColumnNumber": null, diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 5a9e864c5..65c9b5efa 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -34,7 +34,9 @@ "anser": "1.4.1", "babel-code-frame": "6.22.0", "babel-runtime": "6.23.0", - "react-dev-utils": "^3.1.0", + "html-entities": "1.2.1", + "react": "^15.5.4", + "react-dom": "^15.5.4", "settle-promise": "1.0.0", "source-map": "0.5.6" }, diff --git a/packages/react-error-overlay/src/__tests__/stack-frame.js b/packages/react-error-overlay/src/__tests__/stack-frame.js index dc6a01b4a..5a015260a 100644 --- a/packages/react-error-overlay/src/__tests__/stack-frame.js +++ b/packages/react-error-overlay/src/__tests__/stack-frame.js @@ -13,9 +13,9 @@ test('proper empty shape', () => { const empty = new StackFrame(); expect(empty).toMatchSnapshot(); - expect(empty.getFunctionName()).toBe(null); + expect(empty.getFunctionName()).toBe('(anonymous function)'); expect(empty.getSource()).toBe(''); - expect(empty.toString()).toBe(''); + expect(empty.toString()).toBe('(anonymous function)'); }); test('proper full shape', () => { diff --git a/packages/react-error-overlay/src/components/CloseButton.js b/packages/react-error-overlay/src/components/CloseButton.js new file mode 100644 index 000000000..503b1198c --- /dev/null +++ b/packages/react-error-overlay/src/components/CloseButton.js @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React from 'react'; +import { black } from '../styles'; + +const closeButtonStyle = { + color: black, + lineHeight: '1rem', + fontSize: '1.5rem', + padding: '1rem', + cursor: 'pointer', + position: 'absolute', + right: 0, + top: 0, +}; + +type CloseCallback = () => void; +function CloseButton({ close }: {| close: CloseCallback |}) { + return ( + <span + title="Click or press Escape to dismiss." + onClick={close} + style={closeButtonStyle} + > + × + </span> + ); +} + +export default CloseButton; diff --git a/packages/react-error-overlay/src/components/CodeBlock.js b/packages/react-error-overlay/src/components/CodeBlock.js new file mode 100644 index 000000000..478f0111b --- /dev/null +++ b/packages/react-error-overlay/src/components/CodeBlock.js @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React from 'react'; +import { redTransparent, yellowTransparent } from '../styles'; + +const _preStyle = { + display: 'block', + padding: '0.5em', + marginTop: '0.5em', + marginBottom: '0.5em', + overflowX: 'auto', + whiteSpace: 'pre-wrap', + borderRadius: '0.25rem', +}; + +const primaryPreStyle = { + ..._preStyle, + backgroundColor: redTransparent, +}; + +const secondaryPreStyle = { + ..._preStyle, + backgroundColor: yellowTransparent, +}; + +const codeStyle = { + fontFamily: 'Consolas, Menlo, monospace', +}; + +type CodeBlockPropsType = {| + main: boolean, + codeHTML: string, +|}; + +function CodeBlock(props: CodeBlockPropsType) { + const preStyle = props.main ? primaryPreStyle : secondaryPreStyle; + const codeBlock = { __html: props.codeHTML }; + + return ( + <pre style={preStyle}> + <code style={codeStyle} dangerouslySetInnerHTML={codeBlock} /> + </pre> + ); +} + +export default CodeBlock; diff --git a/packages/react-error-overlay/src/components/Collapsible.js b/packages/react-error-overlay/src/components/Collapsible.js new file mode 100644 index 000000000..92f1de429 --- /dev/null +++ b/packages/react-error-overlay/src/components/Collapsible.js @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React, { Component } from 'react'; +import { black } from '../styles'; + +const _collapsibleStyle = { + color: black, + cursor: 'pointer', + border: 'none', + display: 'block', + width: '100%', + textAlign: 'left', + background: '#fff', + fontFamily: 'Consolas, Menlo, monospace', + fontSize: '1em', + padding: '0px', + lineHeight: '1.5', +}; + +const collapsibleCollapsedStyle = { + ..._collapsibleStyle, + marginBottom: '1.5em', +}; + +const collapsibleExpandedStyle = { + ..._collapsibleStyle, + marginBottom: '0.6em', +}; + +class Collapsible extends Component { + state = { + collapsed: true, + }; + + toggleCollaped = () => { + this.setState(state => ({ + collapsed: !state.collapsed, + })); + }; + + render() { + const count = this.props.children.length; + const collapsed = this.state.collapsed; + return ( + <div> + <button + onClick={this.toggleCollaped} + style={ + collapsed ? collapsibleCollapsedStyle : collapsibleExpandedStyle + } + > + {(collapsed ? '▶' : '▼') + + ` ${count} stack frames were ` + + (collapsed ? 'collapsed.' : 'expanded.')} + </button> + <div style={{ display: collapsed ? 'none' : 'block' }}> + {this.props.children} + <button + onClick={this.toggleCollaped} + style={collapsibleExpandedStyle} + > + {`▲ ${count} stack frames were expanded.`} + </button> + </div> + </div> + ); + } +} + +export default Collapsible; diff --git a/packages/react-error-overlay/src/components/Footer.js b/packages/react-error-overlay/src/components/Footer.js new file mode 100644 index 000000000..68eb84656 --- /dev/null +++ b/packages/react-error-overlay/src/components/Footer.js @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React from 'react'; +import { darkGray } from '../styles'; + +const footerStyle = { + fontFamily: 'sans-serif', + color: darkGray, + marginTop: '0.5rem', + flex: '0 0 auto', +}; + +type FooterPropsType = {| + line1: string, + line2?: string, +|}; + +function Footer(props: FooterPropsType) { + return ( + <div style={footerStyle}> + {props.line1} + <br /> + {props.line2} + </div> + ); +} + +export default Footer; diff --git a/packages/react-error-overlay/src/components/Header.js b/packages/react-error-overlay/src/components/Header.js new file mode 100644 index 000000000..a2f40973d --- /dev/null +++ b/packages/react-error-overlay/src/components/Header.js @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React from 'react'; +import { red } from '../styles'; + +const headerStyle = { + fontSize: '2em', + fontFamily: 'sans-serif', + color: red, + whiteSpace: 'pre-wrap', + // Top bottom margin spaces header + // Right margin revents overlap with close button + margin: '0 2rem 0.75rem 0', + flex: '0 0 auto', + maxHeight: '50%', + overflow: 'auto', +}; + +type HeaderPropType = {| + headerText: string, +|}; + +function Header(props: HeaderPropType) { + return ( + <div style={headerStyle}> + {props.headerText} + </div> + ); +} + +export default Header; diff --git a/packages/react-error-overlay/src/components/NavigationBar.js b/packages/react-error-overlay/src/components/NavigationBar.js new file mode 100644 index 000000000..4eba743ce --- /dev/null +++ b/packages/react-error-overlay/src/components/NavigationBar.js @@ -0,0 +1,70 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React from 'react'; +import { red, redTransparent } from '../styles'; + +const navigationBarStyle = { + marginBottom: '0.5rem', +}; + +const buttonContainerStyle = { + marginRight: '1em', +}; + +const _navButtonStyle = { + backgroundColor: redTransparent, + color: red, + border: 'none', + borderRadius: '4px', + padding: '3px 6px', + cursor: 'pointer', +}; + +const leftButtonStyle = { + ..._navButtonStyle, + borderTopRightRadius: '0px', + borderBottomRightRadius: '0px', + marginRight: '1px', +}; + +const rightButtonStyle = { + ..._navButtonStyle, + borderTopLeftRadius: '0px', + borderBottomLeftRadius: '0px', +}; + +type Callback = () => void; + +type NavigationBarPropsType = {| + currentError: number, + totalErrors: number, + previous: Callback, + next: Callback, +|}; + +function NavigationBar(props: NavigationBarPropsType) { + const { currentError, totalErrors, previous, next } = props; + return ( + <div style={navigationBarStyle}> + <span style={buttonContainerStyle}> + <button onClick={previous} style={leftButtonStyle}> + ← + </button> + <button onClick={next} style={rightButtonStyle}> + → + </button> + </span> + {`${currentError} of ${totalErrors} errors on the page`} + </div> + ); +} + +export default NavigationBar; diff --git a/packages/react-error-overlay/src/components/Overlay.js b/packages/react-error-overlay/src/components/Overlay.js new file mode 100644 index 000000000..4fe530b6f --- /dev/null +++ b/packages/react-error-overlay/src/components/Overlay.js @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React, { Component } from 'react'; +import { black } from '../styles'; + +const overlayStyle = { + position: 'relative', + display: 'inline-flex', + flexDirection: 'column', + height: '100%', + width: '1024px', + maxWidth: '100%', + overflowX: 'hidden', + overflowY: 'auto', + padding: '0.5rem', + boxSizing: 'border-box', + textAlign: 'left', + fontFamily: 'Consolas, Menlo, monospace', + fontSize: '11px', + whiteSpace: 'pre-wrap', + wordBreak: 'break-word', + lineHeight: 1.5, + color: black, +}; + +class Overlay extends Component { + iframeWindow: window = null; + + getIframeWindow = (element: HTMLDivElement) => { + if (element) { + const document = element.ownerDocument; + this.iframeWindow = document.defaultView; + } + }; + + onKeyDown = (e: KeyboardEvent) => { + const { shortcutHandler } = this.props; + if (shortcutHandler) { + shortcutHandler(e.key); + } + }; + + componentDidMount() { + window.addEventListener('keydown', this.onKeyDown); + if (this.iframeWindow) { + this.iframeWindow.addEventListener('keydown', this.onKeyDown); + } + } + + componentWillUnmount() { + window.removeEventListener('keydown', this.onKeyDown); + if (this.iframeWindow) { + this.iframeWindow.removeEventListener('keydown', this.onKeyDown); + } + } + + render() { + return ( + <div style={overlayStyle} ref={this.getIframeWindow}> + {this.props.children} + </div> + ); + } +} + +export default Overlay; diff --git a/packages/react-error-overlay/src/components/additional.js b/packages/react-error-overlay/src/components/additional.js deleted file mode 100644 index b573c7406..000000000 --- a/packages/react-error-overlay/src/components/additional.js +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -import { applyStyles } from '../utils/dom/css'; -import { - additionalChildStyle, - groupStyle, - groupElemLeft, - groupElemRight, -} from '../styles'; -import { consumeEvent } from '../utils/dom/consumeEvent'; -import { enableTabClick } from '../utils/dom/enableTabClick'; - -type SwitchCallback = (offset: number) => void; -function updateAdditional( - document: Document, - additionalReference: HTMLDivElement, - currentError: number, - totalErrors: number, - switchCallback: SwitchCallback -) { - if (additionalReference.lastChild) { - additionalReference.removeChild(additionalReference.lastChild); - } - - if (totalErrors <= 1) { - return; - } - - const div = document.createElement('div'); - applyStyles(div, additionalChildStyle); - - const group = document.createElement('span'); - applyStyles(group, groupStyle); - - const left = document.createElement('button'); - applyStyles(left, groupElemLeft); - left.addEventListener('click', function(e: MouseEvent) { - consumeEvent(e); - switchCallback(-1); - }); - left.appendChild(document.createTextNode('←')); - enableTabClick(left); - - const right = document.createElement('button'); - applyStyles(right, groupElemRight); - right.addEventListener('click', function(e: MouseEvent) { - consumeEvent(e); - switchCallback(1); - }); - right.appendChild(document.createTextNode('→')); - enableTabClick(right); - - group.appendChild(left); - group.appendChild(right); - div.appendChild(group); - - const text = `${currentError} of ${totalErrors} errors on the page`; - div.appendChild(document.createTextNode(text)); - - additionalReference.appendChild(div); -} - -export type { SwitchCallback }; -export { updateAdditional }; diff --git a/packages/react-error-overlay/src/components/close.js b/packages/react-error-overlay/src/components/close.js deleted file mode 100644 index 2ced8d0ce..000000000 --- a/packages/react-error-overlay/src/components/close.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -import { applyStyles } from '../utils/dom/css'; -import { hintsStyle, hintStyle, closeButtonStyle } from '../styles'; - -function createHint(document: Document, hint: string, title: string) { - const span = document.createElement('span'); - span.appendChild(document.createTextNode(hint)); - span.setAttribute('title', title); - applyStyles(span, hintStyle); - return span; -} - -type CloseCallback = () => void; -function createClose(document: Document, callback: CloseCallback) { - const hints = document.createElement('div'); - applyStyles(hints, hintsStyle); - - const close = createHint(document, '×', 'Click or press Escape to dismiss.'); - close.addEventListener('click', () => callback()); - applyStyles(close, closeButtonStyle); - hints.appendChild(close); - return hints; -} - -export type { CloseCallback }; -export { createClose }; diff --git a/packages/react-error-overlay/src/components/footer.js b/packages/react-error-overlay/src/components/footer.js deleted file mode 100644 index 4586a04ff..000000000 --- a/packages/react-error-overlay/src/components/footer.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -import { applyStyles } from '../utils/dom/css'; -import { footerStyle } from '../styles'; - -function createFooter(document: Document) { - const div = document.createElement('div'); - applyStyles(div, footerStyle); - div.appendChild( - document.createTextNode( - 'This screen is visible only in development. It will not appear if the app crashes in production.' - ) - ); - div.appendChild(document.createElement('br')); - div.appendChild( - document.createTextNode( - 'Open your browser’s developer console to further inspect this error.' - ) - ); - return div; -} - -export { createFooter }; diff --git a/packages/react-error-overlay/src/components/frame.js b/packages/react-error-overlay/src/components/frame.js deleted file mode 100644 index 4087f4d9c..000000000 --- a/packages/react-error-overlay/src/components/frame.js +++ /dev/null @@ -1,355 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -import { enableTabClick } from '../utils/dom/enableTabClick'; -import { createCode } from './code'; -import { isInternalFile } from '../utils/isInternalFile'; -import type { StackFrame } from '../utils/stack-frame'; -import type { FrameSetting, OmitsObject } from './frames'; -import { applyStyles } from '../utils/dom/css'; -import { - omittedFramesExpandedStyle, - omittedFramesCollapsedStyle, - functionNameStyle, - depStyle, - linkStyle, - anchorStyle, - hiddenStyle, -} from '../styles'; - -function getGroupToggle( - document: Document, - omitsCount: number, - omitBundle: number -) { - const omittedFrames = document.createElement('div'); - enableTabClick(omittedFrames); - const text1 = document.createTextNode( - '\u25B6 ' + omitsCount + ' stack frames were collapsed.' - ); - omittedFrames.appendChild(text1); - omittedFrames.addEventListener('click', function() { - const hide = text1.textContent.match(/▲/); - const list = document.getElementsByName('bundle-' + omitBundle); - for (let index = 0; index < list.length; ++index) { - const n = list[index]; - if (hide) { - n.style.display = 'none'; - } else { - n.style.display = ''; - } - } - if (hide) { - text1.textContent = text1.textContent.replace(/▲/, '▶'); - text1.textContent = text1.textContent.replace(/expanded/, 'collapsed'); - applyStyles(omittedFrames, omittedFramesCollapsedStyle); - } else { - text1.textContent = text1.textContent.replace(/▶/, '▲'); - text1.textContent = text1.textContent.replace(/collapsed/, 'expanded'); - applyStyles(omittedFrames, omittedFramesExpandedStyle); - } - }); - applyStyles(omittedFrames, omittedFramesCollapsedStyle); - return omittedFrames; -} - -function insertBeforeBundle( - document: Document, - parent: Node, - omitsCount: number, - omitBundle: number, - actionElement -) { - const children = document.getElementsByName('bundle-' + omitBundle); - if (children.length < 1) { - return; - } - let first: ?Node = children[0]; - while (first != null && first.parentNode !== parent) { - first = first.parentNode; - } - const div = document.createElement('div'); - enableTabClick(div); - div.setAttribute('name', 'bundle-' + omitBundle); - const text = document.createTextNode( - '\u25BC ' + omitsCount + ' stack frames were expanded.' - ); - div.appendChild(text); - div.addEventListener('click', function() { - return actionElement.click(); - }); - applyStyles(div, omittedFramesExpandedStyle); - div.style.display = 'none'; - - parent.insertBefore(div, first); -} - -function frameDiv( - document: Document, - functionName, - url, - internalUrl, - onSourceClick: ?Function -) { - const frame = document.createElement('div'); - const frameFunctionName = document.createElement('div'); - - if (functionName && functionName.indexOf('Object.') === 0) { - functionName = functionName.slice('Object.'.length); - } - if (functionName === '<anonymous>') { - functionName = null; - } - const cleanedFunctionName = functionName || '(anonymous function)'; - const cleanedUrl = url.replace('webpack://', '.'); - - if (internalUrl) { - applyStyles( - frameFunctionName, - Object.assign({}, functionNameStyle, depStyle) - ); - } else { - applyStyles(frameFunctionName, functionNameStyle); - } - - frameFunctionName.appendChild(document.createTextNode(cleanedFunctionName)); - frame.appendChild(frameFunctionName); - - const frameLink = document.createElement('div'); - applyStyles(frameLink, linkStyle); - const frameAnchor = document.createElement('a'); - applyStyles(frameAnchor, anchorStyle); - frameAnchor.appendChild(document.createTextNode(cleanedUrl)); - frameLink.appendChild(frameAnchor); - frame.appendChild(frameLink); - - if (typeof onSourceClick === 'function') { - let handler = onSourceClick; - enableTabClick(frameAnchor); - frameAnchor.style.cursor = 'pointer'; - frameAnchor.addEventListener('click', function() { - handler(); - }); - } - - return frame; -} - -function isBultinErrorName(errorName: ?string) { - switch (errorName) { - case 'EvalError': - case 'InternalError': - case 'RangeError': - case 'ReferenceError': - case 'SyntaxError': - case 'TypeError': - case 'URIError': - return true; - default: - return false; - } -} - -function getPrettyURL( - sourceFileName: ?string, - sourceLineNumber: ?number, - sourceColumnNumber: ?number, - fileName: ?string, - lineNumber: ?number, - columnNumber: ?number, - compiled: boolean -): string { - let prettyURL; - if (!compiled && sourceFileName && typeof sourceLineNumber === 'number') { - // Remove everything up to the first /src/ or /node_modules/ - const trimMatch = /^[/|\\].*?[/|\\]((src|node_modules)[/|\\].*)/.exec( - sourceFileName - ); - if (trimMatch && trimMatch[1]) { - prettyURL = trimMatch[1]; - } else { - prettyURL = sourceFileName; - } - prettyURL += ':' + sourceLineNumber; - // Note: we intentionally skip 0's because they're produced by cheap Webpack maps - if (sourceColumnNumber) { - prettyURL += ':' + sourceColumnNumber; - } - } else if (fileName && typeof lineNumber === 'number') { - prettyURL = fileName + ':' + lineNumber; - // Note: we intentionally skip 0's because they're produced by cheap Webpack maps - if (columnNumber) { - prettyURL += ':' + columnNumber; - } - } else { - prettyURL = 'unknown'; - } - return prettyURL; -} - -function createFrame( - document: Document, - frameSetting: FrameSetting, - frame: StackFrame, - contextSize: number, - critical: boolean, - omits: OmitsObject, - omitBundle: number, - parentContainer: HTMLDivElement, - lastElement: boolean, - errorName: ?string -) { - const { compiled } = frameSetting; - let { functionName, _originalFileName: sourceFileName } = frame; - const { - fileName, - lineNumber, - columnNumber, - _scriptCode: scriptLines, - _originalLineNumber: sourceLineNumber, - _originalColumnNumber: sourceColumnNumber, - _originalScriptCode: sourceLines, - } = frame; - - // TODO: find a better place for this. - // Chrome has a bug with inferring function.name: - // https://github.com/facebookincubator/create-react-app/issues/2097 - // Let's ignore a meaningless name we get for top-level modules. - if ( - functionName === 'Object.friendlySyntaxErrorLabel' || - functionName === 'Object.exports.__esModule' - ) { - functionName = '(anonymous function)'; - } - - const prettyURL = getPrettyURL( - sourceFileName, - sourceLineNumber, - sourceColumnNumber, - fileName, - lineNumber, - columnNumber, - compiled - ); - - let needsHidden = false; - const isInternalUrl = isInternalFile(sourceFileName, fileName); - const isThrownIntentionally = !isBultinErrorName(errorName); - const shouldCollapse = - isInternalUrl && (isThrownIntentionally || omits.hasReachedAppCode); - - if (!isInternalUrl) { - omits.hasReachedAppCode = true; - } - - if (shouldCollapse) { - ++omits.value; - needsHidden = true; - } - - let collapseElement = null; - if (!shouldCollapse || lastElement) { - if (omits.value > 0) { - const capV = omits.value; - const omittedFrames = getGroupToggle(document, capV, omitBundle); - window.requestAnimationFrame(() => { - insertBeforeBundle( - document, - parentContainer, - capV, - omitBundle, - omittedFrames - ); - }); - if (lastElement && shouldCollapse) { - collapseElement = omittedFrames; - } else { - parentContainer.appendChild(omittedFrames); - } - ++omits.bundle; - } - omits.value = 0; - } - - let onSourceClick = null; - if (sourceFileName) { - // e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1" - const isInternalWebpackBootstrapCode = - sourceFileName.trim().indexOf(' ') !== -1; - if (!isInternalWebpackBootstrapCode) { - onSourceClick = () => { - // Keep this in sync with react-error-overlay/middleware.js - fetch( - '/__open-stack-frame-in-editor?fileName=' + - window.encodeURIComponent(sourceFileName) + - '&lineNumber=' + - window.encodeURIComponent(sourceLineNumber || 1) - ).then(() => {}, () => {}); - }; - } - } - - const elem = frameDiv( - document, - functionName, - prettyURL, - shouldCollapse, - onSourceClick - ); - if (needsHidden) { - applyStyles(elem, hiddenStyle); - elem.setAttribute('name', 'bundle-' + omitBundle); - } - - let hasSource = false; - if (!shouldCollapse) { - if ( - compiled && - scriptLines && - scriptLines.length !== 0 && - lineNumber != null - ) { - elem.appendChild( - createCode( - document, - scriptLines, - lineNumber, - columnNumber, - contextSize, - critical, - onSourceClick - ) - ); - hasSource = true; - } else if ( - !compiled && - sourceLines && - sourceLines.length !== 0 && - sourceLineNumber != null - ) { - elem.appendChild( - createCode( - document, - sourceLines, - sourceLineNumber, - sourceColumnNumber, - contextSize, - critical, - onSourceClick - ) - ); - hasSource = true; - } - } - - return { elem: elem, hasSource: hasSource, collapseElement: collapseElement }; -} - -export { createFrame }; diff --git a/packages/react-error-overlay/src/components/frames.js b/packages/react-error-overlay/src/components/frames.js deleted file mode 100644 index 8bd505092..000000000 --- a/packages/react-error-overlay/src/components/frames.js +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -import type { StackFrame } from '../utils/stack-frame'; -import { applyStyles } from '../utils/dom/css'; -import { traceStyle, toggleStyle } from '../styles'; -import { enableTabClick } from '../utils/dom/enableTabClick'; -import { createFrame } from './frame'; - -type OmitsObject = { - value: number, - bundle: number, - hasReachedAppCode: boolean, -}; -type FrameSetting = { compiled: boolean }; -export type { OmitsObject, FrameSetting }; - -function createFrameWrapper( - document: Document, - parent: HTMLDivElement, - factory, - lIndex: number, - frameSettings: FrameSetting[], - contextSize: number -) { - const fac = factory(); - if (fac == null) { - return; - } - const { hasSource, elem, collapseElement } = fac; - - const elemWrapper = document.createElement('div'); - elemWrapper.appendChild(elem); - - if (hasSource) { - const compiledDiv = document.createElement('div'); - enableTabClick(compiledDiv); - applyStyles(compiledDiv, toggleStyle); - - const o = frameSettings[lIndex]; - const compiledText = document.createTextNode( - 'View ' + (o && o.compiled ? 'source' : 'compiled') - ); - compiledDiv.addEventListener('click', function() { - if (o) { - o.compiled = !o.compiled; - } - - const next = createFrameWrapper( - document, - parent, - factory, - lIndex, - frameSettings, - contextSize - ); - if (next != null) { - parent.insertBefore(next, elemWrapper); - parent.removeChild(elemWrapper); - } - }); - compiledDiv.appendChild(compiledText); - elemWrapper.appendChild(compiledDiv); - } - - if (collapseElement != null) { - elemWrapper.appendChild(collapseElement); - } - - return elemWrapper; -} - -function createFrames( - document: Document, - resolvedFrames: StackFrame[], - frameSettings: FrameSetting[], - contextSize: number, - errorName: ?string -) { - if (resolvedFrames.length !== frameSettings.length) { - throw new Error( - 'You must give a frame settings array of identical length to resolved frames.' - ); - } - const trace = document.createElement('div'); - applyStyles(trace, traceStyle); - - let index = 0; - let critical = true; - const omits: OmitsObject = { value: 0, bundle: 1, hasReachedAppCode: false }; - resolvedFrames.forEach(function(frame) { - const lIndex = index++; - const elem = createFrameWrapper( - document, - trace, - createFrame.bind( - undefined, - document, - frameSettings[lIndex], - frame, - contextSize, - critical, - omits, - omits.bundle, - trace, - index === resolvedFrames.length, - errorName - ), - lIndex, - frameSettings, - contextSize - ); - if (elem == null) { - return; - } - critical = false; - trace.appendChild(elem); - }); - //TODO: fix this - omits.value = 0; - - return trace; -} - -export { createFrames }; diff --git a/packages/react-error-overlay/src/components/overlay.js b/packages/react-error-overlay/src/components/overlay.js deleted file mode 100644 index 69acf9ad4..000000000 --- a/packages/react-error-overlay/src/components/overlay.js +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -import { applyStyles } from '../utils/dom/css'; -import { containerStyle, overlayStyle, headerStyle } from '../styles'; -import { createClose } from './close'; -import { createFrames } from './frames'; -import { createFooter } from './footer'; -import type { CloseCallback } from './close'; -import type { StackFrame } from '../utils/stack-frame'; -import { updateAdditional } from './additional'; -import type { FrameSetting } from './frames'; -import type { SwitchCallback } from './additional'; - -function createOverlay( - document: Document, - name: ?string, - message: string, - frames: StackFrame[], - contextSize: number, - currentError: number, - totalErrors: number, - switchCallback: SwitchCallback, - closeCallback: CloseCallback -): { - overlay: HTMLDivElement, - additional: HTMLDivElement, -} { - const frameSettings: FrameSetting[] = frames.map(() => ({ compiled: false })); - // Create overlay - const overlay = document.createElement('div'); - applyStyles(overlay, overlayStyle); - - // Create container - const container = document.createElement('div'); - applyStyles(container, containerStyle); - overlay.appendChild(container); - container.appendChild(createClose(document, closeCallback)); - - // Create "Errors X of Y" in case of multiple errors - const additional = document.createElement('div'); - updateAdditional( - document, - additional, - currentError, - totalErrors, - switchCallback - ); - container.appendChild(additional); - - // Create header - const header = document.createElement('div'); - applyStyles(header, headerStyle); - - // Make message prettier - let finalMessage = - message.match(/^\w*:/) || !name ? message : name + ': ' + message; - - finalMessage = finalMessage - // TODO: maybe remove this prefix from fbjs? - // It's just scaring people - .replace(/^Invariant Violation:\s*/, '') - // This is not helpful either: - .replace(/^Warning:\s*/, '') - // Break the actionable part to the next line. - // AFAIK React 16+ should already do this. - .replace(' Check the render method', '\n\nCheck the render method') - .replace(' Check your code at', '\n\nCheck your code at'); - - // Put it in the DOM - header.appendChild(document.createTextNode(finalMessage)); - container.appendChild(header); - - // Create trace - container.appendChild( - createFrames(document, frames, frameSettings, contextSize, name) - ); - - // Show message - container.appendChild(createFooter(document)); - - return { - overlay, - additional, - }; -} - -export { createOverlay }; diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js new file mode 100644 index 000000000..bd193eb50 --- /dev/null +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React, { PureComponent } from 'react'; +import Overlay from '../components/Overlay'; +import Footer from '../components/Footer'; +import Header from '../components/Header'; +import CodeBlock from '../components/CodeBlock'; +import generateAnsiHTML from '../utils/generateAnsiHTML'; + +class CompileErrorContainer extends PureComponent { + render() { + const { error } = this.props; + return ( + <Overlay> + <Header headerText="Failed to compile" /> + <CodeBlock main={true} codeHTML={generateAnsiHTML(error)} /> + <Footer line1="This error occurred during the build time and cannot be dismissed." /> + </Overlay> + ); + } +} + +export default CompileErrorContainer; diff --git a/packages/react-error-overlay/src/containers/RuntimeError.js b/packages/react-error-overlay/src/containers/RuntimeError.js new file mode 100644 index 000000000..c64824137 --- /dev/null +++ b/packages/react-error-overlay/src/containers/RuntimeError.js @@ -0,0 +1,68 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React from 'react'; +import Header from '../components/Header'; +import StackTrace from './StackTrace'; +import type { StackFrame } from '../utils/stack-frame'; + +const wrapperStyle = { + display: 'flex', + flexDirection: 'column', +}; + +type ErrorRecord = {| + error: Error, + unhandledRejection: boolean, + contextSize: number, + stackFrames: StackFrame[], +|}; + +type Props = {| + errorRecord: ErrorRecord, + launchEditorEndpoint: ?string, +|}; + +function RuntimeError({ errorRecord, launchEditorEndpoint }: Props) { + const { error, unhandledRejection, contextSize, stackFrames } = errorRecord; + const errorName = unhandledRejection + ? 'Unhandled Rejection (' + error.name + ')' + : error.name; + + // Make header prettier + const message = error.message; + let headerText = + message.match(/^\w*:/) || !errorName ? message : errorName + ': ' + message; + + headerText = headerText + // TODO: maybe remove this prefix from fbjs? + // It's just scaring people + .replace(/^Invariant Violation:\s*/, '') + // This is not helpful either: + .replace(/^Warning:\s*/, '') + // Break the actionable part to the next line. + // AFAIK React 16+ should already do this. + .replace(' Check the render method', '\n\nCheck the render method') + .replace(' Check your code at', '\n\nCheck your code at'); + + return ( + <div style={wrapperStyle}> + <Header headerText={headerText} /> + <StackTrace + stackFrames={stackFrames} + errorName={errorName} + contextSize={contextSize} + launchEditorEndpoint={launchEditorEndpoint} + /> + </div> + ); +} + +export default RuntimeError; diff --git a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js new file mode 100644 index 000000000..c84adb194 --- /dev/null +++ b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React, { PureComponent } from 'react'; +import Overlay from '../components/Overlay'; +import CloseButton from '../components/CloseButton'; +import NavigationBar from '../components/NavigationBar'; +import RuntimeError from './RuntimeError'; +import Footer from '../components/Footer'; + +class RuntimeErrorContainer extends PureComponent { + state = { + currentIndex: 0, + }; + + previous = () => { + this.setState((state, props) => ({ + currentIndex: + state.currentIndex > 0 + ? state.currentIndex - 1 + : props.errorRecords.length - 1, + })); + }; + + next = () => { + this.setState((state, props) => ({ + currentIndex: + state.currentIndex < props.errorRecords.length - 1 + ? state.currentIndex + 1 + : 0, + })); + }; + + shortcutHandler = (key: string) => { + if (key === 'Escape') { + this.props.close(); + } else if (key === 'ArrowLeft') { + this.previous(); + } else if (key === 'ArrowRight') { + this.next(); + } + }; + + render() { + const { errorRecords, close } = this.props; + const totalErrors = errorRecords.length; + return ( + <Overlay shortcutHandler={this.shortcutHandler}> + <CloseButton close={close} /> + {totalErrors > 1 && + <NavigationBar + currentError={this.state.currentIndex + 1} + totalErrors={totalErrors} + previous={this.previous} + next={this.next} + />} + <RuntimeError + errorRecord={errorRecords[this.state.currentIndex]} + launchEditorEndpoint={this.props.launchEditorEndpoint} + /> + <Footer + line1="This screen is visible only in development. It will not appear if the app crashes in production." + line2="Open your browser’s developer console to further inspect this error." + /> + </Overlay> + ); + } +} + +export default RuntimeErrorContainer; diff --git a/packages/react-error-overlay/src/containers/StackFrame.js b/packages/react-error-overlay/src/containers/StackFrame.js new file mode 100644 index 000000000..c95ce003f --- /dev/null +++ b/packages/react-error-overlay/src/containers/StackFrame.js @@ -0,0 +1,188 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React, { Component } from 'react'; +import CodeBlock from './StackFrameCodeBlock'; +import { getPrettyURL } from '../utils/getPrettyURL'; +import { darkGray } from '../styles'; + +const linkStyle = { + fontSize: '0.9em', + marginBottom: '0.9em', +}; + +const anchorStyle = { + textDecoration: 'none', + color: darkGray, + cursor: 'pointer', +}; + +const codeAnchorStyle = { + cursor: 'pointer', +}; + +const toggleStyle = { + marginBottom: '1.5em', + color: darkGray, + cursor: 'pointer', + border: 'none', + display: 'block', + width: '100%', + textAlign: 'left', + background: '#fff', + fontFamily: 'Consolas, Menlo, monospace', + fontSize: '1em', + padding: '0px', + lineHeight: '1.5', +}; + +class StackFrame extends Component { + state = { + compiled: false, + }; + + toggleCompiled = () => { + this.setState(state => ({ + compiled: !state.compiled, + })); + }; + + canOpenInEditor() { + if (!this.props.launchEditorEndpoint) { + return; + } + const { _originalFileName: sourceFileName } = this.props.frame; + // Unknown file + if (!sourceFileName) { + return false; + } + // e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1" + const isInternalWebpackBootstrapCode = + sourceFileName.trim().indexOf(' ') !== -1; + if (isInternalWebpackBootstrapCode) { + return false; + } + // Code is in a real file + return true; + } + + openInEditor = () => { + if (!this.canOpenInEditor()) { + return; + } + const { + _originalFileName: sourceFileName, + _originalLineNumber: sourceLineNumber, + } = this.props.frame; + // Keep this in sync with react-error-overlay/middleware.js + fetch( + `${this.props.launchEditorEndpoint}?fileName=` + + window.encodeURIComponent(sourceFileName) + + '&lineNumber=' + + window.encodeURIComponent(sourceLineNumber || 1) + ).then(() => {}, () => {}); + }; + + onKeyDown = (e: SyntheticKeyboardEvent) => { + if (e.key === 'Enter') { + this.openInEditor(); + } + }; + + render() { + const { frame, contextSize, critical, showCode } = this.props; + const { + fileName, + lineNumber, + columnNumber, + _scriptCode: scriptLines, + _originalFileName: sourceFileName, + _originalLineNumber: sourceLineNumber, + _originalColumnNumber: sourceColumnNumber, + _originalScriptCode: sourceLines, + } = frame; + const functionName = frame.getFunctionName(); + + const compiled = this.state.compiled; + const url = getPrettyURL( + sourceFileName, + sourceLineNumber, + sourceColumnNumber, + fileName, + lineNumber, + columnNumber, + compiled + ); + + let codeBlockProps = null; + if (showCode) { + if ( + compiled && + scriptLines && + scriptLines.length !== 0 && + lineNumber != null + ) { + codeBlockProps = { + lines: scriptLines, + lineNum: lineNumber, + columnNum: columnNumber, + contextSize, + main: critical, + }; + } else if ( + !compiled && + sourceLines && + sourceLines.length !== 0 && + sourceLineNumber != null + ) { + codeBlockProps = { + lines: sourceLines, + lineNum: sourceLineNumber, + columnNum: sourceColumnNumber, + contextSize, + main: critical, + }; + } + } + + const canOpenInEditor = this.canOpenInEditor(); + return ( + <div> + <div> + {functionName} + </div> + <div style={linkStyle}> + <a + style={canOpenInEditor ? anchorStyle : null} + onClick={canOpenInEditor ? this.openInEditor : null} + onKeyDown={canOpenInEditor ? this.onKeyDown : null} + tabIndex={canOpenInEditor ? '0' : null} + > + {url} + </a> + </div> + {codeBlockProps && + <span> + <a + onClick={canOpenInEditor ? this.openInEditor : null} + style={canOpenInEditor ? codeAnchorStyle : null} + > + <CodeBlock {...codeBlockProps} /> + </a> + <button style={toggleStyle} onClick={this.toggleCompiled}> + {'View ' + (compiled ? 'source' : 'compiled')} + </button> + </span>} + </div> + ); + } +} + +export default StackFrame; diff --git a/packages/react-error-overlay/src/components/code.js b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js similarity index 71% rename from packages/react-error-overlay/src/components/code.js rename to packages/react-error-overlay/src/containers/StackFrameCodeBlock.js index 580fe3b1b..2ed685cff 100644 --- a/packages/react-error-overlay/src/components/code.js +++ b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js @@ -8,33 +8,29 @@ */ /* @flow */ -import type { ScriptLine } from '../utils/stack-frame'; +import React from 'react'; +import CodeBlock from '../components/CodeBlock'; import { applyStyles } from '../utils/dom/css'; import { absolutifyCaret } from '../utils/dom/absolutifyCaret'; -import { - codeStyle, - primaryErrorStyle, - primaryPreStyle, - secondaryErrorStyle, - secondaryPreStyle, -} from '../styles'; - -import generateAnsiHtml from 'react-dev-utils/ansiHTML'; +import type { ScriptLine } from '../utils/stack-frame'; +import { primaryErrorStyle, secondaryErrorStyle } from '../styles'; +import generateAnsiHTML from '../utils/generateAnsiHTML'; import codeFrame from 'babel-code-frame'; -function createCode( - document: Document, - sourceLines: ScriptLine[], +type StackFrameCodeBlockPropsType = {| + lines: ScriptLine[], lineNum: number, - columnNum: number | null, + columnNum: number, contextSize: number, main: boolean, - onSourceClick: ?Function -) { +|}; + +function StackFrameCodeBlock(props: StackFrameCodeBlockPropsType) { + const { lines, lineNum, columnNum, contextSize, main } = props; const sourceCode = []; let whiteSpace = Infinity; - sourceLines.forEach(function(e) { + lines.forEach(function(e) { const { content: text } = e; const m = text.match(/^\s*/); if (text === '') { @@ -46,7 +42,7 @@ function createCode( whiteSpace = 0; } }); - sourceLines.forEach(function(e) { + lines.forEach(function(e) { let { content: text } = e; const { lineNumber: line } = e; @@ -65,11 +61,10 @@ function createCode( linesBelow: contextSize, } ); - const htmlHighlight = generateAnsiHtml(ansiHighlight); + const htmlHighlight = generateAnsiHTML(ansiHighlight); const code = document.createElement('code'); code.innerHTML = htmlHighlight; absolutifyCaret(code); - applyStyles(code, codeStyle); const ccn = code.childNodes; // eslint-disable-next-line @@ -91,19 +86,8 @@ function createCode( break oLoop; } } - const pre = document.createElement('pre'); - applyStyles(pre, main ? primaryPreStyle : secondaryPreStyle); - pre.appendChild(code); - - if (typeof onSourceClick === 'function') { - let handler = onSourceClick; - pre.style.cursor = 'pointer'; - pre.addEventListener('click', function() { - handler(); - }); - } - return pre; + return <CodeBlock main={main} codeHTML={code.innerHTML} />; } -export { createCode }; +export default StackFrameCodeBlock; diff --git a/packages/react-error-overlay/src/containers/StackTrace.js b/packages/react-error-overlay/src/containers/StackTrace.js new file mode 100644 index 000000000..4cb20bce1 --- /dev/null +++ b/packages/react-error-overlay/src/containers/StackTrace.js @@ -0,0 +1,95 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import React, { Component } from 'react'; +import StackFrame from './StackFrame'; +import Collapsible from '../components/Collapsible'; +import { isInternalFile } from '../utils/isInternalFile'; +import { isBultinErrorName } from '../utils/isBultinErrorName'; + +const traceStyle = { + fontSize: '1em', + flex: '0 1 auto', + minHeight: '0px', + overflow: 'auto', +}; + +class StackTrace extends Component { + renderFrames() { + const { + stackFrames, + errorName, + contextSize, + launchEditorEndpoint, + } = this.props; + const renderedFrames = []; + let hasReachedAppCode = false, + currentBundle = [], + bundleCount = 0; + + stackFrames.forEach((frame, index) => { + const { fileName, _originalFileName: sourceFileName } = frame; + const isInternalUrl = isInternalFile(sourceFileName, fileName); + const isThrownIntentionally = !isBultinErrorName(errorName); + const shouldCollapse = + isInternalUrl && (isThrownIntentionally || hasReachedAppCode); + + if (!isInternalUrl) { + hasReachedAppCode = true; + } + + const frameEle = ( + <StackFrame + key={'frame-' + index} + frame={frame} + contextSize={contextSize} + critical={index === 0} + showCode={!shouldCollapse} + launchEditorEndpoint={launchEditorEndpoint} + /> + ); + const lastElement = index === stackFrames.length - 1; + + if (shouldCollapse) { + currentBundle.push(frameEle); + } + + if (!shouldCollapse || lastElement) { + if (currentBundle.length === 1) { + renderedFrames.push(currentBundle[0]); + } else if (currentBundle.length > 1) { + bundleCount++; + renderedFrames.push( + <Collapsible key={'bundle-' + bundleCount}> + {currentBundle} + </Collapsible> + ); + } + currentBundle = []; + } + + if (!shouldCollapse) { + renderedFrames.push(frameEle); + } + }); + + return renderedFrames; + } + + render() { + return ( + <div style={traceStyle}> + {this.renderFrames()} + </div> + ); + } +} + +export default StackTrace; diff --git a/packages/react-error-overlay/src/effects/shortcuts.js b/packages/react-error-overlay/src/effects/shortcuts.js deleted file mode 100644 index bf8fd6d5e..000000000 --- a/packages/react-error-overlay/src/effects/shortcuts.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -const SHORTCUT_ESCAPE = 'SHORTCUT_ESCAPE', - SHORTCUT_LEFT = 'SHORTCUT_LEFT', - SHORTCUT_RIGHT = 'SHORTCUT_RIGHT'; - -let boundKeyHandler = null; - -type ShortcutCallback = (type: string) => void; - -function keyHandler(callback: ShortcutCallback, e: KeyboardEvent) { - const { key, keyCode, which } = e; - if (key === 'Escape' || keyCode === 27 || which === 27) { - callback(SHORTCUT_ESCAPE); - } else if (key === 'ArrowLeft' || keyCode === 37 || which === 37) { - callback(SHORTCUT_LEFT); - } else if (key === 'ArrowRight' || keyCode === 39 || which === 39) { - callback(SHORTCUT_RIGHT); - } -} - -function registerShortcuts(target: EventTarget, callback: ShortcutCallback) { - if (boundKeyHandler !== null) { - return; - } - boundKeyHandler = keyHandler.bind(undefined, callback); - target.addEventListener('keydown', boundKeyHandler); -} - -function unregisterShortcuts(target: EventTarget) { - if (boundKeyHandler === null) { - return; - } - target.removeEventListener('keydown', boundKeyHandler); - boundKeyHandler = null; -} - -export { - SHORTCUT_ESCAPE, - SHORTCUT_LEFT, - SHORTCUT_RIGHT, - registerShortcuts as register, - unregisterShortcuts as unregister, - keyHandler as handler, -}; diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index 4f3b23167..ff4f1c714 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -8,11 +8,158 @@ */ /* @flow */ -import { inject, uninject } from './overlay'; +import React from 'react'; +import ReactDOM from 'react-dom'; +import CompileErrorContainer from './containers/CompileErrorContainer'; +import RuntimeErrorContainer from './containers/RuntimeErrorContainer'; +import { listenToRuntimeErrors } from './listenToRuntimeErrors'; +import { iframeStyle, overlayStyle } from './styles'; +import { applyStyles } from './utils/dom/css'; -inject(); -if (module.hot && typeof module.hot.dispose === 'function') { - module.hot.dispose(function() { - uninject(); +import type { ErrorRecord } from './listenToRuntimeErrors'; + +type RuntimeReportingOptions = {| + onError: () => void, + launchEditorEndpoint: string, +|}; + +let iframe: null | HTMLIFrameElement = null; +let isLoadingIframe: boolean = false; + +let renderedElement: null | React.Element<any> = null; +let currentBuildError: null | string = null; +let currentRuntimeErrorRecords: Array<ErrorRecord> = []; +let currentRuntimeErrorOptions: null | RuntimeReportingOptions = null; +let stopListeningToRuntimeErrors: null | (() => void) = null; + +export function reportBuildError(error: string) { + currentBuildError = error; + update(); +} + +export function dismissBuildError() { + currentBuildError = null; + update(); +} + +export function startReportingRuntimeErrors(options: RuntimeReportingOptions) { + if (stopListeningToRuntimeErrors !== null) { + throw new Error('Already listening'); + } + currentRuntimeErrorOptions = options; + listenToRuntimeErrors(errorRecord => { + try { + if (typeof options.onError === 'function') { + options.onError.call(null); + } + } finally { + handleRuntimeError(errorRecord); + } }); } + +function handleRuntimeError(errorRecord) { + if ( + currentRuntimeErrorRecords.some(({ error }) => error === errorRecord.error) + ) { + // Deduplicate identical errors. + // This fixes https://github.com/facebookincubator/create-react-app/issues/3011. + return; + } + currentRuntimeErrorRecords = currentRuntimeErrorRecords.concat([errorRecord]); + update(); +} + +function dismissRuntimeErrors() { + currentRuntimeErrorRecords = []; + update(); +} + +export function stopReportingRuntimeErrors() { + if (stopListeningToRuntimeErrors === null) { + throw new Error('Not currently listening'); + } + currentRuntimeErrorOptions = null; + try { + stopListeningToRuntimeErrors(); + } finally { + stopListeningToRuntimeErrors = null; + } +} + +function update() { + renderedElement = render(); + // Loading iframe can be either sync or async depending on the browser. + if (isLoadingIframe) { + // Iframe is loading. + // First render will happen soon--don't need to do anything. + return; + } + if (iframe) { + // Iframe has already loaded. + // Just update it. + updateIframeContent(); + return; + } + // We need to schedule the first render. + isLoadingIframe = true; + const loadingIframe = window.document.createElement('iframe'); + applyStyles(loadingIframe, iframeStyle); + loadingIframe.onload = function() { + const iframeDocument = loadingIframe.contentDocument; + if (iframeDocument != null && iframeDocument.body != null) { + iframeDocument.body.style.margin = '0'; + // Keep popup within body boundaries for iOS Safari + iframeDocument.body.style['max-width'] = '100vw'; + const iframeRoot = iframeDocument.createElement('div'); + applyStyles(iframeRoot, overlayStyle); + iframeDocument.body.appendChild(iframeRoot); + + // Ready! Now we can update the UI. + iframe = loadingIframe; + isLoadingIframe = false; + updateIframeContent(); + } + }; + const appDocument = window.document; + appDocument.body.appendChild(loadingIframe); +} + +function render() { + if (currentBuildError) { + return <CompileErrorContainer error={currentBuildError} />; + } + if (currentRuntimeErrorRecords.length > 0) { + if (!currentRuntimeErrorOptions) { + throw new Error('Expected options to be injected.'); + } + return ( + <RuntimeErrorContainer + errorRecords={currentRuntimeErrorRecords} + close={dismissRuntimeErrors} + launchEditorEndpoint={currentRuntimeErrorOptions.launchEditorEndpoint} + /> + ); + } + return null; +} + +function updateIframeContent() { + if (iframe === null) { + throw new Error('Iframe has not been created yet.'); + } + const iframeBody = iframe.contentDocument.body; + if (!iframeBody) { + throw new Error('Expected iframe to have a body.'); + } + const iframeRoot = iframeBody.firstChild; + if (renderedElement === null) { + // Destroy iframe and force it to be recreated on next error + window.document.body.removeChild(iframe); + ReactDOM.unmountComponentAtNode(iframeRoot); + iframe = null; + return; + } + // Update the overlay + ReactDOM.render(renderedElement, iframeRoot); +} diff --git a/packages/react-error-overlay/src/listenToRuntimeErrors.js b/packages/react-error-overlay/src/listenToRuntimeErrors.js new file mode 100644 index 000000000..45c43fa5d --- /dev/null +++ b/packages/react-error-overlay/src/listenToRuntimeErrors.js @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +import { + register as registerError, + unregister as unregisterError, +} from './effects/unhandledError'; +import { + register as registerPromise, + unregister as unregisterPromise, +} from './effects/unhandledRejection'; +import { + register as registerStackTraceLimit, + unregister as unregisterStackTraceLimit, +} from './effects/stackTraceLimit'; +import { + permanentRegister as permanentRegisterConsole, + registerReactStack, + unregisterReactStack, +} from './effects/proxyConsole'; +import { massage as massageWarning } from './utils/warnings'; +import getStackFrames from './utils/getStackFrames'; + +import type { StackFrame } from './utils/stack-frame'; + +const CONTEXT_SIZE: number = 3; + +export type ErrorRecord = {| + error: Error, + unhandledRejection: boolean, + contextSize: number, + stackFrames: StackFrame[], +|}; + +export function listenToRuntimeErrors(crash: ErrorRecord => void) { + function crashWithFrames(error: Error, unhandledRejection = false) { + getStackFrames(error, unhandledRejection, CONTEXT_SIZE) + .then(stackFrames => { + if (stackFrames == null) { + return; + } + crash({ + error, + unhandledRejection, + contextSize: CONTEXT_SIZE, + stackFrames, + }); + }) + .catch(e => { + console.log('Could not get the stack frames of error:', e); + }); + } + registerError(window, error => crashWithFrames(error, false)); + registerPromise(window, error => crashWithFrames(error, true)); + registerStackTraceLimit(); + registerReactStack(); + permanentRegisterConsole('error', (warning, stack) => { + const data = massageWarning(warning, stack); + crashWithFrames( + // $FlowFixMe + { + message: data.message, + stack: data.stack, + __unmap_source: '/static/js/bundle.js', + }, + false + ); + }); + + return function stopListening() { + unregisterStackTraceLimit(); + unregisterPromise(window); + unregisterError(window); + unregisterReactStack(); + }; +} diff --git a/packages/react-error-overlay/src/overlay.js b/packages/react-error-overlay/src/overlay.js deleted file mode 100644 index 181cb0271..000000000 --- a/packages/react-error-overlay/src/overlay.js +++ /dev/null @@ -1,235 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -import { - register as registerError, - unregister as unregisterError, -} from './effects/unhandledError'; -import { - register as registerPromise, - unregister as unregisterPromise, -} from './effects/unhandledRejection'; -import { - register as registerShortcuts, - unregister as unregisterShortcuts, - handler as keyEventHandler, - SHORTCUT_ESCAPE, - SHORTCUT_LEFT, - SHORTCUT_RIGHT, -} from './effects/shortcuts'; -import { - register as registerStackTraceLimit, - unregister as unregisterStackTraceLimit, -} from './effects/stackTraceLimit'; -import { - permanentRegister as permanentRegisterConsole, - registerReactStack, - unregisterReactStack, -} from './effects/proxyConsole'; -import { massage as massageWarning } from './utils/warnings'; - -import { - consume as consumeError, - getErrorRecord, - drain as drainErrors, -} from './utils/errorRegister'; -import type { ErrorRecordReference } from './utils/errorRegister'; - -import type { StackFrame } from './utils/stack-frame'; -import { iframeStyle } from './styles'; -import { applyStyles } from './utils/dom/css'; -import { createOverlay } from './components/overlay'; -import { updateAdditional } from './components/additional'; - -const CONTEXT_SIZE: number = 3; -let iframeReference: HTMLIFrameElement | null = null; -let additionalReference = null; -let errorReferences: ErrorRecordReference[] = []; -let currReferenceIndex: number = -1; - -function render(name: ?string, message: string, resolvedFrames: StackFrame[]) { - disposeCurrentView(); - - const iframe = window.document.createElement('iframe'); - applyStyles(iframe, iframeStyle); - iframeReference = iframe; - iframe.onload = () => { - if (iframeReference == null) { - return; - } - const w = iframeReference.contentWindow; - const document = iframeReference.contentDocument; - - const { overlay, additional } = createOverlay( - document, - name, - message, - resolvedFrames, - CONTEXT_SIZE, - currReferenceIndex + 1, - errorReferences.length, - offset => { - switchError(offset); - }, - () => { - unmount(); - } - ); - if (w != null) { - w.onkeydown = event => { - keyEventHandler(type => shortcutHandler(type), event); - }; - } - if (document.body != null) { - document.body.style.margin = '0'; - // Keep popup within body boundaries for iOS Safari - // $FlowFixMe - document.body.style['max-width'] = '100vw'; - - (document.body: any).appendChild(overlay); - } - additionalReference = additional; - }; - window.document.body.appendChild(iframe); -} - -function renderErrorByIndex(index: number) { - currReferenceIndex = index; - - const { error, unhandledRejection, enhancedFrames } = getErrorRecord( - errorReferences[index] - ); - - if (unhandledRejection) { - render( - 'Unhandled Rejection (' + error.name + ')', - error.message, - enhancedFrames - ); - } else { - render(error.name, error.message, enhancedFrames); - } -} - -function switchError(offset) { - if (errorReferences.length === 0) { - return; - } - - let nextView = currReferenceIndex + offset; - - if (nextView < 0) { - nextView = errorReferences.length - 1; - } else if (nextView >= errorReferences.length) { - nextView = 0; - } - - renderErrorByIndex(nextView); -} - -function disposeCurrentView() { - if (iframeReference === null) { - return; - } - window.document.body.removeChild(iframeReference); - iframeReference = null; - additionalReference = null; -} - -function unmount() { - disposeCurrentView(); - drainErrors(); - errorReferences = []; - currReferenceIndex = -1; -} - -function crash(error: Error, unhandledRejection = false) { - if (module.hot && typeof module.hot.decline === 'function') { - module.hot.decline(); - } - consumeError(error, unhandledRejection, CONTEXT_SIZE) - .then(ref => { - if (ref == null) { - return; - } - errorReferences.push(ref); - if (iframeReference !== null && additionalReference !== null) { - updateAdditional( - iframeReference.contentDocument, - additionalReference, - currReferenceIndex + 1, - errorReferences.length, - offset => { - switchError(offset); - } - ); - } else { - if (errorReferences.length !== 1) { - throw new Error('Something is *really* wrong.'); - } - renderErrorByIndex((currReferenceIndex = 0)); - } - }) - .catch(e => { - console.log('Could not consume error:', e); - }); -} - -function shortcutHandler(type: string) { - switch (type) { - case SHORTCUT_ESCAPE: { - unmount(); - break; - } - case SHORTCUT_LEFT: { - switchError(-1); - break; - } - case SHORTCUT_RIGHT: { - switchError(1); - break; - } - default: { - //TODO: this - break; - } - } -} - -function inject() { - registerError(window, error => crash(error)); - registerPromise(window, error => crash(error, true)); - registerShortcuts(window, shortcutHandler); - registerStackTraceLimit(); - - registerReactStack(); - permanentRegisterConsole('error', (warning, stack) => { - const data = massageWarning(warning, stack); - crash( - // $FlowFixMe - { - message: data.message, - stack: data.stack, - __unmap_source: '/static/js/bundle.js', - }, - false - ); - }); -} - -function uninject() { - unregisterStackTraceLimit(); - unregisterShortcuts(window); - unregisterPromise(window); - unregisterError(window); - unregisterReactStack(); -} - -export { inject, uninject }; diff --git a/packages/react-error-overlay/src/styles.js b/packages/react-error-overlay/src/styles.js index bf17561d7..d6557c5d9 100644 --- a/packages/react-error-overlay/src/styles.js +++ b/packages/react-error-overlay/src/styles.js @@ -24,7 +24,7 @@ const iframeStyle = { width: '100%', height: '100%', border: 'none', - 'z-index': 2147483647 - 1, // below the compile error overlay + 'z-index': 2147483647, }; const overlayStyle = { @@ -35,84 +35,6 @@ const overlayStyle = { 'background-color': white, }; -const containerStyle = { - position: 'relative', - display: 'inline-flex', - 'flex-direction': 'column', - height: '100%', - width: '1024px', - 'max-width': '100%', - 'overflow-x': 'hidden', - 'overflow-y': 'auto', - padding: '0.5rem', - 'box-sizing': 'border-box', - 'text-align': 'left', - 'font-family': 'Consolas, Menlo, monospace', - 'font-size': '11px', - 'white-space': 'pre-wrap', - 'word-break': 'break-word', - 'line-height': 1.5, - color: black, -}; - -const hintsStyle = { - color: darkGray, -}; - -const hintStyle = { - padding: '0.5em 1em', - cursor: 'pointer', -}; - -const closeButtonStyle = { - color: black, - 'line-height': '1rem', - 'font-size': '1.5rem', - padding: '1rem', - cursor: 'pointer', - position: 'absolute', - right: 0, - top: 0, -}; - -const additionalChildStyle = { - 'margin-bottom': '0.5rem', -}; - -const headerStyle = { - 'font-size': '2em', - 'font-family': 'sans-serif', - color: red, - 'white-space': 'pre-wrap', - // Top bottom margin spaces header - // Right margin revents overlap with close button - margin: '0 2rem 0.75rem 0', - flex: '0 0 auto', - 'max-height': '50%', - overflow: 'auto', -}; - -const functionNameStyle = {}; - -const linkStyle = { - 'font-size': '0.9em', - 'margin-bottom': '0.9em', -}; - -const anchorStyle = { - 'text-decoration': 'none', - color: darkGray, -}; - -const traceStyle = { - 'font-size': '1em', - flex: '0 1 auto', - 'min-height': '0px', - overflow: 'auto', -}; - -const depStyle = {}; - const primaryErrorStyle = { 'background-color': lightRed, }; @@ -121,104 +43,14 @@ const secondaryErrorStyle = { 'background-color': yellow, }; -const omittedFramesCollapsedStyle = { - color: black, - cursor: 'pointer', - 'margin-bottom': '1.5em', -}; - -const omittedFramesExpandedStyle = { - color: black, - cursor: 'pointer', - 'margin-bottom': '0.6em', -}; - -const _preStyle = { - display: 'block', - padding: '0.5em', - 'margin-top': '0.5em', - 'margin-bottom': '0.5em', - 'overflow-x': 'auto', - 'white-space': 'pre-wrap', - 'border-radius': '0.25rem', -}; -const primaryPreStyle = Object.assign({}, _preStyle, { - 'background-color': redTransparent, -}); -const secondaryPreStyle = Object.assign({}, _preStyle, { - 'background-color': yellowTransparent, -}); - -const toggleStyle = { - 'margin-bottom': '1.5em', - color: darkGray, - cursor: 'pointer', -}; - -const codeStyle = { - 'font-family': 'Consolas, Menlo, monospace', -}; - -const hiddenStyle = { - display: 'none', -}; - -const groupStyle = { - 'margin-right': '1em', -}; - -const _groupElemStyle = { - 'background-color': redTransparent, - color: red, - border: 'none', - 'border-radius': '4px', - padding: '3px 6px', - cursor: 'pointer', -}; - -const groupElemLeft = Object.assign({}, _groupElemStyle, { - 'border-top-right-radius': '0px', - 'border-bottom-right-radius': '0px', - 'margin-right': '1px', -}); - -const groupElemRight = Object.assign({}, _groupElemStyle, { - 'border-top-left-radius': '0px', - 'border-bottom-left-radius': '0px', -}); - -const footerStyle = { - 'font-family': 'sans-serif', - color: darkGray, - 'margin-top': '0.5rem', - flex: '0 0 auto', -}; - export { - containerStyle, iframeStyle, overlayStyle, - hintsStyle, - hintStyle, - closeButtonStyle, - additionalChildStyle, - headerStyle, - functionNameStyle, - linkStyle, - anchorStyle, - traceStyle, - depStyle, primaryErrorStyle, - primaryPreStyle, secondaryErrorStyle, - secondaryPreStyle, - omittedFramesCollapsedStyle, - omittedFramesExpandedStyle, - toggleStyle, - codeStyle, - hiddenStyle, - groupStyle, - groupElemLeft, - groupElemRight, - footerStyle, + black, + darkGray, + red, + redTransparent, + yellowTransparent, }; diff --git a/packages/react-error-overlay/src/utils/dom/enableTabClick.js b/packages/react-error-overlay/src/utils/dom/enableTabClick.js deleted file mode 100644 index b663c055f..000000000 --- a/packages/react-error-overlay/src/utils/dom/enableTabClick.js +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -/* @flow */ -function enableTabClick(node: Element) { - node.setAttribute('tabindex', '0'); - node.addEventListener('keydown', function(e: KeyboardEvent) { - const { key, which, keyCode } = e; - if (key === 'Enter' || which === 13 || keyCode === 13) { - e.preventDefault(); - if (typeof e.target.click === 'function') { - e.target.click(); - } - } - }); -} - -export { enableTabClick }; diff --git a/packages/react-dev-utils/ansiHTML.js b/packages/react-error-overlay/src/utils/generateAnsiHTML.js similarity index 95% rename from packages/react-dev-utils/ansiHTML.js rename to packages/react-error-overlay/src/utils/generateAnsiHTML.js index 90bf70374..509daddc2 100644 --- a/packages/react-dev-utils/ansiHTML.js +++ b/packages/react-error-overlay/src/utils/generateAnsiHTML.js @@ -7,10 +7,11 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -'use strict'; +/* @flow */ + +import Anser from 'anser'; +import { AllHtmlEntities as Entities } from 'html-entities'; -var Anser = require('anser'); -var Entities = require('html-entities').AllHtmlEntities; var entities = new Entities(); // Color scheme inspired by https://chriskempson.github.io/base16/css/base16-github.css @@ -62,7 +63,7 @@ var anserMap = { 'ansi-white': 'darkgrey', }; -function ansiHTML(txt) { +function generateAnsiHTML(txt: string): string { var arr = new Anser().ansiToJson(entities.encode(txt), { use_classes: true, }); @@ -104,4 +105,4 @@ function ansiHTML(txt) { return result; } -module.exports = ansiHTML; +export default generateAnsiHTML; diff --git a/packages/react-error-overlay/src/utils/getLinesAround.js b/packages/react-error-overlay/src/utils/getLinesAround.js index a03e09a58..7cb2ea5c5 100644 --- a/packages/react-error-overlay/src/utils/getLinesAround.js +++ b/packages/react-error-overlay/src/utils/getLinesAround.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -//@flow +/* @flow */ import { ScriptLine } from './stack-frame'; /** diff --git a/packages/react-error-overlay/src/utils/getPrettyURL.js b/packages/react-error-overlay/src/utils/getPrettyURL.js new file mode 100644 index 000000000..47b834d08 --- /dev/null +++ b/packages/react-error-overlay/src/utils/getPrettyURL.js @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +function getPrettyURL( + sourceFileName: ?string, + sourceLineNumber: ?number, + sourceColumnNumber: ?number, + fileName: ?string, + lineNumber: ?number, + columnNumber: ?number, + compiled: boolean +): string { + let prettyURL; + if (!compiled && sourceFileName && typeof sourceLineNumber === 'number') { + // Remove everything up to the first /src/ or /node_modules/ + const trimMatch = /^[/|\\].*?[/|\\]((src|node_modules)[/|\\].*)/.exec( + sourceFileName + ); + if (trimMatch && trimMatch[1]) { + prettyURL = trimMatch[1]; + } else { + prettyURL = sourceFileName; + } + prettyURL += ':' + sourceLineNumber; + // Note: we intentionally skip 0's because they're produced by cheap Webpack maps + if (sourceColumnNumber) { + prettyURL += ':' + sourceColumnNumber; + } + } else if (fileName && typeof lineNumber === 'number') { + prettyURL = fileName + ':' + lineNumber; + // Note: we intentionally skip 0's because they're produced by cheap Webpack maps + if (columnNumber) { + prettyURL += ':' + columnNumber; + } + } else { + prettyURL = 'unknown'; + } + return prettyURL.replace('webpack://', '.'); +} + +export { getPrettyURL }; +export default getPrettyURL; diff --git a/packages/react-error-overlay/src/utils/getSourceMap.js b/packages/react-error-overlay/src/utils/getSourceMap.js index 80dd6002e..1d8405519 100644 --- a/packages/react-error-overlay/src/utils/getSourceMap.js +++ b/packages/react-error-overlay/src/utils/getSourceMap.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -//@flow +/* @flow */ import { SourceMapConsumer } from 'source-map'; /** diff --git a/packages/react-error-overlay/src/utils/errorRegister.js b/packages/react-error-overlay/src/utils/getStackFrames.js similarity index 59% rename from packages/react-error-overlay/src/utils/errorRegister.js rename to packages/react-error-overlay/src/utils/getStackFrames.js index 0bd3379ce..e5a407310 100644 --- a/packages/react-error-overlay/src/utils/errorRegister.js +++ b/packages/react-error-overlay/src/utils/getStackFrames.js @@ -13,22 +13,11 @@ import { parse } from './parser'; import { map } from './mapper'; import { unmap } from './unmapper'; -type ErrorRecord = { - error: Error, - unhandledRejection: boolean, - contextSize: number, - enhancedFrames: StackFrame[], -}; -type ErrorRecordReference = number; -const recorded: ErrorRecord[] = []; - -let errorsConsumed: ErrorRecordReference = 0; - -function consume( +function getStackFrames( error: Error, unhandledRejection: boolean = false, contextSize: number = 3 -): Promise<ErrorRecordReference | null> { +): Promise<StackFrame[] | null> { const parsedFrames = parse(error); let enhancedFramesPromise; if (error.__unmap_source) { @@ -49,32 +38,13 @@ function consume( ) { return null; } - enhancedFrames = enhancedFrames.filter( + return enhancedFrames.filter( ({ functionName }) => functionName == null || functionName.indexOf('__stack_frame_overlay_proxy_console__') === -1 ); - recorded[++errorsConsumed] = { - error, - unhandledRejection, - contextSize, - enhancedFrames, - }; - return errorsConsumed; }); } -function getErrorRecord(ref: ErrorRecordReference): ErrorRecord { - return recorded[ref]; -} - -function drain() { - // $FlowFixMe - const keys = Object.keys(recorded); - for (let index = 0; index < keys.length; ++index) { - delete recorded[keys[index]]; - } -} - -export { consume, getErrorRecord, drain }; -export type { ErrorRecordReference }; +export default getStackFrames; +export { getStackFrames }; diff --git a/packages/react-error-overlay/src/utils/isBultinErrorName.js b/packages/react-error-overlay/src/utils/isBultinErrorName.js new file mode 100644 index 000000000..cf732b838 --- /dev/null +++ b/packages/react-error-overlay/src/utils/isBultinErrorName.js @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + +/* @flow */ +function isBultinErrorName(errorName: ?string) { + switch (errorName) { + case 'EvalError': + case 'InternalError': + case 'RangeError': + case 'ReferenceError': + case 'SyntaxError': + case 'TypeError': + case 'URIError': + return true; + default: + return false; + } +} + +export { isBultinErrorName }; +export default isBultinErrorName; diff --git a/packages/react-error-overlay/src/utils/mapper.js b/packages/react-error-overlay/src/utils/mapper.js index fc3eb2266..656c216c1 100644 --- a/packages/react-error-overlay/src/utils/mapper.js +++ b/packages/react-error-overlay/src/utils/mapper.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -// @flow +/* @flow */ import StackFrame from './stack-frame'; import { getSourceMap } from './getSourceMap'; import { getLinesAround } from './getLinesAround'; diff --git a/packages/react-error-overlay/src/utils/parser.js b/packages/react-error-overlay/src/utils/parser.js index bfbb85f79..1cbee1d1c 100644 --- a/packages/react-error-overlay/src/utils/parser.js +++ b/packages/react-error-overlay/src/utils/parser.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -// @flow +/* @flow */ import StackFrame from './stack-frame'; const regexExtractLocation = /\(?(.+?)(?::(\d+))?(?::(\d+))?\)?$/; diff --git a/packages/react-error-overlay/src/utils/stack-frame.js b/packages/react-error-overlay/src/utils/stack-frame.js index ae28cb535..49f9da7fa 100644 --- a/packages/react-error-overlay/src/utils/stack-frame.js +++ b/packages/react-error-overlay/src/utils/stack-frame.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -//@flow +/* @flow */ /** A container holding a script line. */ class ScriptLine { @@ -54,6 +54,20 @@ class StackFrame { sourceColumnNumber: number | null = null, sourceScriptCode: ScriptLine[] | null = null ) { + if (functionName && functionName.indexOf('Object.') === 0) { + functionName = functionName.slice('Object.'.length); + } + if ( + // Chrome has a bug with inferring function.name: + // https://github.com/facebookincubator/create-react-app/issues/2097 + // Let's ignore a meaningless name we get for top-level modules. + functionName === 'friendlySyntaxErrorLabel' || + functionName === 'exports.__esModule' || + functionName === '<anonymous>' || + !functionName + ) { + functionName = null; + } this.functionName = functionName; this.fileName = fileName; @@ -72,8 +86,8 @@ class StackFrame { /** * Returns the name of this function. */ - getFunctionName(): string | null { - return this.functionName; + getFunctionName(): string { + return this.functionName || '(anonymous function)'; } /** @@ -98,11 +112,9 @@ class StackFrame { * Returns a pretty version of this stack frame. */ toString(): string { - const f = this.getFunctionName(); - if (f == null) { - return this.getSource(); - } - return `${f} (${this.getSource()})`; + const functionName = this.getFunctionName(); + const source = this.getSource(); + return `${functionName}${source ? ` (${source})` : ``}`; } } diff --git a/packages/react-error-overlay/src/utils/unmapper.js b/packages/react-error-overlay/src/utils/unmapper.js index b01736d74..60b2bee43 100644 --- a/packages/react-error-overlay/src/utils/unmapper.js +++ b/packages/react-error-overlay/src/utils/unmapper.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -// @flow +/* @flow */ import StackFrame from './stack-frame'; import { getSourceMap } from './getSourceMap'; import { getLinesAround } from './getLinesAround'; diff --git a/packages/react-error-overlay/src/utils/warnings.js b/packages/react-error-overlay/src/utils/warnings.js index 8dcd7e1ee..bcc54ceb7 100644 --- a/packages/react-error-overlay/src/utils/warnings.js +++ b/packages/react-error-overlay/src/utils/warnings.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. */ -// @flow +/* @flow */ import type { ReactFrame } from '../effects/proxyConsole'; function stripInlineStacktrace(message: string): string { diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index 1261de6be..a8f37e813 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -13,8 +13,9 @@ const spawn = require('react-dev-utils/crossSpawn'); const args = process.argv.slice(2); -const scriptIndex = args.findIndex(x => - x === 'build' || x === 'eject' || x === 'start' || x === 'test'); +const scriptIndex = args.findIndex( + x => x === 'build' || x === 'eject' || x === 'start' || x === 'test' +); const script = scriptIndex === -1 ? args[0] : args[scriptIndex]; const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []; diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index e9f985909..3ef1104a1 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -56,8 +56,6 @@ module.exports = { require.resolve('react-dev-utils/webpackHotDevClient'), // We ship a few polyfills by default: require.resolve('./polyfills'), - // Errors should be considered fatal in development - require.resolve('react-error-overlay'), // Finally, this is your app's code: paths.appIndexJs, // We include the app code last so that if there is a runtime error during diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index 2a351e668..9c3889aba 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -10,7 +10,7 @@ // @remove-on-eject-end 'use strict'; -const errorOverlayMiddleware = require('react-error-overlay/middleware'); +const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware'); const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware'); const config = require('./webpack.config.dev'); const paths = require('./paths'); diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index bf6c6be48..fa74ffa58 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -49,7 +49,6 @@ "postcss-loader": "2.0.6", "promise": "8.0.1", "react-dev-utils": "^3.1.0", - "react-error-overlay": "^1.0.10", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", From fbbc64fce2039fa799bff2a30298fadee0ab6b6e Mon Sep 17 00:00:00 2001 From: Christophe Hurpeau <christophe.hurpeau+github@gmail.com> Date: Mon, 28 Aug 2017 02:12:11 +0000 Subject: [PATCH 148/265] update babel-runtime dependency in react-error-overlay and react-scripts (#2991) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * update babel-runtime dependency in react-error-overlay and react-scripts `babel-runtime@6.23.0` have a dependency on `regenerator-runtime@0.10.5` `babel-runtime@6.26.0` on `regenerator-runtime@0.11.0` > npm ls regenerator-runtime ``` └─┬ react-scripts@1.0.11 ├─┬ babel-core@6.25.0 │ └─┬ babel-runtime@6.26.0 │ └── regenerator-runtime@0.11.0 ├─┬ babel-eslint@7.2.3 │ └─┬ babel-traverse@6.26.0 │ └─┬ babel-runtime@6.26.0 │ └── regenerator-runtime@0.11.0 ├─┬ babel-runtime@6.23.0 │ └── regenerator-runtime@0.10.5 └─┬ react-error-overlay@1.0.10 └─┬ babel-runtime@6.23.0 └── regenerator-runtime@0.10.5 ``` * fix requested changes --- packages/react-error-overlay/package.json | 2 +- packages/react-scripts/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 65c9b5efa..06c890a10 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -33,7 +33,7 @@ "dependencies": { "anser": "1.4.1", "babel-code-frame": "6.22.0", - "babel-runtime": "6.23.0", + "babel-runtime": "6.26.0", "html-entities": "1.2.1", "react": "^15.5.4", "react-dom": "^15.5.4", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index fa74ffa58..797fbc2d3 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -27,7 +27,7 @@ "babel-jest": "20.0.3", "babel-loader": "7.1.1", "babel-preset-react-app": "^3.0.2", - "babel-runtime": "6.23.0", + "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", "css-loader": "0.28.4", From 2cbb76018a32f4ed1846022118cb3297dd08d17b Mon Sep 17 00:00:00 2001 From: Sylvain Baronnet <sylvain@studio.gd> Date: Mon, 28 Aug 2017 04:17:21 +0200 Subject: [PATCH 149/265] Default Favicon lossless optimisation (#2917) --- .../react-scripts/template/public/favicon.ico | Bin 24838 -> 3870 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/packages/react-scripts/template/public/favicon.ico b/packages/react-scripts/template/public/favicon.ico index 5c125de5d897c1ff5692a656485b3216123dcd89..a11777cc471a4344702741ab1c8a588998b1311a 100644 GIT binary patch literal 3870 zcma);c{J4h9>;%nil|2-o+rCuEF-(I%-F}ijC~o(k~HKAkr0)!FCj~d>`RtpD?8b; zXOC1OD!V*IsqUwzbMF1)-gEDD=A573Z-&G7^LoAC9|WO7Xc0Cx1g^Zu0u_SjAPB<A z`RksU20=ur5rmib*S!+l%h4eS4)^Q+0X>3vGa^W|sj)80f#V0@M_CAZTIO(t--xg= z!sii`1giyH7EKL_+Wi0ab<)&E_0KD!3Rp2^HNB*K2@PHCs4PWSA32*-^7d{9nH2_E zmC{C*N*)(vEF1_aMamw2A{ZH5aIDqiabnFdJ|y0%aS|64E$`s2ccV~3lR!u<){eS` z#^Mx6o(iP1Ix%<jZ{9b!^*}EvPeMb_W#+3mPDk@<s^Oh#VM&a2^K;|820}`)peR}+ zJXt@j)V#7+Js?u;Lb#g$HH)e~Ro^hvl6KSLHq)Y3adj<OOD7?;gwee^gNzCxwD?IA z8?*}E@b*IiVPUPv3?XqzLRv|{4)GKGzjS`)#ukL7W&K6BHn&1}P(skc69cJ?5^C+V z@yyqLJg;V2Ul%gZ*?2WiB%bNfz1}F^UeTpW^N?dSY@NL3zDD+Tzk$Cg_=cj!M^ot0 zu%qYEoTU9K@kMP2H52_@<2On}lNX!oZ(oWk^?eSfXAa3M8S?8tzISV2V&9A+_-47Y z>4dv`t@!&Za-K@mTm#vadc{0aWDV*_%EiGK7qMC_(`exc>-$Gb9~W!w_^{*pYRm~G zBN{nA<l~YIv(*f3@JAyAZDXwp4d;meFk*lN;rx5VQze6aK!n?W9`Uc4pES2K&V3BC zkTJK{PcIXdQ?hM;i7~K{wRSeU-w9_32aC}+7nN6r5o<=I@CyjQAS~;jsb7p#@eUT2 zkh1M~1>;cm^w$VWg1O^^<6vY`1XCD|s_zv*g*5&V#wv&s#h$xlUilPe4U@I&UXZbL z0)%9Uj&@yd03n;!7do+bfixH^FeZ-Ema}s;DQX2gY+7g0s(9;`8GyvPY1*vxiF&|w z>!vA~GA<~JUqH}d;DfBSi^IT*#lrzXl$fNpq0_T1tA+`A$1?(gLb?e#0>UELvljtQ zK+*74m0jn&)5yk8mLBv;=@}c{t0ztT<<S2g5CX`xuBQVwYJOMIsv7paOX6ypYJL$a zJ|Vy}#?V4i+kjXzBq)LcuJEA=z^Z2W4WQ1U@0}*!;_q<!3_ls8PhMM3ii*Ci+cF6= zF!@E<x#%Yvb!P0>v;Avck$S6D`Z)^c0(jiwKhQsn|LDRY&w(Fmi91I7H6S;b0XM{e zXp0~(T@k_r-!jkLwd1_Vre^v$G4|kh4}=Gi?$AaJ)3I+^m|Zyj#*?Kp@w(lQdJZf4 z#|IJW5z+S^e9@(6hW6N~{pj8|NO*>1)E=%?nNUAkmv~OY&ZV<PHdt%yO<W_%O|c-T zC%nAvgv?#h>;m-%?pQ_11)hAr0oAwILrlsGawpxx4D43J&K=n+p3WLnlDsQ$b(9+4 z?mO^hmV^F8MV{4<aA#E-8o{y-by8hR1>Lx>(Q=aHhQ1){0d*(e&s%G=i5rq3;t{JC zmgbn5Nkl)t@fPH$v;af26lyhH!k+#}_&aBK4baYPbZy$5aFx4}ka<ge$nBI}>&qxl z$=Rh$W;U)>-=S-0=?7FH9dUAd2(q#4TCAHky!$^~;Dz^j|8_wuKc*YzfdA<NJp8x7 z`_}_7!m44CG`<6nLk0r3A}8e>ht@Q&ror?91Dm!N03=4=O!a)I*0q~p0g$Fm$pmr$ zb;wD;STDIi$@M%y1>p&_>%?UP($15gou_ue1u0!4(%81;qcIW8NyxFEvXpiJ|H4wz z*mFT(qVx1FKufG11hByuX%lPk4t#WZ{>8ka2efjY`~;AL6vWyQKpJun2nRiZYDij$ zP>4jQXPaP$UC$yIVgGa)jDV;F0l^n(V=HMRB5)20V7&r$<L^Phf(W29K>jmk{UUIe zVjKroK}JAbD>B`2cwNQ&GDLx8{pg`7hbA~grk|W6LgiZ`8y`{Iq0i>t!3p2}MS6S+ zO_ruKyAElt)rdS>CtF7j{&6rP-#c=7evGMt7B6`7HG|-(WL`bDUAjyn+k$mx$C<FS ztTQ#rrhaxTX7@2TN#`pson<p6thk-4?N)^;_(Up!_V=f}<~kR)zD%o0iiqseIMZqh zGU`kZGbN)qs{;AuZP?~%PajDo&b&7)!V!+|VO<ediN}{)OvR~sQ<ZYe%O|)8-DTKw zTXmYP$VLa(Y>H;q2Dz4x;cPP$hW=`pFfLO)!jaCL@V2+F)So3}vg|%O*^T1j>C2lx zsURO-zIJC$^$g2byVbRIo^w>UxK}74^TqUiRR#7s_X$e)$6iYG1(PcW7un-va-S&u zHk9-6Zn&>T==A)lM^D~bk{&rFzCi35>UR!ZjQkdSiNX*-;l4z9j*7|q`TBl~Au`5& z+c)*8?#-tgUR$Zd%Q3bs96w6k7q@#tUn`5rj+r@_sAVVLqco|6O{ILX&U-&-cbVa3 zY?ngHR@%l{;`ri%H*0EhBWrGjv!LE4db?HEWb5mu*t@{kv|XwK8?npOshmzf=vZA@ zVSN9sL~!sn?r(AK)Q7Jk2(|M67Uy3I{eRy<vjA)m;~)jV3DFGzL)eNbs@Sy80roD> z_l&Y@A>;vjkWN5I2xvFFTLX0i+`{qz7C_@bo`ZUzDugfq4+>a3?1v%)O+YTd6@Ul7 zAfLfm=nhZ`)P~&v90$&UcF+yXm9sq!qCx3^9gzIcO|Y(js^Fj)Rvq>nQAHI92ap=P z10A4@prk+<s7nQxb0&o?puD0BStB$NLIA{pVg<pW;2=HJ11ZpVkRkF89w0s#3ef?( zka>AGWCb`2)dQYFuR$|H6iDE8p}9a?#nV2}LBCoCf(Xi2@szia7#gY>b|l!-U`c}@ zLdhvQjc!BdLJvYvzzzngnw51yRYCqh4}$oRCy-z|v3Hc*d|?^Wj=l~18*E~*cR_kU z{XsxM1i{V*4GujHQ3DBpl2w4FgFR48Nma@HPgnyKoIEY-MqmMeY=I<%oG~l!f<+FN z1ZY^;10j4M4<Vo=b&OyEfF!Y);yDCJas8bbVhK~blk}<IGME~h)6n~gdmqP>#HYXP zw5eJpA_y(>uLQ~OucgxDLuf}fVs272FaMxhn4xnDGIyLXnw>Xsd^J8XhcWIwIoQ9} z%FoSJTAGW(SRGwJwb=@pY7r$uQRK3Zd~XbxU)ts!4XsJrCycrWSI?e!IqwqIR8+Jh zlRjZ`UO1I!BtJR_2~7AbkbSm%XQqxEPkz6BTGWx8e}nQ=w7bZ|eVP4?*Tb!$(R)iC z9)&%bS*u(lXqzitAN)Oo=&Ytn>%Hzjc<5liuPi>zC_nw;Z0AE3Y$Jao_Q90R-gl~5 z_xAb2J%eArrC1CN4G$}-zVvCqF1;H;abAu6G*+PDHSYFx@Tdbfox*uEd3}BUyYY-l zTfEsOqsi#f9^FoLO;ChK<554qkri&Av~SIM*{fEYRE?vH7pTAOmu2pz3X?Wn*!ROX ztd54huAk&mFBemMooL33RV-*1f0Q3_(7hl$<#*|WF9P!;r;4_+X~k~uKEqdzZ$5Al zV63X<s4EnR@itBNL^suG_KHV!zgrw6&Bq&`dNv>N<k2!6lBSoSAvQBw$a}{Sg*d5f zJqeF6lxH}v-(s5jl(8V8Bv*((#aw(*iLTd8#?8FnMLG#}AorDTkK*%$ni#S{e-*jA zjy$_xALPmR?$A)F?XdsKy|!Ue+lIR5=csS!ZPu7h{Nc+Sd%?*WHR`S5ByDdhQAsNO zeyx0!D+fx-a_t<57fQ^<7*WTVDog0}WA0F2_h++_I?f`i|C>@)j$FN#cCD;ek1R#l zv%pGrhB~KWgoCj%GT?%{@@o(AJGt*PG#l3i>lhmb_twKH^EYvacVY-6bsCl5*^~L0 zonm@lk2UvvTKr2RS%}T>^~EYqdL1q4nD%0n&Xqr^cK^`J5W;lRRB^R-O<zOhVxo?8 zb#fjP=~|*nH<rZsU&F20QcP*BR|)$r#sFFtYi6hV=2&f<YJ%JC0IAdIRdHjO(;S%3 zC;L{EqcHO368@u|<ql>8b&HENO||mo0xaD+S=I8RTlIfVgqN@SXDr2&-)we--K7w= zJVU8?Z+7k9dy;s;^gDkQa`0nz6N{T?(A&Iz)2!DEecLyRa&FI!id#5Z7B*O2=PsR0 zEvc|8{NS^)!d)MDX(97Xw}m&kEO@5jqRaDZ!+%`wYOI<23q|&js`&o4xvjP7D_xv@ z5hEwpsp{HezI9!~6O{~)lLR@oF7?J7i>1|5a~UuoN=q&6N}EJPV_GD`&M*v8Y`^2j zKII*d_@Fi$+i*YEW+Hbz<W=zs^XxM$!;??OHDS{MUEdOi9{rF;;#a0RO>n{iQk~yP z>7N{S4)r*!NwQ`(qcN#8SRQsNK6>{)X12nbF`*7#ecO7I)Q$uZsV+xS4E7aUn+U(K baj7?x%VD!5Cxk2YbYLNVeiXvvpMCWYo=by@ literal 24838 zcmeI4X^>UL6@VY56)S&I{`6Nu0RscWCdj@GJHx(%?6_-;yKy1n;EEf9f}pr1CW5HA zYt$%U#C=}?jWH&%G@BaHBxsWAoUb3}&6%Ei@4Ii_JRa1`RQ23*yU)_wJ$?H0>6gj0 z${d_I^w5kvTW3x<IFlKb$z%>YEc?FvyP3>p$!py@`@T`|dVepIsjbbvR}af%KKy<r zQ!O-7BpkB&^2i9=CVy?(v>7YuQ%SDC^zmNWPYR^7avI5P-@dKev}UZ^aDAOyci9Nn zwR4qEz~tSvrp|#ACvWzo9`3B;`}^{t18dxaH;?xT7#hmJiKAaI;|O=$yxzXNOHGw~ z^!5pE^SW`av%t_$22LFPsM^l%=PSp!3r`>9w%s+^ZQYnnTQ*Ggd9-1~kj_o$YdW@b ztCkJ(ZGYjusqV5L4{^)R9Gt@gzU1t|?xhE&c^q(|(R#oa*}Sj5c({A$mhrB8*Y@tc zr)K#C{KOp-eHl35ZWJ1&zkmI>9DL%!KJE@_!<b=R+`r#n>=W?aH;i?ZDb0O1HPFy6 zcV0Kf)eZ0BHm<I7>z9vowF7EA{z*aue9M)iJP&Zd)qYlfJ-c^sS1qY^?>s)!!Ta@x zr@Lz|80r)7<{QVk9Z$}5SDaVtz*Rc?oH5~Wcjoc^eA&EdJ^h@aZ-BvL{K2s_7Cvfr zFL&(R?D&(9OxsS%z_BzI9^Ai^AOF$PUpGk~oO(=OpMc3@Zh&KH1a9>G%%0rC)t@oQ z4d~M`hX+g^Wf8P>A&&qjq|tZe*44Laq7qVPK#QIc)s*Qj34P`NL`Q{xBI`SnR!RC? zlGdTvC%oVZ@0BgcH>}qc!uzul@{i@sH}L0|=eZBJ9qF!HHaw?`s0(_DJj(v`(memI z6jH}=BfGlS<lCz5(9Y}G6-$SDeZe<M+V!hhjy&`*IN(B)R>lRV4)ouv#h*65yRR>G zo;I#~BVK&l&{+H=_~Nq$d%bFLh7GE5pS&>Fr{RMe>)MM19~z6F1oQo_y>vtlpEZF# zIc82TpMc3z9;{Q)=zG5B#4+96yHCvYy8p4;C%6x`%y$2HccC9|#vGVD)**C0xX|R| z%h)}ze!Tnrvvb@RZ!GX@2lMEq`=`08b`9$%FnN@*zJLo2wD5?MbE&LN)Z>Kty*;m= zt{Cn0>Q3nk)`<?XKA&^a0H1)#qYT{(E;6A-&$G^18FQ!hbgw)(&2_47Slh<SeEagv z1zwkfi$2$N30U*M0ay8T6dv$`r{-OD&Jed;=9s?oY}dAp`^ziy+~Qf;b^SNe-^w2t z9LoMGIN(}Zc-b}#mAUu+)3b7GF}TbX=E<)&P4Tq!pYjI=hcfyIT;)Gf)@XRC?V|at zU(AVHuNvjo6xRCr(|dYbL)R{7Nh*KKhDl<#^z?QC;{h#gi(3onyYo*T;9eA4gt}r! zVK4mgxjCK>bR^{dVf!3ECg6Yz4YcskI>$XH*L8E)MsudhnkP0B>+M(XEcErHUBKi~ z1`fEP&WPhp{@Ew?cPlR(ma9iw8NbJWHqp=btCtM*FnP*@ZwwlJ&-Y|LEjgvJzUtPc zz5CrWNBRV8d0-bpWAl<=zM1PU8lJ<auFSVLADiJ5u&qD1&?ND+W&L_}^tzZnT_kh- z*}JFsu|}tn7*p~nn>seDxBK^QuuCj2fg{&2#*IG5ezf1B(o%lU+OZx7So4D?yi2*h zFBkr5pG3AJs83uy!~C3mQZLp~ss7-N9oAY>t)!eC#s)CrPukK!(!G*)H?v(~JCoj# zfvgTxMV{4?zL1neQ;ITVBAdFDf`1yG$o{g7^1sR_n{RZ7tnXio?tM%240}(z9xFY0 zlz{^-G*RET;-`7`>e0b{{`!2kM)t7Si9ZqD$~wh*hyGC>z~qs@0T&u*;h}hiKGEga zHkJ;%7aNc^o_0(>Z{Gp06<d!oiwkYI9@z4HFzfO!R*h-IQ)!TmJxBu9eEVd72@jiB z2+SIP`!%B@>9H;TwPTUnvvX0SJ+kGGZ0lFBWocl>kaa)AoiMta+x_-J-?#KHFnJ*! zwD1V?)4s#|?O)DlMBhVv4IgZs?d>b<6%xK3<{o91H?-%8?PK!_fm#3d>{{gQ<X0b> z?*8`b{G6?bZKdO{_9IVlz{R$PcGjeL|3*|@upby()_Lf^eQ&XQe)CjsbJ3Uolrgt< zweld3GH|fZpn(=1@PencO_a_)v6tU?WV-w8wfXLbOGae<M=}TTxv_VkkFEV<X@MyN z2V7{Fd+b}_1y6V*Bc$V<eH8m0Xsn%ve~-Ncd(n@dpOe#l=sI|Q`r=&2J`x`2Kya=+ zzt+=O-yl5kg&`x#=ZBrln1yv?kHLJSFLf?4rgqGMXHLwH^SM79;Blb|_b2e?d&Z|2 z%0Y)skMV`6zEc~Xy<sSyJa~eGoo@HZRu=U{mdyihsrJ)H^i^E@>0{<*C?Ead$6v+> z|EQKThJTmwXK!c6AOD+<KQQ<@{@^la?D)eoY5bwjH~(4t^38v6nlt~kz2*G=wGR5k zez5wFeYu@?QTh*@V)UQN=9#4b(fO+XpV^ev|A%*Lm^aWDtN+Wr{-FzRyE@u_*ca=6 z8v94>FgtDv7i<48{-OPce!KDVkzR+XKOcREPha(;$}iUb!*)f-Fb}Y4@r9z-_{OIg z`xn^T#ZtEPv_T$M*Sr+=Z{q#~8$|7Y{0!*2u${D*Jj%dfOrS~FzpH*_|55J!7kl4w z?LT!7T(!3!632pmZh?dh`n-z$_ts42pn6;c`}hx;TSYd0idsqal5&0uGV=UM{c9xQ z1KK6&TS+a^H|6B<wY1?KNwleRT=S(2ztn0;|CLnE`j%2QZCfX)(aE8_)AlDNl~VTp z#QQ1QtaCx&H5Jr$9fvivU)tSS(tj$j{j{03Ut57~*ExVr+*!fxXI=QFg4>_hPo1W3 zh+Dun!`UkP%H3}*@IE18q{7&MH2f3?T6o}Jf+xI@fh=SyUOArw`*w1_-PUlHZTHc@ z--yqIxPtI}IjPRzLIZ8cPv4P=>?A&=E~~0)>&J#V;TwAR*6}`01iu~U$@prtzW6YS ze}E>gUX+0YuF}B+Uhw2x7a7Q+oOzMNFHTNN<)40Rzg#`pABKF18@l}5A>RL`?Ri;Z zC8ExD$)im1@R{N7(wIog8$Yn(6%q$yd9(zKe};OnH%;<E6IVx!rq-Dls&Jo8o|c0< zuy5@7x0i)X@To&fw53oU#K*E9rw;0;PU1oT;M+!rL4$AO=p(c7O~B+)22N66stja8 zLmiT0brrv*pZHXfPf{Ow8X2@%^#b3ye(U5>mWBs7)>ls~T3Wi6!Xqw6+dpJLVS1P| z9qV%io-nE*rYcPxiS<?aaq&fI_%s)XSYMT&^sPqm$A6{c4iDfIKCMP$j7*hZC~Z`o z3eB_QUx<xEycp-_)Sah=HMTrWU685mFUR=P4wY|pc~adutHaL<osPMk3zXS2!X#eA zQmK56!Art#=`!NBRQ}0}8{+lj<e<}^zH?HJ#;)7I$_tz{`u|6Z8)$57Y@Ga3<m;M! z?b2b5zRf6E_G}ZMeu#tbU;9AgHA5Wxj!f{WgU#QUu-Y`l-Nnh}4h83xs_!^=pf9is zZ6c2{+5|2%arZBfg-mccFN>31>U_>mbPTXxkC*!?*zefr#2vF|qr8{|4|u^7-pD|f z&OPc->UKu)=iHgIpysp<ozGa?r0YPT{HTLHSC6V|OXXo_ayN;&#~E={T{+X=e(w~2 zw~0Nh;&4Wvrk?&hU(QFB4j$Z-f+xH+-#)1eb)s&iu!V^~AfA{w1uGX=?Rm}#S-&+l zgncRJ)Zh@ylBVrCPT)cVEj)CO3vXl~%gP4UL>;Lsbyj}GJWoBkufOA={CRTUjr%af zc5pUH9{pg?M5%+)oN`q9yBb<oyS@>Bt@+3xHV)qGm8b)Cp-w7~CwEhtBUk0rbjrqM zTb|tQ3-5-pw^cul`T+X&s?O;?V(FD<p-*U$j}C+<^vEC&nfC4)HUsx3hzYZGCbpcm z6e64X$6Y|>!(Q9Qg@(LTCNz{0-vBM^SX5lti3|GpxFn4;Ax6pGc~t)R!Bo${lYH(* z!F&5X*?S&}YoDCyzwv1H+XI(+rL`;RN9}iLxlfr-r&vGG8OQa@=>+a)+Ij)sd_{wu z1Am(+3-RFr4&N8N6+hqo19S#;SA1-hG<GH5jM5~<MA>>07p3}&*j4CR+rqdV)^6n; z_vFr!<qZ$Di!AT7`VHNnve0FgcNDC1nRsh^hbs!#=B-+mwMSJJ_g-u{F!6C(9`}rj zp@WyjXIw+xaqqN&wm`3UqvCMM*H~D5k4bo8S)U`Sb2ctKqWtsfFSBh4VQ@m;@X~sr z`v>(a%-=#=kb{pY<Q=}Noc+1|5qFyt+f_*W)u&sj^WW+}&Yr^g5%rG#;~pt<%<8C6 z|8W;TobTZ~I?~E0R{zlkm666CYO?;xU4uf_KXk0x#D%VZQTTTKvty&bKVbXH!qmAr z>mNL@6|DWkw~%E2V2jYl*e1}c{e$fib?(O+hs}eoBLRo&9(<zgA7XHk#X4o%Yhmmk z)%oBSV*e<g{mK4CZ|_U{SNnixv-dx;XDQ^nvoeA0T(|zPeYO9w^}*Jn4%|!DHtAEp zb?%3Z9@-^mGnHchi!Fl;WFcQ=Yh8F!N9vl^KD6!32cuK+`9GMe&)qxK-!FUQwr2W2 z#8;wi!vDctHF&~X^X;?L{*S1BVUJj8{;#kftpAfc-q!z#-zILn?AYal;Q=q}|3p@~ z{h#zj8vi$U_xSw+>;J}YV}0Mi<mo;y>;LZA<ldj{|NX)Ltz*y<=O3Jj=v>e{U$(s= zT<-IaV$Z+q-P!~3{HxN>Kbw30jXzM&I(S<6Ksx^}HvU2Vntb!<yFz0a_NVv<Vo^f< zl=P0zzDfLx<R#IBWyIX5zAQ)l1A8--U&vi>etSsm0>)j}Me^+L5{2yz--)?W`Q?az z!WLG4UNP}+#C+NKH+ZG-Q<ppbjq%{@oiSjqt>=E>IPp%LuKLx$$8NAOGr(#~P>!EA zDYlpXDR=xM?Xv5(-qp74Cw3LzBeASHSBY`OezkbO<VD55M#Z-5FY&MJafv~uZ8rWH z`;FiF)bE^fzVqhBKl3|r@GMdMb5Zvn(!{^B503JKg>yjP!G%WSymju_C$VBl--z<c z^Q7%X-+y6_@;es({)3!PFz);&9_MF;#0G|Sg%%$0f+uGm$Us)qcM;O3c&F`^eE*5I zbKkX6@4waTy#rW@_a9fA`=1qk|8?&isM!0@IuG{tLnqM(D<q*C_eg4Ds~li?v|)!N z+SJLm6?jiJ;|CvQpNDMCKKbne{#w=h$G-m^gRI#9|8H&&)Mp8E<F_^Ye$YqR=OH@o F{{x|jBbfjI From cc2e270d0eb9e1703e6df1a92aa57f1acfb809ae Mon Sep 17 00:00:00 2001 From: Dan Abramov <gaearon@fb.com> Date: Sun, 27 Aug 2017 19:20:54 -0700 Subject: [PATCH 150/265] Relax React dep requirements --- packages/react-error-overlay/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 06c890a10..8034897d9 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -35,8 +35,8 @@ "babel-code-frame": "6.22.0", "babel-runtime": "6.26.0", "html-entities": "1.2.1", - "react": "^15.5.4", - "react-dom": "^15.5.4", + "react": "^15 || ^16", + "react-dom": "^15 || ^16", "settle-promise": "1.0.0", "source-map": "0.5.6" }, From 9a072e2bb517edd57480b9c97cf5ff4beb5d126f Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sun, 27 Aug 2017 20:25:03 -0600 Subject: [PATCH 151/265] Changelog for 1.0.12 (#3016) --- CHANGELOG.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b82304032..62f877da1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,68 @@ -## 1.0.11 (2017-08-09) +## 1.0.12 (August 28, 2017) + +#### :bug: Bug Fix + +* `react-error-overlay` + * [#3012](https://github.com/facebookincubator/create-react-app/pull/3012) Fix module function name in error overlay. ([@gaearon](https://github.com/gaearon)) + +* `react-dev-utils` + * [#2938](https://github.com/facebookincubator/create-react-app/pull/2938) Remove superfluous lodash usage. ([@Timer](https://github.com/Timer)) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#2917](https://github.com/facebookincubator/create-react-app/pull/2917) Optimize the size of default favicon. ([@sylvainbaronnet](https://github.com/sylvainbaronnet)) + +#### :memo: Documentation + +* `react-scripts` + + * [#2986](https://github.com/facebookincubator/create-react-app/pull/2986) Docs: debugging in WebStorm. ([@prigara](https://github.com/prigara)) + * [#2948](https://github.com/facebookincubator/create-react-app/pull/2948) Remove Modulus from user guide. ([@Zertz](https://github.com/Zertz)) + * [#2927](https://github.com/facebookincubator/create-react-app/pull/2927) Update README.md. ([@tbassetto](https://github.com/tbassetto)) + +* `react-dev-utils` + + * [#2942](https://github.com/facebookincubator/create-react-app/pull/2942) Fix docs for `printFileSizesAfterBuild`. ([@Kerumen](https://github.com/Kerumen)) + +#### :house: Internal + +* `react-error-overlay`, `react-scripts` + + * [#2991](https://github.com/facebookincubator/create-react-app/pull/2991) Update `babel-runtime` dependency ([@christophehurpeau](https://github.com/christophehurpeau)) + +* `react-dev-utils`, `react-error-overlay`, `react-scripts` + + * [#2515](https://github.com/facebookincubator/create-react-app/pull/2515) Convert `react-error-overlay` to React ([@tharakawj](https://github.com/tharakawj)) + +#### Committers: 9 + +- Christophe Hurpeau ([christophehurpeau](https://github.com/christophehurpeau)) +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Ekaterina Prigara ([prigara](https://github.com/prigara)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Pier-Luc Gendreau ([Zertz](https://github.com/Zertz)) +- Sylvain Baronnet ([sylvainbaronnet](https://github.com/sylvainbaronnet)) +- Tharaka Wijebandara ([tharakawj](https://github.com/tharakawj)) +- Thomas Bassetto ([tbassetto](https://github.com/tbassetto)) +- Yann Pringault ([Kerumen](https://github.com/Kerumen)) + +### Migrating from 1.0.11 to 1.0.12 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.12 +``` + +or + +``` +yarn add --exact react-scripts@1.0.12 +``` + +## 1.0.11 (August 9, 2017) #### :bug: Bug Fix * `create-react-app` From a51be9582a53700aae1eb7e81dc66d33e80dad88 Mon Sep 17 00:00:00 2001 From: Dan Abramov <gaearon@fb.com> Date: Sun, 27 Aug 2017 19:26:52 -0700 Subject: [PATCH 152/265] Publish - react-dev-utils@4.0.0 - react-error-overlay@2.0.0 - react-scripts@1.0.12 --- packages/react-dev-utils/package.json | 4 ++-- packages/react-error-overlay/package.json | 2 +- packages/react-scripts/package.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index ccc22bf63..d2f87f51c 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "3.1.1", + "version": "4.0.0", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -47,7 +47,7 @@ "inquirer": "3.2.1", "is-root": "1.0.0", "opn": "5.1.0", - "react-error-overlay": "^1.0.9", + "react-error-overlay": "^2.0.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 8034897d9..ba4676c4a 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "1.0.10", + "version": "2.0.0", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 797fbc2d3..ff19eb347 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.11", + "version": "1.0.12", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -48,7 +48,7 @@ "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", - "react-dev-utils": "^3.1.0", + "react-dev-utils": "^4.0.0", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", From 1df16109c96a4aa27745ce93411a8cc67ae42321 Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara <tharaka.nw@gmail.com> Date: Sat, 2 Sep 2017 01:24:58 +0530 Subject: [PATCH 153/265] Fix error overlay 'Object.assign' issue in IE by including polyfills before webpack client (#3046) --- packages/react-scripts/config/webpack.config.dev.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 3ef1104a1..90d6a6413 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -43,6 +43,8 @@ module.exports = { // 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 @@ -54,8 +56,6 @@ module.exports = { // require.resolve('webpack-dev-server/client') + '?/', // require.resolve('webpack/hot/dev-server'), require.resolve('react-dev-utils/webpackHotDevClient'), - // We ship a few polyfills by default: - require.resolve('./polyfills'), // Finally, this is your app's code: paths.appIndexJs, // We include the app code last so that if there is a runtime error during From 270b1dc5cd2dc324de4f5f45145e679548fd5080 Mon Sep 17 00:00:00 2001 From: "Erik J. Sturcke" <esturcke@users.noreply.github.com> Date: Fri, 1 Sep 2017 15:56:17 -0400 Subject: [PATCH 154/265] Strip hash from chunk file name (#3049) --- packages/react-dev-utils/FileSizeReporter.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js index ab9a27287..f25e47378 100644 --- a/packages/react-dev-utils/FileSizeReporter.js +++ b/packages/react-dev-utils/FileSizeReporter.js @@ -92,7 +92,10 @@ function printFileSizesAfterBuild( function removeFileNameHash(buildFolder, fileName) { return fileName .replace(buildFolder, '') - .replace(/\/?(.*)(\.\w+)(\.js|\.css)/, (match, p1, p2, p3) => p1 + p3); + .replace( + /\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, + (match, p1, p2, p3, p4) => p1 + p4 + ); } // Input: 1024, 2048 From 51d0df490295b70808b61d780a54ebcf296a8db2 Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara <tharaka.nw@gmail.com> Date: Sat, 2 Sep 2017 06:29:37 +0530 Subject: [PATCH 155/265] Rename Overlay to ErrorOvelay (#3051) --- .../src/components/{Overlay.js => ErrorOverlay.js} | 4 ++-- .../src/containers/CompileErrorContainer.js | 6 +++--- .../src/containers/RuntimeErrorContainer.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) rename packages/react-error-overlay/src/components/{Overlay.js => ErrorOverlay.js} (96%) diff --git a/packages/react-error-overlay/src/components/Overlay.js b/packages/react-error-overlay/src/components/ErrorOverlay.js similarity index 96% rename from packages/react-error-overlay/src/components/Overlay.js rename to packages/react-error-overlay/src/components/ErrorOverlay.js index 4fe530b6f..446105dad 100644 --- a/packages/react-error-overlay/src/components/Overlay.js +++ b/packages/react-error-overlay/src/components/ErrorOverlay.js @@ -31,7 +31,7 @@ const overlayStyle = { color: black, }; -class Overlay extends Component { +class ErrorOverlay extends Component { iframeWindow: window = null; getIframeWindow = (element: HTMLDivElement) => { @@ -71,4 +71,4 @@ class Overlay extends Component { } } -export default Overlay; +export default ErrorOverlay; diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js index bd193eb50..a3e89fe59 100644 --- a/packages/react-error-overlay/src/containers/CompileErrorContainer.js +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -9,7 +9,7 @@ /* @flow */ import React, { PureComponent } from 'react'; -import Overlay from '../components/Overlay'; +import ErrorOverlay from '../components/ErrorOverlay'; import Footer from '../components/Footer'; import Header from '../components/Header'; import CodeBlock from '../components/CodeBlock'; @@ -19,11 +19,11 @@ class CompileErrorContainer extends PureComponent { render() { const { error } = this.props; return ( - <Overlay> + <ErrorOverlay> <Header headerText="Failed to compile" /> <CodeBlock main={true} codeHTML={generateAnsiHTML(error)} /> <Footer line1="This error occurred during the build time and cannot be dismissed." /> - </Overlay> + </ErrorOverlay> ); } } diff --git a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js index c84adb194..9c41aa381 100644 --- a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js +++ b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js @@ -9,7 +9,7 @@ /* @flow */ import React, { PureComponent } from 'react'; -import Overlay from '../components/Overlay'; +import ErrorOverlay from '../components/ErrorOverlay'; import CloseButton from '../components/CloseButton'; import NavigationBar from '../components/NavigationBar'; import RuntimeError from './RuntimeError'; @@ -52,7 +52,7 @@ class RuntimeErrorContainer extends PureComponent { const { errorRecords, close } = this.props; const totalErrors = errorRecords.length; return ( - <Overlay shortcutHandler={this.shortcutHandler}> + <ErrorOverlay shortcutHandler={this.shortcutHandler}> <CloseButton close={close} /> {totalErrors > 1 && <NavigationBar @@ -69,7 +69,7 @@ class RuntimeErrorContainer extends PureComponent { line1="This screen is visible only in development. It will not appear if the app crashes in production." line2="Open your browser’s developer console to further inspect this error." /> - </Overlay> + </ErrorOverlay> ); } } From 6644054fc3f64533dd1b9469baa2fab94e44b721 Mon Sep 17 00:00:00 2001 From: Anthony <anthony.alayo@gmail.com> Date: Sat, 2 Sep 2017 13:41:40 -0700 Subject: [PATCH 156/265] provide empty mock for child_process so importing libraries with it works (#3033) --- packages/react-scripts/config/webpack.config.dev.js | 1 + packages/react-scripts/config/webpack.config.prod.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 90d6a6413..3ac7395e6 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -280,6 +280,7 @@ module.exports = { fs: 'empty', net: 'empty', tls: 'empty', + child_process: 'empty', }, // Turn off performance hints during development because we don't do any // splitting or minification in interest of speed. These warnings become diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 449643461..d80351ec6 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -358,5 +358,6 @@ module.exports = { fs: 'empty', net: 'empty', tls: 'empty', + child_process: 'empty', }, }; From 8a72a314bcdfbf6357029ea79d9ea3b4e8c63da5 Mon Sep 17 00:00:00 2001 From: Jared Palmer <jaredloganpalmer@gmail.com> Date: Sat, 2 Sep 2017 16:42:04 -0400 Subject: [PATCH 157/265] Make error overlay filename configurable (#3028) * Make error overlay file configurable * Add fallback filename --- packages/react-dev-utils/webpackHotDevClient.js | 1 + packages/react-error-overlay/src/index.js | 3 ++- packages/react-error-overlay/src/listenToRuntimeErrors.js | 7 +++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index b6effe718..96a150632 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -33,6 +33,7 @@ ErrorOverlay.startReportingRuntimeErrors({ module.hot.decline(); } }, + filename: 'static/js/bundle.js', }); if (module.hot && typeof module.hot.dispose === 'function') { diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index ff4f1c714..168baa7ef 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -21,6 +21,7 @@ import type { ErrorRecord } from './listenToRuntimeErrors'; type RuntimeReportingOptions = {| onError: () => void, launchEditorEndpoint: string, + filename?: string, |}; let iframe: null | HTMLIFrameElement = null; @@ -55,7 +56,7 @@ export function startReportingRuntimeErrors(options: RuntimeReportingOptions) { } finally { handleRuntimeError(errorRecord); } - }); + }, options.filename); } function handleRuntimeError(errorRecord) { diff --git a/packages/react-error-overlay/src/listenToRuntimeErrors.js b/packages/react-error-overlay/src/listenToRuntimeErrors.js index 45c43fa5d..341200afa 100644 --- a/packages/react-error-overlay/src/listenToRuntimeErrors.js +++ b/packages/react-error-overlay/src/listenToRuntimeErrors.js @@ -39,7 +39,10 @@ export type ErrorRecord = {| stackFrames: StackFrame[], |}; -export function listenToRuntimeErrors(crash: ErrorRecord => void) { +export function listenToRuntimeErrors( + crash: ErrorRecord => void, + filename: string = '/static/js/bundle.js' +) { function crashWithFrames(error: Error, unhandledRejection = false) { getStackFrames(error, unhandledRejection, CONTEXT_SIZE) .then(stackFrames => { @@ -68,7 +71,7 @@ export function listenToRuntimeErrors(crash: ErrorRecord => void) { { message: data.message, stack: data.stack, - __unmap_source: '/static/js/bundle.js', + __unmap_source: filename, }, false ); From f65a1a90a7758b6a570b05925f52cfe87d9ff20a Mon Sep 17 00:00:00 2001 From: Dan Abramov <gaearon@fb.com> Date: Sat, 2 Sep 2017 13:54:33 -0700 Subject: [PATCH 158/265] Add missing slash --- packages/react-dev-utils/webpackHotDevClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 96a150632..18a6a4a0a 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -33,7 +33,7 @@ ErrorOverlay.startReportingRuntimeErrors({ module.hot.decline(); } }, - filename: 'static/js/bundle.js', + filename: '/static/js/bundle.js', }); if (module.hot && typeof module.hot.dispose === 'function') { From efeabee92b6a76681c8af97ca5a5af701b77adee Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sat, 2 Sep 2017 13:57:52 -0700 Subject: [PATCH 159/265] Changelog for 1.0.13 --- CHANGELOG.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62f877da1..3a77c54b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,52 @@ +## 1.0.13 (September 2, 2017) + +#### :bug: Bug Fix + +* `react-error-overlay` + + * [#3051](https://github.com/facebookincubator/create-react-app/pull/3051) Fix case-sensitivity issue with upgrading the package version. ([@tharakawj](https://github.com/tharakawj)) + +* `react-dev-utils` + + * [#3049](https://github.com/facebookincubator/create-react-app/pull/3049) Print filesize difference for chunks. ([@esturcke](https://github.com/esturcke)) + +* `react-scripts` + + * [#3046](https://github.com/facebookincubator/create-react-app/pull/3046) Fix crash in development mode on IE11. ([@tharakawj](https://github.com/tharakawj)) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#3033](https://github.com/facebookincubator/create-react-app/pull/3033) Add an empty mock for `child_process` to let some libraries compile. ([@McFlurriez](https://github.com/McFlurriez)) + +#### :house: Internal + +* `react-dev-utils`, `react-error-overlay` + + * [#3028](https://github.com/facebookincubator/create-react-app/pull/3028) Make error overlay filename configurable. ([@jaredpalmer](https://github.com/jaredpalmer)) + +#### Committers: 4 + +- Anthony ([McFlurriez](https://github.com/McFlurriez)) +- Erik J. Sturcke ([esturcke](https://github.com/esturcke)) +- Jared Palmer ([jaredpalmer](https://github.com/jaredpalmer)) +- Tharaka Wijebandara ([tharakawj](https://github.com/tharakawj)) + +### Migrating from 1.0.12 to 1.0.13 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.13 +``` + +or + +``` +yarn add --exact react-scripts@1.0.13 +``` + ## 1.0.12 (August 28, 2017) #### :bug: Bug Fix @@ -62,6 +111,8 @@ or yarn add --exact react-scripts@1.0.12 ``` +**Note:** there’s a [known issue](https://github.com/facebookincubator/create-react-app/issues/3041) that might cause the project to not compile after upgrading. In this case, migrate straight to `1.0.13` which doesn’t have this issue. + ## 1.0.11 (August 9, 2017) #### :bug: Bug Fix From c22dc7092627aa0281f690fe5f3ea1ec725c2f42 Mon Sep 17 00:00:00 2001 From: Dan Abramov <gaearon@fb.com> Date: Sat, 2 Sep 2017 13:58:21 -0700 Subject: [PATCH 160/265] Publish - react-dev-utils@4.0.1 - react-error-overlay@2.0.1 - react-scripts@1.0.13 --- packages/react-dev-utils/package.json | 4 ++-- packages/react-error-overlay/package.json | 2 +- packages/react-scripts/package.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index d2f87f51c..ec8b44292 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "4.0.0", + "version": "4.0.1", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -47,7 +47,7 @@ "inquirer": "3.2.1", "is-root": "1.0.0", "opn": "5.1.0", - "react-error-overlay": "^2.0.0", + "react-error-overlay": "^2.0.1", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index ba4676c4a..b3b9365ae 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "2.0.0", + "version": "2.0.1", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index ff19eb347..5e7bb276c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.12", + "version": "1.0.13", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -48,7 +48,7 @@ "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", - "react-dev-utils": "^4.0.0", + "react-dev-utils": "^4.0.1", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", From e8b58edf637ee07b44492b715814797eaf272ce2 Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara <tharaka.nw@gmail.com> Date: Sun, 3 Sep 2017 09:16:58 +0530 Subject: [PATCH 161/265] Set travis config to use 'precise' ci environment --- .travis.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.travis.yml b/.travis.yml index b08d2bf6b..0ca362c23 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,9 @@ --- +# Use Ubuntu Precise instead of new default Trusty which cause build fail +# with pre installed yarn v0.17.8 +# https://github.com/facebookincubator/create-react-app/issues/3054 +# TODO: remove after Trusty environment is updated with a lastet version of yarn +dist: precise language: node_js node_js: - 6 From b17fa4123e2d098d943f4b33ae9c5c2ac311fab6 Mon Sep 17 00:00:00 2001 From: Jon Crenshaw <jdcrensh@gmail.com> Date: Tue, 5 Sep 2017 19:29:17 -0700 Subject: [PATCH 162/265] Update eslint-config npm install command (#3072) The `npm install` script for outside usage instructions is outdated. Updated to match the package's current peer dependencies. --- packages/eslint-config-react-app/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/eslint-config-react-app/README.md b/packages/eslint-config-react-app/README.md index 0679552a2..6918cda52 100644 --- a/packages/eslint-config-react-app/README.md +++ b/packages/eslint-config-react-app/README.md @@ -19,7 +19,7 @@ If you want to use this ESLint configuration in a project not built with Create First, install this package, ESLint and the necessary plugins. ```sh - npm install --save-dev eslint-config-react-app babel-eslint@7.2.3 eslint@3.19.0 eslint-plugin-flowtype@2.33.0 eslint-plugin-import@2.2.0 eslint-plugin-jsx-a11y@5.0.1 eslint-plugin-react@7.0.1 + npm install --save-dev eslint-config-react-app babel-eslint@^7.2.3 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-react@^7.1.0 ``` Then create a file named `.eslintrc` with following contents in the root folder of your project: From 634dadb4400669d8aa6aa00b7072441f71a36ea7 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Wed, 6 Sep 2017 14:42:40 -0400 Subject: [PATCH 163/265] Unmapper Windows compatibility (#3079) * Switch to unix path separators before normalizing path for Windows compatibility * Add comment for posterity * Revert "Add comment for posterity" This reverts commit 742baceef97e767527498a2ad8b2ab66ad748333. * Strictly add comment --- packages/react-error-overlay/src/utils/unmapper.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/react-error-overlay/src/utils/unmapper.js b/packages/react-error-overlay/src/utils/unmapper.js index 60b2bee43..40f4528c0 100644 --- a/packages/react-error-overlay/src/utils/unmapper.js +++ b/packages/react-error-overlay/src/utils/unmapper.js @@ -56,7 +56,11 @@ async function unmap( } let { fileName } = frame; if (fileName) { - fileName = path.normalize(fileName); + // The web version of this module only provides POSIX support, so Windows + // paths like C:\foo\\baz\..\\bar\ cannot be normalized. + // A simple solution to this is to replace all `\` with `/`, then + // normalize afterwards. + fileName = path.normalize(fileName.replace(/[\\]+/g, '/')); } if (fileName == null) { return frame; @@ -64,6 +68,7 @@ async function unmap( const fN: string = fileName; const source = map .getSources() + // Prepare path for normalization; see comment above for reasoning. .map(s => s.replace(/[\\]+/g, '/')) .filter(p => { p = path.normalize(p); From fcb6dc55578e089e9f62f6e6c12cb9b60a57fee5 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Thu, 7 Sep 2017 16:47:55 +0700 Subject: [PATCH 164/265] run npm 5.4.0 in CI (#3026) * run npm 5.4.0 in CI * run npm cache clean with --force in CI * use link instead of install * Update e2e-installs.sh * Update e2e-kitchensink.sh * Update e2e-simple.sh --- tasks/e2e-installs.sh | 6 +++--- tasks/e2e-kitchensink.sh | 6 +++--- tasks/e2e-simple.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 588642632..ebff7d13a 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -95,11 +95,11 @@ fi if hash npm 2>/dev/null then - # npm 5 is too buggy right now + # npm 5.0-5.4.0 is too buggy if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^4.x + npm i -g npm@^5.4.1 fi; - npm cache clean || npm cache verify + npm cache clean --force || npm cache verify fi # Prevent bootstrap, we only want top-level dependencies diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index ebbac271e..10bdc0779 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -87,11 +87,11 @@ fi if hash npm 2>/dev/null then - # npm 5 is too buggy right now + # npm 5.0-5.4.0 is too buggy if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^4.x + npm i -g npm@^5.4.1 fi; - npm cache clean || npm cache verify + npm cache clean --force || npm cache verify fi # Prevent bootstrap, we only want top-level dependencies diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 48d705eef..84d095e94 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -86,11 +86,11 @@ fi if hash npm 2>/dev/null then - # npm 5 is too buggy right now + # npm 5.0-5.4.0 is too buggy if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^4.x + npm i -g npm@^5.4.1 fi; - npm cache clean || npm cache verify + npm cache clean --force || npm cache verify fi # Prevent bootstrap, we only want top-level dependencies From 5e300cebb3c656c9403f787ede5045d0a737b95f Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Fri, 8 Sep 2017 22:52:18 -0400 Subject: [PATCH 165/265] Reload the page when an error has occurred (#3098) * Reload the page when an error has occurred Fixes #3096 * Use a global boolean instead --- packages/react-dev-utils/webpackHotDevClient.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 18a6a4a0a..b0508dc4d 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -25,13 +25,17 @@ var launchEditorEndpoint = require('./launchEditorEndpoint'); var formatWebpackMessages = require('./formatWebpackMessages'); var ErrorOverlay = require('react-error-overlay'); +// We need to keep track of if there has been a runtime error. +// Essentially, we cannot guarantee application state was not corrupted by the +// runtime error. To prevent confusing behavior, we forcibly reload the entire +// application. This is handled below when we are notified of a compile (code +// change). +// See https://github.com/facebookincubator/create-react-app/issues/3096 +var hadRuntimeError = false; ErrorOverlay.startReportingRuntimeErrors({ launchEditorEndpoint: launchEditorEndpoint, onError: function() { - // TODO: why do we need this? - if (module.hot && typeof module.hot.decline === 'function') { - module.hot.decline(); - } + hadRuntimeError = true; }, filename: '/static/js/bundle.js', }); @@ -227,7 +231,7 @@ function tryApplyUpdates(onHotUpdateSuccess) { } function handleApplyUpdates(err, updatedModules) { - if (err || !updatedModules) { + if (err || !updatedModules || hadRuntimeError) { window.location.reload(); return; } From 44cfbccfda665d6bfb626ce5528697de6033ee8e Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Sun, 10 Sep 2017 12:12:38 +0700 Subject: [PATCH 166/265] Rerun prettier and pin version (#3058) * rerun prettier for all files * pin prettier to 1.6.1 --- package.json | 2 +- packages/create-react-app/createReactApp.js | 4 +++- packages/react-dev-utils/launchEditor.js | 4 ++-- .../src/components/Header.js | 6 +---- .../src/containers/RuntimeErrorContainer.js | 5 +++-- .../src/containers/StackFrame.js | 9 ++++---- .../src/containers/StackTrace.js | 6 +---- .../react-error-overlay/src/utils/parser.js | 22 ++++++++++++------- .../react-error-overlay/src/utils/warnings.js | 5 ++++- .../src/features/env/FileEnvVariables.js | 9 ++++---- .../kitchensink/src/features/env/NodePath.js | 6 +---- .../kitchensink/src/features/env/PublicUrl.js | 7 +++--- .../src/features/env/ShellEnvVariables.js | 5 +++-- .../src/features/syntax/ArrayDestructuring.js | 6 +---- .../src/features/syntax/ArraySpread.js | 6 +---- .../src/features/syntax/AsyncAwait.js | 6 +---- .../src/features/syntax/ClassProperties.js | 6 +---- .../src/features/syntax/ComputedProperties.js | 8 +++---- .../features/syntax/CustomInterpolation.js | 4 ++-- .../src/features/syntax/DefaultParameters.js | 6 +---- .../features/syntax/DestructuringAndAwait.js | 6 +---- .../src/features/syntax/Generators.js | 6 +---- .../features/syntax/ObjectDestructuring.js | 6 +---- .../src/features/syntax/ObjectSpread.js | 4 ++-- .../src/features/syntax/Promises.js | 6 +---- .../src/features/syntax/RestAndDefault.js | 6 +---- .../src/features/syntax/RestParameters.js | 6 +---- .../features/syntax/TemplateInterpolation.js | 6 +---- .../src/features/webpack/ImageInclusion.js | 5 +++-- .../src/features/webpack/JsonInclusion.js | 5 +---- .../src/features/webpack/LinkedModules.js | 6 +---- .../src/features/webpack/NoExtInclusion.js | 5 +++-- .../features/webpack/UnknownExtInclusion.js | 5 +++-- packages/react-scripts/scripts/eject.js | 8 ++++--- 34 files changed, 79 insertions(+), 133 deletions(-) diff --git a/package.json b/package.json index c3dd6404b..5758c6263 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "lerna": "^2.0.0", "lerna-changelog": "^0.6.0", "lint-staged": "^3.3.1", - "prettier": "^1.5.2" + "prettier": "1.6.1" }, "lint-staged": { "*.js": [ diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 4a1b7901d..594f81154 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -455,7 +455,9 @@ function checkNpmVersion() { let hasMinNpm = false; let npmVersion = null; try { - npmVersion = execSync('npm --version').toString().trim(); + npmVersion = execSync('npm --version') + .toString() + .trim(); hasMinNpm = semver.gte(npmVersion, '3.0.0'); } catch (err) { // ignore diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index e1ea29c88..95ae1cddf 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -43,7 +43,7 @@ const COMMON_EDITORS_OSX = { '/Applications/CLion.app/Contents/MacOS/clion': '/Applications/CLion.app/Contents/MacOS/clion', '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea': - '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea', + '/Applications/IntelliJ IDEA.app/Contents/MacOS/idea', '/Applications/PhpStorm.app/Contents/MacOS/phpstorm': '/Applications/PhpStorm.app/Contents/MacOS/phpstorm', '/Applications/PyCharm.app/Contents/MacOS/pycharm': @@ -53,7 +53,7 @@ const COMMON_EDITORS_OSX = { '/Applications/RubyMine.app/Contents/MacOS/rubymine': '/Applications/RubyMine.app/Contents/MacOS/rubymine', '/Applications/WebStorm.app/Contents/MacOS/webstorm': - '/Applications/WebStorm.app/Contents/MacOS/webstorm', + '/Applications/WebStorm.app/Contents/MacOS/webstorm', }; const COMMON_EDITORS_WIN = [ diff --git a/packages/react-error-overlay/src/components/Header.js b/packages/react-error-overlay/src/components/Header.js index a2f40973d..227162343 100644 --- a/packages/react-error-overlay/src/components/Header.js +++ b/packages/react-error-overlay/src/components/Header.js @@ -29,11 +29,7 @@ type HeaderPropType = {| |}; function Header(props: HeaderPropType) { - return ( - <div style={headerStyle}> - {props.headerText} - </div> - ); + return <div style={headerStyle}>{props.headerText}</div>; } export default Header; diff --git a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js index 9c41aa381..1e09724df 100644 --- a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js +++ b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js @@ -54,13 +54,14 @@ class RuntimeErrorContainer extends PureComponent { return ( <ErrorOverlay shortcutHandler={this.shortcutHandler}> <CloseButton close={close} /> - {totalErrors > 1 && + {totalErrors > 1 && ( <NavigationBar currentError={this.state.currentIndex + 1} totalErrors={totalErrors} previous={this.previous} next={this.next} - />} + /> + )} <RuntimeError errorRecord={errorRecords[this.state.currentIndex]} launchEditorEndpoint={this.props.launchEditorEndpoint} diff --git a/packages/react-error-overlay/src/containers/StackFrame.js b/packages/react-error-overlay/src/containers/StackFrame.js index c95ce003f..1dfcbb437 100644 --- a/packages/react-error-overlay/src/containers/StackFrame.js +++ b/packages/react-error-overlay/src/containers/StackFrame.js @@ -155,9 +155,7 @@ class StackFrame extends Component { const canOpenInEditor = this.canOpenInEditor(); return ( <div> - <div> - {functionName} - </div> + <div>{functionName}</div> <div style={linkStyle}> <a style={canOpenInEditor ? anchorStyle : null} @@ -168,7 +166,7 @@ class StackFrame extends Component { {url} </a> </div> - {codeBlockProps && + {codeBlockProps && ( <span> <a onClick={canOpenInEditor ? this.openInEditor : null} @@ -179,7 +177,8 @@ class StackFrame extends Component { <button style={toggleStyle} onClick={this.toggleCompiled}> {'View ' + (compiled ? 'source' : 'compiled')} </button> - </span>} + </span> + )} </div> ); } diff --git a/packages/react-error-overlay/src/containers/StackTrace.js b/packages/react-error-overlay/src/containers/StackTrace.js index 4cb20bce1..8d81cc942 100644 --- a/packages/react-error-overlay/src/containers/StackTrace.js +++ b/packages/react-error-overlay/src/containers/StackTrace.js @@ -84,11 +84,7 @@ class StackTrace extends Component { } render() { - return ( - <div style={traceStyle}> - {this.renderFrames()} - </div> - ); + return <div style={traceStyle}>{this.renderFrames()}</div>; } } diff --git a/packages/react-error-overlay/src/utils/parser.js b/packages/react-error-overlay/src/utils/parser.js index 1cbee1d1c..6bc65ed8d 100644 --- a/packages/react-error-overlay/src/utils/parser.js +++ b/packages/react-error-overlay/src/utils/parser.js @@ -13,13 +13,16 @@ import StackFrame from './stack-frame'; const regexExtractLocation = /\(?(.+?)(?::(\d+))?(?::(\d+))?\)?$/; function extractLocation(token: string): [string, number, number] { - return regexExtractLocation.exec(token).slice(1).map(v => { - const p = Number(v); - if (!isNaN(p)) { - return p; - } - return v; - }); + return regexExtractLocation + .exec(token) + .slice(1) + .map(v => { + const p = Number(v); + if (!isNaN(p)) { + return p; + } + return v; + }); } const regexValidFrame_Chrome = /^\s*(at|in)\s.+(:\d+)/; @@ -55,7 +58,10 @@ function parseStack(stack: string[]): StackFrame[] { if (e.indexOf('(at ') !== -1) { e = e.replace(/\(at /, '('); } - const data = e.trim().split(/\s+/g).slice(1); + const data = e + .trim() + .split(/\s+/g) + .slice(1); const last = data.pop(); return new StackFrame(data.join(' ') || null, ...extractLocation(last)); } diff --git a/packages/react-error-overlay/src/utils/warnings.js b/packages/react-error-overlay/src/utils/warnings.js index bcc54ceb7..1cdb53dc0 100644 --- a/packages/react-error-overlay/src/utils/warnings.js +++ b/packages/react-error-overlay/src/utils/warnings.js @@ -11,7 +11,10 @@ import type { ReactFrame } from '../effects/proxyConsole'; function stripInlineStacktrace(message: string): string { - return message.split('\n').filter(line => !line.match(/^\s*in/)).join('\n'); // " in Foo" + return message + .split('\n') + .filter(line => !line.match(/^\s*in/)) + .join('\n'); // " in Foo" } function massage( diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js index 03d638471..41c472e03 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js @@ -9,7 +9,7 @@ import React from 'react'; -export default () => +export default () => ( <span> <span id="feature-file-env-original-1"> {process.env.REACT_APP_ORIGINAL_1} @@ -21,7 +21,6 @@ export default () => {process.env.REACT_APP_DEVELOPMENT} {process.env.REACT_APP_PRODUCTION} </span> - <span id="feature-file-env-x"> - {process.env.REACT_APP_X} - </span> - </span>; + <span id="feature-file-env-x">{process.env.REACT_APP_X}</span> + </span> +); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js index 6d2437a64..a039cefed 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js @@ -33,11 +33,7 @@ export default class extends Component { render() { return ( <div id="feature-node-path"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js index af87748e6..4ea9b96f8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js @@ -9,7 +9,6 @@ import React from 'react'; -export default () => - <span id="feature-public-url"> - {process.env.PUBLIC_URL}. - </span>; +export default () => ( + <span id="feature-public-url">{process.env.PUBLIC_URL}.</span> +); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js index 400dfc013..8449097d6 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js @@ -9,7 +9,8 @@ import React from 'react'; -export default () => +export default () => ( <span id="feature-shell-env-variables"> {process.env.REACT_APP_SHELL_ENV_MESSAGE}. - </span>; + </span> +); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js index de0576549..be6c39f90 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js @@ -38,11 +38,7 @@ export default class extends Component { <div id="feature-array-destructuring"> {this.state.users.map(user => { const [id, name] = user; - return ( - <div key={id}> - {name} - </div> - ); + return <div key={id}>{name}</div>; })} </div> ); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js index ebf90ef6e..eb7886aa4 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js @@ -41,11 +41,7 @@ export default class extends Component { render() { return ( <div id="feature-array-spread"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js index c91da311d..a60633460 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js @@ -41,11 +41,7 @@ export default class extends Component { render() { return ( <div id="feature-async-await"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js index 58ae10763..ed96d4f8c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js @@ -29,11 +29,7 @@ export default class extends Component { render() { return ( <div id="feature-class-properties"> - {this.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js index fcbf721e8..38dc797a8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js @@ -41,11 +41,9 @@ export default class extends Component { render() { return ( <div id="feature-computed-properties"> - {this.state.users.map(user => - <div key={user.id}> - {user.user_name} - </div> - )} + {this.state.users.map(user => ( + <div key={user.id}>{user.user_name}</div> + ))} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js index ab648255a..a6c9b69de 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js @@ -53,11 +53,11 @@ export default class extends Component { return ( <div id="feature-custom-interpolation"> - {this.state.users.map(user => + {this.state.users.map(user => ( <div key={user.id} style={veryInlineStyle}> {user.name} </div> - )} + ))} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js index 6ebabaec7..0a519eba8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js @@ -41,11 +41,7 @@ export default class extends Component { render() { return ( <div id="feature-default-parameters"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js index aa8c9d7db..d44f4cf22 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js @@ -43,11 +43,7 @@ export default class extends Component { render() { return ( <div id="feature-destructuring-and-await"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js index 44b2776e1..2fe473d13 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js @@ -43,11 +43,7 @@ export default class extends Component { render() { return ( <div id="feature-generators"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js index 8a7b1095f..2994d14af 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js @@ -43,11 +43,7 @@ export default class extends Component { <div id="feature-object-destructuring"> {this.state.users.map(user => { const { id, name } = user; - return ( - <div key={id}> - {name} - </div> - ); + return <div key={id}>{name}</div>; })} </div> ); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js index 5ff4e10ac..7349be2f9 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js @@ -41,11 +41,11 @@ export default class extends Component { render() { return ( <div id="feature-object-spread"> - {this.state.users.map(user => + {this.state.users.map(user => ( <div key={user.id}> {user.name}: {user.age} </div> - )} + ))} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js index 31ef2c9eb..e626de5d8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js @@ -42,11 +42,7 @@ export default class extends Component { render() { return ( <div id="feature-promises"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js index 9e3e3fbab..dc2a1563a 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js @@ -41,11 +41,7 @@ export default class extends Component { render() { return ( <div id="feature-rest-and-default"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js index 98a0e7edc..e703a33cc 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js @@ -41,11 +41,7 @@ export default class extends Component { render() { return ( <div id="feature-rest-parameters"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js index b69f7ede8..5aba5da62 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js @@ -41,11 +41,7 @@ export default class extends Component { render() { return ( <div id="feature-template-interpolation"> - {this.state.users.map(user => - <div key={user.id}> - {user.name} - </div> - )} + {this.state.users.map(user => <div key={user.id}>{user.name}</div>)} </div> ); } diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js index 8598d8d06..a6ca7aaa8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js @@ -10,5 +10,6 @@ import React from 'react'; import tiniestCat from './assets/tiniest-cat.jpg'; -export default () => - <img id="feature-image-inclusion" src={tiniestCat} alt="tiniest cat" />; +export default () => ( + <img id="feature-image-inclusion" src={tiniestCat} alt="tiniest cat" /> +); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js index 66425c66c..e81f76397 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js @@ -10,7 +10,4 @@ import React from 'react'; import { abstract } from './assets/abstract.json'; -export default () => - <summary id="feature-json-inclusion"> - {abstract} - </summary>; +export default () => <summary id="feature-json-inclusion">{abstract}</summary>; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js index 395ebd7ed..de8a5e4ab 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js @@ -16,9 +16,5 @@ export default () => { if (!test() || v !== '2.0.0') { throw new Error('Functionality test did not pass.'); } - return ( - <p id="feature-linked-modules"> - {v} - </p> - ); + return <p id="feature-linked-modules">{v}</p>; }; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js index 086885db2..be22a6c9f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js @@ -14,7 +14,8 @@ const text = aFileWithoutExt.includes('base64') ? atob(aFileWithoutExt.split('base64,')[1]).trim() : aFileWithoutExt; -export default () => +export default () => ( <a id="feature-no-ext-inclusion" href={text}> aFileWithoutExt - </a>; + </a> +); diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js index c41a1e0c0..5cae4516a 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js @@ -14,7 +14,8 @@ const text = aFileWithExtUnknown.includes('base64') ? atob(aFileWithExtUnknown.split('base64,')[1]).trim() : aFileWithExtUnknown; -export default () => +export default () => ( <a id="feature-unknown-ext-inclusion" href={text}> aFileWithExtUnknown - </a>; + </a> +); diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 3d8d258cc..8f6af4f47 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -167,9 +167,11 @@ inquirer // Sort the deps const unsortedDependencies = appPackage.dependencies; appPackage.dependencies = {}; - Object.keys(unsortedDependencies).sort().forEach(key => { - appPackage.dependencies[key] = unsortedDependencies[key]; - }); + Object.keys(unsortedDependencies) + .sort() + .forEach(key => { + appPackage.dependencies[key] = unsortedDependencies[key]; + }); console.log(); console.log(cyan('Updating the scripts')); From 12f1a8eed8863a1cc6a5703e6bc5f43283ea547c Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Mon, 11 Sep 2017 07:37:36 -0400 Subject: [PATCH 167/265] Clean target directory before compiling overlay (#3102) * Clean target directory before compiling overlay * Use rimraf --- packages/react-error-overlay/package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index b3b9365ae..289f72126 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -5,10 +5,10 @@ "main": "lib/index.js", "scripts": { "prepublishOnly": "npm run build:prod && npm test", - "start": "cross-env NODE_ENV=development npm run build -- --watch", + "start": "rimraf lib/ && cross-env NODE_ENV=development npm run build -- --watch", "test": "flow && jest", - "build": "babel src/ -d lib/", - "build:prod": "cross-env NODE_ENV=production babel src/ -d lib/" + "build": "rimraf lib/ && babel src/ -d lib/", + "build:prod": "rimraf lib/ && cross-env NODE_ENV=production babel src/ -d lib/" }, "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -53,7 +53,8 @@ "eslint-plugin-react": "7.1.0", "flow-bin": "0.52.0", "jest": "20.0.4", - "jest-fetch-mock": "1.2.1" + "jest-fetch-mock": "1.2.1", + "rimraf": "^2.6.1" }, "jest": { "setupFiles": [ From 1faee66a778924d1f038e6ba789daac3706b15db Mon Sep 17 00:00:00 2001 From: gulderov <gulderov@ya.ru> Date: Mon, 11 Sep 2017 15:31:28 +0300 Subject: [PATCH 168/265] Auto-detect running editor on Linux for error overlay (#3077) * Auto-detect running editor on Linux for error overlay Basic support of auto detecting running editor for #2636. Tested on Ubuntu 16.04. It detects few editors. JetBrains products should start by wrapper like /usr/local/bin/webstorm. Otherwise it takes a lot of time to open editor. * Comments fixed. * List all processes owned by you * Comment rewording --- packages/react-dev-utils/launchEditor.js | 33 ++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index 95ae1cddf..a6f7226ef 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -56,6 +56,20 @@ const COMMON_EDITORS_OSX = { '/Applications/WebStorm.app/Contents/MacOS/webstorm', }; +const COMMON_EDITORS_LINUX = { + atom: 'atom', + Brackets: 'brackets', + code: 'code', + emacs: 'emacs', + 'idea.sh': 'idea', + 'phpstorm.sh': 'phpstorm', + 'pycharm.sh': 'pycharm', + 'rubymine.sh': 'rubymine', + sublime_text: 'sublime_text', + vim: 'vim', + 'webstorm.sh': 'webstorm', +}; + const COMMON_EDITORS_WIN = [ 'Brackets.exe', 'Code.exe', @@ -144,8 +158,9 @@ function guessEditor() { return shellQuote.parse(process.env.REACT_EDITOR); } - // Using `ps x` on OSX or `Get-Process` on Windows we can find out which editor is currently running. - // Potentially we could use similar technique for Linux + // We can find out which editor is currently running by: + // `ps x` on macOS and Linux + // `Get-Process` on Windows try { if (process.platform === 'darwin') { const output = child_process.execSync('ps x').toString(); @@ -176,6 +191,20 @@ function guessEditor() { return [fullProcessPath]; } } + } else if (process.platform === 'linux') { + // --no-heading No header line + // x List all processes owned by you + // -o comm Need only names column + const output = child_process + .execSync('ps x --no-heading -o comm --sort=comm') + .toString(); + const processNames = Object.keys(COMMON_EDITORS_LINUX); + for (let i = 0; i < processNames.length; i++) { + const processName = processNames[i]; + if (output.indexOf(processName) !== -1) { + return [COMMON_EDITORS_LINUX[processName]]; + } + } } } catch (error) { // Ignore... From eed708a822d6cf3ff17b665b093a2c23a50f6b15 Mon Sep 17 00:00:00 2001 From: Luca <duvet86@gmail.com> Date: Tue, 12 Sep 2017 00:20:50 +0800 Subject: [PATCH 169/265] Updated react-error-overlay to latest Flow (0.54.0) (#3065) * Updated react-error-overlay to latest Flow (0.54.0) * Revert "Updated react-error-overlay to latest Flow (0.54.0)" This reverts commit 6deaffbdb0b2e7c72a7f4053a299f28db174383b. * Fixed unit tests. * Updated code as per code review. * Fixed code as per code review. * Updated the code as per review. --- packages/react-error-overlay/package.json | 2 +- .../src/components/Collapsible.js | 12 ++++++- .../src/components/ErrorOverlay.js | 15 ++++++-- .../src/containers/CompileErrorContainer.js | 6 +++- .../src/containers/RuntimeError.js | 3 +- .../src/containers/RuntimeErrorContainer.js | 14 +++++++- .../src/containers/StackFrame.js | 36 +++++++++++++------ .../src/containers/StackFrameCodeBlock.js | 8 +++-- .../src/containers/StackTrace.js | 11 +++++- packages/react-error-overlay/src/index.js | 3 +- .../src/utils/getSourceMap.js | 5 ++- 11 files changed, 93 insertions(+), 22 deletions(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 289f72126..11ee85894 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -51,7 +51,7 @@ "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.1.0", - "flow-bin": "0.52.0", + "flow-bin": "^0.54.0", "jest": "20.0.4", "jest-fetch-mock": "1.2.1", "rimraf": "^2.6.1" diff --git a/packages/react-error-overlay/src/components/Collapsible.js b/packages/react-error-overlay/src/components/Collapsible.js index 92f1de429..095428813 100644 --- a/packages/react-error-overlay/src/components/Collapsible.js +++ b/packages/react-error-overlay/src/components/Collapsible.js @@ -11,6 +11,8 @@ import React, { Component } from 'react'; import { black } from '../styles'; +import type { Element as ReactElement } from 'react'; + const _collapsibleStyle = { color: black, cursor: 'pointer', @@ -35,7 +37,15 @@ const collapsibleExpandedStyle = { marginBottom: '0.6em', }; -class Collapsible extends Component { +type Props = {| + children: ReactElement<any>[], +|}; + +type State = {| + collapsed: boolean, +|}; + +class Collapsible extends Component<Props, State> { state = { collapsed: true, }; diff --git a/packages/react-error-overlay/src/components/ErrorOverlay.js b/packages/react-error-overlay/src/components/ErrorOverlay.js index 446105dad..2f706f242 100644 --- a/packages/react-error-overlay/src/components/ErrorOverlay.js +++ b/packages/react-error-overlay/src/components/ErrorOverlay.js @@ -11,6 +11,8 @@ import React, { Component } from 'react'; import { black } from '../styles'; +import type { Node as ReactNode } from 'react'; + const overlayStyle = { position: 'relative', display: 'inline-flex', @@ -31,10 +33,19 @@ const overlayStyle = { color: black, }; -class ErrorOverlay extends Component { +type Props = {| + children: ReactNode, + shortcutHandler?: (eventKey: string) => void, +|}; + +type State = {| + collapsed: boolean, +|}; + +class ErrorOverlay extends Component<Props, State> { iframeWindow: window = null; - getIframeWindow = (element: HTMLDivElement) => { + getIframeWindow = (element: ?HTMLDivElement) => { if (element) { const document = element.ownerDocument; this.iframeWindow = document.defaultView; diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js index a3e89fe59..9eb8c029b 100644 --- a/packages/react-error-overlay/src/containers/CompileErrorContainer.js +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -15,7 +15,11 @@ import Header from '../components/Header'; import CodeBlock from '../components/CodeBlock'; import generateAnsiHTML from '../utils/generateAnsiHTML'; -class CompileErrorContainer extends PureComponent { +type Props = {| + error: string, +|}; + +class CompileErrorContainer extends PureComponent<Props, void> { render() { const { error } = this.props; return ( diff --git a/packages/react-error-overlay/src/containers/RuntimeError.js b/packages/react-error-overlay/src/containers/RuntimeError.js index c64824137..b21360d5e 100644 --- a/packages/react-error-overlay/src/containers/RuntimeError.js +++ b/packages/react-error-overlay/src/containers/RuntimeError.js @@ -11,6 +11,7 @@ import React from 'react'; import Header from '../components/Header'; import StackTrace from './StackTrace'; + import type { StackFrame } from '../utils/stack-frame'; const wrapperStyle = { @@ -18,7 +19,7 @@ const wrapperStyle = { flexDirection: 'column', }; -type ErrorRecord = {| +export type ErrorRecord = {| error: Error, unhandledRejection: boolean, contextSize: number, diff --git a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js index 1e09724df..dafd2af27 100644 --- a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js +++ b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js @@ -15,7 +15,19 @@ import NavigationBar from '../components/NavigationBar'; import RuntimeError from './RuntimeError'; import Footer from '../components/Footer'; -class RuntimeErrorContainer extends PureComponent { +import type { ErrorRecord } from './RuntimeError'; + +type Props = {| + errorRecords: ErrorRecord[], + close: () => void, + launchEditorEndpoint: ?string, +|}; + +type State = {| + currentIndex: number, +|}; + +class RuntimeErrorContainer extends PureComponent<Props, State> { state = { currentIndex: 0, }; diff --git a/packages/react-error-overlay/src/containers/StackFrame.js b/packages/react-error-overlay/src/containers/StackFrame.js index 1dfcbb437..991662356 100644 --- a/packages/react-error-overlay/src/containers/StackFrame.js +++ b/packages/react-error-overlay/src/containers/StackFrame.js @@ -13,6 +13,8 @@ import CodeBlock from './StackFrameCodeBlock'; import { getPrettyURL } from '../utils/getPrettyURL'; import { darkGray } from '../styles'; +import type { StackFrame as StackFrameType } from '../utils/stack-frame'; + const linkStyle = { fontSize: '0.9em', marginBottom: '0.9em', @@ -43,7 +45,19 @@ const toggleStyle = { lineHeight: '1.5', }; -class StackFrame extends Component { +type Props = {| + frame: StackFrameType, + launchEditorEndpoint: ?string, + contextSize: number, + critical: boolean, + showCode: boolean, +|}; + +type State = {| + compiled: boolean, +|}; + +class StackFrame extends Component<Props, State> { state = { compiled: false, }; @@ -54,43 +68,45 @@ class StackFrame extends Component { })); }; - canOpenInEditor() { + getEndpointUrl(): string | null { if (!this.props.launchEditorEndpoint) { - return; + return null; } const { _originalFileName: sourceFileName } = this.props.frame; // Unknown file if (!sourceFileName) { - return false; + return null; } // e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1" const isInternalWebpackBootstrapCode = sourceFileName.trim().indexOf(' ') !== -1; if (isInternalWebpackBootstrapCode) { - return false; + return null; } // Code is in a real file - return true; + return this.props.launchEditorEndpoint || null; } openInEditor = () => { - if (!this.canOpenInEditor()) { + const endpointUrl = this.getEndpointUrl(); + if (endpointUrl === null) { return; } + const { _originalFileName: sourceFileName, _originalLineNumber: sourceLineNumber, } = this.props.frame; // Keep this in sync with react-error-overlay/middleware.js fetch( - `${this.props.launchEditorEndpoint}?fileName=` + + `${endpointUrl}?fileName=` + window.encodeURIComponent(sourceFileName) + '&lineNumber=' + window.encodeURIComponent(sourceLineNumber || 1) ).then(() => {}, () => {}); }; - onKeyDown = (e: SyntheticKeyboardEvent) => { + onKeyDown = (e: SyntheticKeyboardEvent<>) => { if (e.key === 'Enter') { this.openInEditor(); } @@ -152,7 +168,7 @@ class StackFrame extends Component { } } - const canOpenInEditor = this.canOpenInEditor(); + const canOpenInEditor = this.getEndpointUrl() !== null; return ( <div> <div>{functionName}</div> diff --git a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js index 2ed685cff..58a2c0d53 100644 --- a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js +++ b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js @@ -21,12 +21,16 @@ import codeFrame from 'babel-code-frame'; type StackFrameCodeBlockPropsType = {| lines: ScriptLine[], lineNum: number, - columnNum: number, + columnNum: ?number, contextSize: number, main: boolean, |}; -function StackFrameCodeBlock(props: StackFrameCodeBlockPropsType) { +// Exact type workaround for spread operator. +// See: https://github.com/facebook/flow/issues/2405 +type Exact<T> = $Shape<T>; + +function StackFrameCodeBlock(props: Exact<StackFrameCodeBlockPropsType>) { const { lines, lineNum, columnNum, contextSize, main } = props; const sourceCode = []; let whiteSpace = Infinity; diff --git a/packages/react-error-overlay/src/containers/StackTrace.js b/packages/react-error-overlay/src/containers/StackTrace.js index 8d81cc942..8d4a487dc 100644 --- a/packages/react-error-overlay/src/containers/StackTrace.js +++ b/packages/react-error-overlay/src/containers/StackTrace.js @@ -14,6 +14,8 @@ import Collapsible from '../components/Collapsible'; import { isInternalFile } from '../utils/isInternalFile'; import { isBultinErrorName } from '../utils/isBultinErrorName'; +import type { StackFrame as StackFrameType } from '../utils/stack-frame'; + const traceStyle = { fontSize: '1em', flex: '0 1 auto', @@ -21,7 +23,14 @@ const traceStyle = { overflow: 'auto', }; -class StackTrace extends Component { +type Props = {| + stackFrames: StackFrameType[], + errorName: string, + contextSize: number, + launchEditorEndpoint: ?string, +|}; + +class StackTrace extends Component<Props> { renderFrames() { const { stackFrames, diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index 168baa7ef..d44976713 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -9,6 +9,7 @@ /* @flow */ import React from 'react'; +import type { Element } from 'react'; import ReactDOM from 'react-dom'; import CompileErrorContainer from './containers/CompileErrorContainer'; import RuntimeErrorContainer from './containers/RuntimeErrorContainer'; @@ -27,7 +28,7 @@ type RuntimeReportingOptions = {| let iframe: null | HTMLIFrameElement = null; let isLoadingIframe: boolean = false; -let renderedElement: null | React.Element<any> = null; +let renderedElement: null | Element<any> = null; let currentBuildError: null | string = null; let currentRuntimeErrorRecords: Array<ErrorRecord> = []; let currentRuntimeErrorOptions: null | RuntimeReportingOptions = null; diff --git a/packages/react-error-overlay/src/utils/getSourceMap.js b/packages/react-error-overlay/src/utils/getSourceMap.js index 1d8405519..5c9e3aa9e 100644 --- a/packages/react-error-overlay/src/utils/getSourceMap.js +++ b/packages/react-error-overlay/src/utils/getSourceMap.js @@ -77,7 +77,10 @@ class SourceMap { } } -function extractSourceMapUrl(fileUri: string, fileContents: string) { +function extractSourceMapUrl( + fileUri: string, + fileContents: string +): Promise<string> { const regex = /\/\/[#@] ?sourceMappingURL=([^\s'"]+)\s*$/gm; let match = null; for (;;) { From 0e064b30ca545e7e1cb40217b9ec2384ceb19658 Mon Sep 17 00:00:00 2001 From: Ade Viankakrisna Fadlil <viankakrisna@gmail.com> Date: Tue, 12 Sep 2017 08:40:11 +0700 Subject: [PATCH 170/265] Revert "run npm 5.4.0 in CI (#3026)" (#3107) This reverts commit fcb6dc55578e089e9f62f6e6c12cb9b60a57fee5. --- tasks/e2e-installs.sh | 6 +++--- tasks/e2e-kitchensink.sh | 6 +++--- tasks/e2e-simple.sh | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index ebff7d13a..588642632 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -95,11 +95,11 @@ fi if hash npm 2>/dev/null then - # npm 5.0-5.4.0 is too buggy + # npm 5 is too buggy right now if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^5.4.1 + npm i -g npm@^4.x fi; - npm cache clean --force || npm cache verify + npm cache clean || npm cache verify fi # Prevent bootstrap, we only want top-level dependencies diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 10bdc0779..ebbac271e 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -87,11 +87,11 @@ fi if hash npm 2>/dev/null then - # npm 5.0-5.4.0 is too buggy + # npm 5 is too buggy right now if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^5.4.1 + npm i -g npm@^4.x fi; - npm cache clean --force || npm cache verify + npm cache clean || npm cache verify fi # Prevent bootstrap, we only want top-level dependencies diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 84d095e94..48d705eef 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -86,11 +86,11 @@ fi if hash npm 2>/dev/null then - # npm 5.0-5.4.0 is too buggy + # npm 5 is too buggy right now if [ $(npm -v | head -c 1) -eq 5 ]; then - npm i -g npm@^5.4.1 + npm i -g npm@^4.x fi; - npm cache clean --force || npm cache verify + npm cache clean || npm cache verify fi # Prevent bootstrap, we only want top-level dependencies From 206f9e84e62434e78d8ad7cf6f2c84476f611d12 Mon Sep 17 00:00:00 2001 From: David Leger <davidleger95@me.com> Date: Tue, 12 Sep 2017 23:32:57 -0300 Subject: [PATCH 171/265] Resolved issue #2971 (#2989) * Resolved issue #2971 - changed h2 to h1 in template to adhere to accessibility guidelines. - Added h1 styles to maintain same font size. * Added header tag to template Corrected templete to use semantically correct header tag for header instead of div * Added className for App-title - Added className="App-title" to h1 tag - Changed CSS selector to target class instead of element --- packages/react-scripts/template/src/App.css | 4 ++++ packages/react-scripts/template/src/App.js | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/template/src/App.css b/packages/react-scripts/template/src/App.css index 15adfdc71..c5c6e8a68 100644 --- a/packages/react-scripts/template/src/App.css +++ b/packages/react-scripts/template/src/App.css @@ -14,6 +14,10 @@ color: white; } +.App-title { + font-size: 1.5em; +} + .App-intro { font-size: large; } diff --git a/packages/react-scripts/template/src/App.js b/packages/react-scripts/template/src/App.js index d7d52a7f3..203067e4d 100644 --- a/packages/react-scripts/template/src/App.js +++ b/packages/react-scripts/template/src/App.js @@ -6,10 +6,10 @@ class App extends Component { render() { return ( <div className="App"> - <div className="App-header"> + <header className="App-header"> <img src={logo} className="App-logo" alt="logo" /> - <h2>Welcome to React</h2> - </div> + <h1 className="App-title">Welcome to React</h1> + </header> <p className="App-intro"> To get started, edit <code>src/App.js</code> and save to reload. </p> From 89bf273ec817ccc32f6098ac00ef0b8d9cc078af Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara <tharaka.nw@gmail.com> Date: Sat, 16 Sep 2017 12:22:13 +0530 Subject: [PATCH 172/265] Link local react-error-overlay package in kitchensink test --- tasks/e2e-kitchensink.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index ebbac271e..8ef0bc23d 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -165,6 +165,9 @@ cd "$temp_app_path/test-kitchensink" # Link to our preset npm link "$root_path"/packages/babel-preset-react-app +# Link to error overlay package because now it's a dependency +# of react-dev-utils and not react-scripts +npm link "$root_path"/packages/react-error-overlay # Link to test module npm link "$temp_module_path/node_modules/test-integrity" @@ -220,6 +223,8 @@ E2E_FILE=./build/index.html \ # Unlink our preset npm unlink "$root_path"/packages/babel-preset-react-app +# Unlink error overlay +npm unlink "$root_path"/packages/react-error-overlay # Eject... echo yes | npm run eject @@ -227,6 +232,7 @@ echo yes | npm run eject # ...but still link to the local packages npm link "$root_path"/packages/babel-preset-react-app npm link "$root_path"/packages/eslint-config-react-app +npm link "$root_path"/packages/react-error-overlay npm link "$root_path"/packages/react-dev-utils npm link "$root_path"/packages/react-scripts From 2cff8db00b31efd7d6ce3da32b7e877458d3c47f Mon Sep 17 00:00:00 2001 From: Rasmus Eneman <rasmus@eneman.eu> Date: Sun, 17 Sep 2017 00:22:06 +0200 Subject: [PATCH 173/265] Display pid in already running message (#3131) Fixes #3106 --- packages/react-dev-utils/getProcessForPort.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index 428dc62cf..73a445f5b 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -48,9 +48,11 @@ function getProcessCommand(processId, processDirectory) { execOptions ); + command = command.replace(/\n$/, '') + if (isProcessAReactApp(command)) { const packageName = getPackageNameInDirectory(processDirectory); - return packageName ? packageName + '\n' : command; + return packageName ? packageName : command; } else { return command; } @@ -68,7 +70,8 @@ function getProcessForPort(port) { var processId = getProcessIdOnPort(port); var directory = getDirectoryOfProcessById(processId); var command = getProcessCommand(processId, directory); - return chalk.cyan(command) + chalk.blue(' in ') + chalk.cyan(directory); + return chalk.cyan(command) + chalk.grey(' (pid ' + processId + ')\n') + + chalk.blue(' in ') + chalk.cyan(directory); } catch (e) { return null; } From b67ef01adee75a96aca5ad3b98101ea79ed116a2 Mon Sep 17 00:00:00 2001 From: Kristie Howard <kristie.howard@docker.com> Date: Tue, 19 Sep 2017 19:00:44 -0700 Subject: [PATCH 174/265] Update unclear wording in webpack config docs (#3160) --- packages/react-scripts/config/webpack.config.dev.js | 2 +- packages/react-scripts/config/webpack.config.prod.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 3ac7395e6..6417578f4 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -220,7 +220,7 @@ module.exports = { // "file" loader makes sure those assets get served by WebpackDevServer. // When you `import` an asset, you get its (virtual) filename. // In production, they would get copied to the `build` folder. - // This loader don't uses a "test" so it will catch all modules + // This loader doesn't use a "test" so it will catch all modules // that fall through the other loaders. { // Exclude `js` files to keep "css" loader working as it injects diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index d80351ec6..81121a949 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -238,7 +238,7 @@ module.exports = { }, // "file" loader makes sure assets end up in the `build` folder. // When you `import` an asset, you get its filename. - // This loader don't uses a "test" so it will catch all modules + // This loader doesn't use a "test" so it will catch all modules // that fall through the other loaders. { loader: require.resolve('file-loader'), From 700c8cd4d4b2b024ac13491daecc8ecf011a814b Mon Sep 17 00:00:00 2001 From: Rick Beerendonk <rick@beerendonk.com> Date: Wed, 20 Sep 2017 15:01:06 +0200 Subject: [PATCH 175/265] Part of class fields to stage 3 (#2908) * Class fields to stage 3 Per 2017.07.27 TC39 https://github.com/tc39/proposals/commit/0bbbb08c3cdcc986d59b21782b70633329546042 * Be explicit that only the public part of the unified field proposal is available. --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index c55ccdf94..98e26c98e 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -199,7 +199,7 @@ In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, * [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017). * [Object Rest/Spread Properties](https://github.com/sebmarkbage/ecmascript-rest-spread) (stage 3 proposal). * [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal) -* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (stage 2 proposal). +* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal). * [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flowtype.org/) syntax. Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-). From 376fd432ce4b95f460af5586139f5e5a026f020d Mon Sep 17 00:00:00 2001 From: Nik Nyby <nnyby@columbia.edu> Date: Thu, 21 Sep 2017 22:48:41 -0400 Subject: [PATCH 176/265] Update webpack-dev-server to 2.8.2 (#3157) It doesn't look like there is any backwards incompatibility: https://github.com/webpack/webpack-dev-server/releases --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 5e7bb276c..9905cb5aa 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -53,7 +53,7 @@ "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", "webpack": "3.5.1", - "webpack-dev-server": "2.7.1", + "webpack-dev-server": "2.8.2", "webpack-manifest-plugin": "1.2.1", "whatwg-fetch": "2.0.3" }, From 1491d4614c4027d2ac8ad4c52f4dcd7e598b4a34 Mon Sep 17 00:00:00 2001 From: Neek Sandhu <neek.sandhu@outlook.com> Date: Thu, 21 Sep 2017 19:50:39 -0700 Subject: [PATCH 177/265] Add link to active CSS modules discussion (#3163) * Add link to active CSS modules discussion * Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f38e73c7..6f7b7a199 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ Some features are currently **not supported**: * Server rendering. * Some experimental syntax extensions (e.g. decorators). -* CSS Modules. +* CSS Modules (see [#2285](https://github.com/facebookincubator/create-react-app/pull/2285)). * Importing LESS or Sass directly ([but you still can use them](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc)). * Hot reloading of components. From 2e82ebb3371731a5c4e346f310848ddb23fd0976 Mon Sep 17 00:00:00 2001 From: Sophie Alpert <git@sophiebits.com> Date: Tue, 26 Sep 2017 02:30:05 -0700 Subject: [PATCH 178/265] BSD+Patents -> MIT (#3189) * File headers BSD+Patents -> MIT * BSD+Patents -> MIT --- LICENSE | 43 ++++++++----------- PATENTS | 33 -------------- packages/babel-preset-react-app/index.js | 6 +-- packages/babel-preset-react-app/package.json | 2 +- packages/create-react-app/createReactApp.js | 6 +-- packages/create-react-app/index.js | 6 +-- packages/create-react-app/package.json | 2 +- packages/eslint-config-react-app/index.js | 6 +-- packages/eslint-config-react-app/package.json | 2 +- packages/react-dev-utils/FileSizeReporter.js | 6 +-- .../react-dev-utils/InterpolateHtmlPlugin.js | 6 +-- packages/react-dev-utils/ModuleScopePlugin.js | 6 +-- .../WatchMissingNodeModulesPlugin.js | 6 +-- .../react-dev-utils/WebpackDevServerUtils.js | 6 +-- .../react-dev-utils/checkRequiredFiles.js | 6 +-- packages/react-dev-utils/clearConsole.js | 6 +-- packages/react-dev-utils/crossSpawn.js | 6 +-- .../react-dev-utils/errorOverlayMiddleware.js | 6 +-- packages/react-dev-utils/eslintFormatter.js | 6 +-- .../react-dev-utils/formatWebpackMessages.js | 6 +-- packages/react-dev-utils/getProcessForPort.js | 6 +-- packages/react-dev-utils/inquirer.js | 6 +-- packages/react-dev-utils/launchEditor.js | 6 +-- .../react-dev-utils/launchEditorEndpoint.js | 6 +-- .../noopServiceWorkerMiddleware.js | 6 +-- packages/react-dev-utils/openBrowser.js | 6 +-- .../react-dev-utils/openChrome.applescript | 6 +-- packages/react-dev-utils/package.json | 2 +- packages/react-dev-utils/printBuildError.js | 6 +-- .../printHostingInstructions.js | 6 +-- .../react-dev-utils/webpackHotDevClient.js | 6 +-- packages/react-error-overlay/package.json | 2 +- .../src/__tests__/extract-source-map.js | 6 +-- .../src/__tests__/get-source-map.js | 6 +-- .../src/__tests__/lines-around.js | 6 +-- .../src/__tests__/mapper.js | 6 +-- .../src/__tests__/parser/chrome.js | 6 +-- .../src/__tests__/parser/firefox.js | 6 +-- .../src/__tests__/parser/generic.js | 6 +-- .../src/__tests__/parser/react.js | 6 +-- .../src/__tests__/parser/safari.js | 6 +-- .../src/__tests__/script-lines.js | 6 +-- .../src/__tests__/setupJest.js | 6 +-- .../src/__tests__/stack-frame.js | 6 +-- .../src/__tests__/unmapper.js | 6 +-- .../src/components/CloseButton.js | 6 +-- .../src/components/CodeBlock.js | 6 +-- .../src/components/Collapsible.js | 6 +-- .../src/components/ErrorOverlay.js | 6 +-- .../src/components/Footer.js | 6 +-- .../src/components/Header.js | 6 +-- .../src/components/NavigationBar.js | 6 +-- .../src/containers/CompileErrorContainer.js | 6 +-- .../src/containers/RuntimeError.js | 6 +-- .../src/containers/RuntimeErrorContainer.js | 6 +-- .../src/containers/StackFrame.js | 6 +-- .../src/containers/StackFrameCodeBlock.js | 6 +-- .../src/containers/StackTrace.js | 6 +-- .../src/effects/proxyConsole.js | 6 +-- .../src/effects/stackTraceLimit.js | 6 +-- .../src/effects/unhandledError.js | 6 +-- .../src/effects/unhandledRejection.js | 6 +-- packages/react-error-overlay/src/index.js | 6 +-- .../src/listenToRuntimeErrors.js | 6 +-- packages/react-error-overlay/src/styles.js | 6 +-- .../src/utils/dom/absolutifyCaret.js | 6 +-- .../react-error-overlay/src/utils/dom/css.js | 6 +-- .../src/utils/generateAnsiHTML.js | 6 +-- .../src/utils/getLinesAround.js | 6 +-- .../src/utils/getPrettyURL.js | 6 +-- .../src/utils/getSourceMap.js | 6 +-- .../src/utils/getStackFrames.js | 6 +-- .../src/utils/isBultinErrorName.js | 6 +-- .../src/utils/isInternalFile.js | 6 +-- .../react-error-overlay/src/utils/mapper.js | 6 +-- .../react-error-overlay/src/utils/parser.js | 6 +-- .../src/utils/stack-frame.js | 6 +-- .../react-error-overlay/src/utils/unmapper.js | 6 +-- .../react-error-overlay/src/utils/warnings.js | 6 +-- packages/react-scripts/bin/react-scripts.js | 6 +-- packages/react-scripts/config/env.js | 6 +-- .../config/jest/babelTransform.js | 7 ++- .../react-scripts/config/jest/cssTransform.js | 7 ++- .../config/jest/fileTransform.js | 7 ++- packages/react-scripts/config/paths.js | 6 +-- packages/react-scripts/config/polyfills.js | 6 +-- .../config/webpack.config.dev.js | 6 +-- .../config/webpack.config.prod.js | 6 +-- .../config/webpackDevServer.config.js | 6 +-- .../kitchensink/integration/env.test.js | 6 +-- .../kitchensink/integration/initDOM.js | 6 +-- .../kitchensink/integration/syntax.test.js | 6 +-- .../kitchensink/integration/webpack.test.js | 6 +-- .../fixtures/kitchensink/src/App.js | 6 +-- .../fixtures/kitchensink/src/absoluteLoad.js | 6 +-- .../src/features/env/FileEnvVariables.js | 6 +-- .../src/features/env/FileEnvVariables.test.js | 6 +-- .../kitchensink/src/features/env/NodePath.js | 6 +-- .../src/features/env/NodePath.test.js | 6 +-- .../kitchensink/src/features/env/PublicUrl.js | 6 +-- .../src/features/env/PublicUrl.test.js | 6 +-- .../src/features/env/ShellEnvVariables.js | 6 +-- .../features/env/ShellEnvVariables.test.js | 6 +-- .../src/features/syntax/ArrayDestructuring.js | 6 +-- .../syntax/ArrayDestructuring.test.js | 6 +-- .../src/features/syntax/ArraySpread.js | 6 +-- .../src/features/syntax/ArraySpread.test.js | 6 +-- .../src/features/syntax/AsyncAwait.js | 6 +-- .../src/features/syntax/AsyncAwait.test.js | 6 +-- .../src/features/syntax/ClassProperties.js | 6 +-- .../features/syntax/ClassProperties.test.js | 6 +-- .../src/features/syntax/ComputedProperties.js | 6 +-- .../syntax/ComputedProperties.test.js | 6 +-- .../features/syntax/CustomInterpolation.js | 6 +-- .../syntax/CustomInterpolation.test.js | 6 +-- .../src/features/syntax/DefaultParameters.js | 6 +-- .../features/syntax/DefaultParameters.test.js | 6 +-- .../features/syntax/DestructuringAndAwait.js | 6 +-- .../syntax/DestructuringAndAwait.test.js | 6 +-- .../src/features/syntax/Generators.js | 6 +-- .../src/features/syntax/Generators.test.js | 6 +-- .../features/syntax/ObjectDestructuring.js | 6 +-- .../syntax/ObjectDestructuring.test.js | 6 +-- .../src/features/syntax/ObjectSpread.js | 6 +-- .../src/features/syntax/ObjectSpread.test.js | 6 +-- .../src/features/syntax/Promises.js | 6 +-- .../src/features/syntax/Promises.test.js | 6 +-- .../src/features/syntax/RestAndDefault.js | 6 +-- .../features/syntax/RestAndDefault.test.js | 6 +-- .../src/features/syntax/RestParameters.js | 6 +-- .../features/syntax/RestParameters.test.js | 6 +-- .../features/syntax/TemplateInterpolation.js | 6 +-- .../syntax/TemplateInterpolation.test.js | 6 +-- .../src/features/webpack/CssInclusion.js | 6 +-- .../src/features/webpack/CssInclusion.test.js | 6 +-- .../src/features/webpack/ImageInclusion.js | 6 +-- .../features/webpack/ImageInclusion.test.js | 6 +-- .../src/features/webpack/JsonInclusion.js | 6 +-- .../features/webpack/JsonInclusion.test.js | 6 +-- .../src/features/webpack/LinkedModules.js | 6 +-- .../features/webpack/LinkedModules.test.js | 6 +-- .../src/features/webpack/NoExtInclusion.js | 6 +-- .../features/webpack/NoExtInclusion.test.js | 6 +-- .../src/features/webpack/SvgInclusion.js | 6 +-- .../src/features/webpack/SvgInclusion.test.js | 6 +-- .../features/webpack/UnknownExtInclusion.js | 6 +-- .../webpack/UnknownExtInclusion.test.js | 6 +-- .../fixtures/kitchensink/src/index.js | 6 +-- .../fixtures/kitchensink/src/subfolder/lol.js | 6 +-- packages/react-scripts/package.json | 2 +- packages/react-scripts/scripts/build.js | 6 +-- packages/react-scripts/scripts/eject.js | 6 +-- packages/react-scripts/scripts/init.js | 6 +-- packages/react-scripts/scripts/start.js | 6 +-- packages/react-scripts/scripts/test.js | 6 +-- .../scripts/utils/createJestConfig.js | 6 +-- tasks/cra.sh | 8 ++-- tasks/e2e-installs.sh | 8 ++-- tasks/e2e-kitchensink.sh | 8 ++-- tasks/e2e-simple.sh | 8 ++-- tasks/release.sh | 8 ++-- tasks/replace-own-deps.js | 6 +-- 162 files changed, 339 insertions(+), 686 deletions(-) delete mode 100644 PATENTS diff --git a/LICENSE b/LICENSE index a6b451216..188fb2b0b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,30 +1,21 @@ -BSD License +MIT License -For create-react-app software +Copyright (c) 2013-present, Facebook, Inc. -Copyright (c) 2016-present, Facebook, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name Facebook nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/PATENTS b/PATENTS deleted file mode 100644 index ca1e727b7..000000000 --- a/PATENTS +++ /dev/null @@ -1,33 +0,0 @@ -Additional Grant of Patent Rights Version 2 - -"Software" means the create-react-app software distributed by Facebook, Inc. - -Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software -("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable -(subject to the termination provision below) license under any Necessary -Claims, to make, have made, use, sell, offer to sell, import, and otherwise -transfer the Software. For avoidance of doubt, no license is granted under -Facebook’s rights in any patent claims that are infringed by (i) modifications -to the Software made by you or any third party or (ii) the Software in -combination with any software or other technology. - -The license granted hereunder will terminate, automatically and without notice, -if you (or any of your subsidiaries, corporate affiliates or agents) initiate -directly or indirectly, or take a direct financial interest in, any Patent -Assertion: (i) against Facebook or any of its subsidiaries or corporate -affiliates, (ii) against any party if such Patent Assertion arises in whole or -in part from any software, technology, product or service of Facebook or any of -its subsidiaries or corporate affiliates, or (iii) against any party relating -to the Software. Notwithstanding the foregoing, if Facebook or any of its -subsidiaries or corporate affiliates files a lawsuit alleging patent -infringement against you in the first instance, and you respond by filing a -patent infringement counterclaim in that lawsuit against that party that is -unrelated to the Software, the license granted hereunder will not terminate -under section (i) of this paragraph due to such counterclaim. - -A "Necessary Claim" is a claim of a patent owned by Facebook that is -necessarily infringed by the Software standing alone. - -A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, -or contributory infringement or inducement to infringe any patent, including a -cross-claim or counterclaim. diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index f6102dc05..0d961af6f 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index dce674298..1149ba49a 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -3,7 +3,7 @@ "version": "3.0.2", "description": "Babel preset used by Create React App", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 594f81154..161beab50 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js index 4df90f53f..a09363660 100755 --- a/packages/create-react-app/index.js +++ b/packages/create-react-app/index.js @@ -2,11 +2,9 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 42ee3497e..3dfe8ef47 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -6,7 +6,7 @@ ], "description": "Create React apps with no build configuration.", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "engines": { "node": ">=4" }, diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 4e94e650c..adcdb86bc 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 375c9f54b..e5eb50a19 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -3,7 +3,7 @@ "version": "2.0.0", "description": "ESLint configuration used by Create React App", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, diff --git a/packages/react-dev-utils/FileSizeReporter.js b/packages/react-dev-utils/FileSizeReporter.js index f25e47378..01ce52c6b 100644 --- a/packages/react-dev-utils/FileSizeReporter.js +++ b/packages/react-dev-utils/FileSizeReporter.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/InterpolateHtmlPlugin.js b/packages/react-dev-utils/InterpolateHtmlPlugin.js index ac1d3e996..9233bdefa 100644 --- a/packages/react-dev-utils/InterpolateHtmlPlugin.js +++ b/packages/react-dev-utils/InterpolateHtmlPlugin.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // This Webpack plugin lets us interpolate custom variables into `index.html`. diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js index 3a10904d3..101a30a1f 100644 --- a/packages/react-dev-utils/ModuleScopePlugin.js +++ b/packages/react-dev-utils/ModuleScopePlugin.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js index 91b089c05..ae11cdc90 100644 --- a/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js +++ b/packages/react-dev-utils/WatchMissingNodeModulesPlugin.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ // This Webpack plugin ensures `npm install <library>` forces a project rebuild. diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 1cd060592..f19582e12 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/checkRequiredFiles.js b/packages/react-dev-utils/checkRequiredFiles.js index 55139b0b8..9799cf6b5 100644 --- a/packages/react-dev-utils/checkRequiredFiles.js +++ b/packages/react-dev-utils/checkRequiredFiles.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/clearConsole.js b/packages/react-dev-utils/clearConsole.js index 05ab28c44..6e3b3c9ce 100644 --- a/packages/react-dev-utils/clearConsole.js +++ b/packages/react-dev-utils/clearConsole.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/crossSpawn.js b/packages/react-dev-utils/crossSpawn.js index 8424dcf09..b772086f2 100644 --- a/packages/react-dev-utils/crossSpawn.js +++ b/packages/react-dev-utils/crossSpawn.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/errorOverlayMiddleware.js b/packages/react-dev-utils/errorOverlayMiddleware.js index b2a857d6e..b756b0ef6 100644 --- a/packages/react-dev-utils/errorOverlayMiddleware.js +++ b/packages/react-dev-utils/errorOverlayMiddleware.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/eslintFormatter.js b/packages/react-dev-utils/eslintFormatter.js index b7756b7a2..a269ccc82 100644 --- a/packages/react-dev-utils/eslintFormatter.js +++ b/packages/react-dev-utils/eslintFormatter.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/formatWebpackMessages.js b/packages/react-dev-utils/formatWebpackMessages.js index 1f22a0059..7aea5582c 100644 --- a/packages/react-dev-utils/formatWebpackMessages.js +++ b/packages/react-dev-utils/formatWebpackMessages.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index 73a445f5b..c91959a37 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/inquirer.js b/packages/react-dev-utils/inquirer.js index 9dbc08026..6b8eca9ea 100644 --- a/packages/react-dev-utils/inquirer.js +++ b/packages/react-dev-utils/inquirer.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/launchEditor.js b/packages/react-dev-utils/launchEditor.js index a6f7226ef..ba16827e6 100644 --- a/packages/react-dev-utils/launchEditor.js +++ b/packages/react-dev-utils/launchEditor.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/launchEditorEndpoint.js b/packages/react-dev-utils/launchEditorEndpoint.js index e21870be9..99b5935d9 100644 --- a/packages/react-dev-utils/launchEditorEndpoint.js +++ b/packages/react-dev-utils/launchEditorEndpoint.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/noopServiceWorkerMiddleware.js b/packages/react-dev-utils/noopServiceWorkerMiddleware.js index b6cee7350..41566dd7f 100644 --- a/packages/react-dev-utils/noopServiceWorkerMiddleware.js +++ b/packages/react-dev-utils/noopServiceWorkerMiddleware.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/openBrowser.js b/packages/react-dev-utils/openBrowser.js index 4f5700125..cb9f32c6a 100644 --- a/packages/react-dev-utils/openBrowser.js +++ b/packages/react-dev-utils/openBrowser.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/openChrome.applescript b/packages/react-dev-utils/openChrome.applescript index 0f5602721..3b1b5a29d 100644 --- a/packages/react-dev-utils/openChrome.applescript +++ b/packages/react-dev-utils/openChrome.applescript @@ -1,10 +1,8 @@ (* Copyright (c) 2015-present, Facebook, Inc. -All rights reserved. -This source code is licensed under the BSD-style license found in the --- LICENSE file in the root directory of this source tree. An additional grant -of patent rights can be found in the PATENTS file in the same directory. +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. *) property targetTab: null diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index ec8b44292..5ac2aeae5 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -3,7 +3,7 @@ "version": "4.0.1", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, diff --git a/packages/react-dev-utils/printBuildError.js b/packages/react-dev-utils/printBuildError.js index eadfff471..26e291356 100644 --- a/packages/react-dev-utils/printBuildError.js +++ b/packages/react-dev-utils/printBuildError.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/printHostingInstructions.js b/packages/react-dev-utils/printHostingInstructions.js index 2ef25767a..4a080dba2 100644 --- a/packages/react-dev-utils/printHostingInstructions.js +++ b/packages/react-dev-utils/printHostingInstructions.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index b0508dc4d..611fc6ba0 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 11ee85894..5c8e1b7b2 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -11,7 +11,7 @@ "build:prod": "rimraf lib/ && cross-env NODE_ENV=production babel src/ -d lib/" }, "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "bugs": { "url": "https://github.com/facebookincubator/create-react-app/issues" }, diff --git a/packages/react-error-overlay/src/__tests__/extract-source-map.js b/packages/react-error-overlay/src/__tests__/extract-source-map.js index 85c30accd..b47f5ab5f 100644 --- a/packages/react-error-overlay/src/__tests__/extract-source-map.js +++ b/packages/react-error-overlay/src/__tests__/extract-source-map.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { extractSourceMapUrl } from '../utils/getSourceMap'; diff --git a/packages/react-error-overlay/src/__tests__/get-source-map.js b/packages/react-error-overlay/src/__tests__/get-source-map.js index 299069266..27c6d5f78 100644 --- a/packages/react-error-overlay/src/__tests__/get-source-map.js +++ b/packages/react-error-overlay/src/__tests__/get-source-map.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { getSourceMap } from '../utils/getSourceMap'; diff --git a/packages/react-error-overlay/src/__tests__/lines-around.js b/packages/react-error-overlay/src/__tests__/lines-around.js index 0317bd47b..64595df30 100644 --- a/packages/react-error-overlay/src/__tests__/lines-around.js +++ b/packages/react-error-overlay/src/__tests__/lines-around.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { getLinesAround } from '../utils/getLinesAround'; diff --git a/packages/react-error-overlay/src/__tests__/mapper.js b/packages/react-error-overlay/src/__tests__/mapper.js index 169bf6c59..bd733487f 100644 --- a/packages/react-error-overlay/src/__tests__/mapper.js +++ b/packages/react-error-overlay/src/__tests__/mapper.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { map } from '../utils/mapper'; diff --git a/packages/react-error-overlay/src/__tests__/parser/chrome.js b/packages/react-error-overlay/src/__tests__/parser/chrome.js index caf95a6fc..651f584cc 100644 --- a/packages/react-error-overlay/src/__tests__/parser/chrome.js +++ b/packages/react-error-overlay/src/__tests__/parser/chrome.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/firefox.js b/packages/react-error-overlay/src/__tests__/parser/firefox.js index 4f1d19ac2..8aa0f4d6c 100644 --- a/packages/react-error-overlay/src/__tests__/parser/firefox.js +++ b/packages/react-error-overlay/src/__tests__/parser/firefox.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/generic.js b/packages/react-error-overlay/src/__tests__/parser/generic.js index b58c537d3..32bade931 100644 --- a/packages/react-error-overlay/src/__tests__/parser/generic.js +++ b/packages/react-error-overlay/src/__tests__/parser/generic.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/react.js b/packages/react-error-overlay/src/__tests__/parser/react.js index 907fae239..e7dcc07cb 100644 --- a/packages/react-error-overlay/src/__tests__/parser/react.js +++ b/packages/react-error-overlay/src/__tests__/parser/react.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/parser/safari.js b/packages/react-error-overlay/src/__tests__/parser/safari.js index 69ecf6c78..74d169d99 100644 --- a/packages/react-error-overlay/src/__tests__/parser/safari.js +++ b/packages/react-error-overlay/src/__tests__/parser/safari.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { parse } from '../../utils/parser'; diff --git a/packages/react-error-overlay/src/__tests__/script-lines.js b/packages/react-error-overlay/src/__tests__/script-lines.js index e26e8d4f8..ec5ff0b0f 100644 --- a/packages/react-error-overlay/src/__tests__/script-lines.js +++ b/packages/react-error-overlay/src/__tests__/script-lines.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { ScriptLine } from '../utils/stack-frame'; diff --git a/packages/react-error-overlay/src/__tests__/setupJest.js b/packages/react-error-overlay/src/__tests__/setupJest.js index 496826f2c..91757b455 100644 --- a/packages/react-error-overlay/src/__tests__/setupJest.js +++ b/packages/react-error-overlay/src/__tests__/setupJest.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ global.fetch = require('jest-fetch-mock'); diff --git a/packages/react-error-overlay/src/__tests__/stack-frame.js b/packages/react-error-overlay/src/__tests__/stack-frame.js index 5a015260a..af1f05e0a 100644 --- a/packages/react-error-overlay/src/__tests__/stack-frame.js +++ b/packages/react-error-overlay/src/__tests__/stack-frame.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { StackFrame } from '../utils/stack-frame'; diff --git a/packages/react-error-overlay/src/__tests__/unmapper.js b/packages/react-error-overlay/src/__tests__/unmapper.js index fd162ccac..c9dc32a53 100644 --- a/packages/react-error-overlay/src/__tests__/unmapper.js +++ b/packages/react-error-overlay/src/__tests__/unmapper.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { unmap } from '../utils/unmapper'; diff --git a/packages/react-error-overlay/src/components/CloseButton.js b/packages/react-error-overlay/src/components/CloseButton.js index 503b1198c..ed7006ea3 100644 --- a/packages/react-error-overlay/src/components/CloseButton.js +++ b/packages/react-error-overlay/src/components/CloseButton.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/CodeBlock.js b/packages/react-error-overlay/src/components/CodeBlock.js index 478f0111b..3165bb3b0 100644 --- a/packages/react-error-overlay/src/components/CodeBlock.js +++ b/packages/react-error-overlay/src/components/CodeBlock.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/Collapsible.js b/packages/react-error-overlay/src/components/Collapsible.js index 095428813..016f3c7a7 100644 --- a/packages/react-error-overlay/src/components/Collapsible.js +++ b/packages/react-error-overlay/src/components/Collapsible.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/ErrorOverlay.js b/packages/react-error-overlay/src/components/ErrorOverlay.js index 2f706f242..da4154002 100644 --- a/packages/react-error-overlay/src/components/ErrorOverlay.js +++ b/packages/react-error-overlay/src/components/ErrorOverlay.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/Footer.js b/packages/react-error-overlay/src/components/Footer.js index 68eb84656..bef53f6c1 100644 --- a/packages/react-error-overlay/src/components/Footer.js +++ b/packages/react-error-overlay/src/components/Footer.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/Header.js b/packages/react-error-overlay/src/components/Header.js index 227162343..7b45ceef5 100644 --- a/packages/react-error-overlay/src/components/Header.js +++ b/packages/react-error-overlay/src/components/Header.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/components/NavigationBar.js b/packages/react-error-overlay/src/components/NavigationBar.js index 4eba743ce..6fb7b14ab 100644 --- a/packages/react-error-overlay/src/components/NavigationBar.js +++ b/packages/react-error-overlay/src/components/NavigationBar.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js index 9eb8c029b..5d491a9d4 100644 --- a/packages/react-error-overlay/src/containers/CompileErrorContainer.js +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/containers/RuntimeError.js b/packages/react-error-overlay/src/containers/RuntimeError.js index b21360d5e..c247ba52a 100644 --- a/packages/react-error-overlay/src/containers/RuntimeError.js +++ b/packages/react-error-overlay/src/containers/RuntimeError.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js index dafd2af27..80585f051 100644 --- a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js +++ b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/containers/StackFrame.js b/packages/react-error-overlay/src/containers/StackFrame.js index 991662356..f16ae6435 100644 --- a/packages/react-error-overlay/src/containers/StackFrame.js +++ b/packages/react-error-overlay/src/containers/StackFrame.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js index 58a2c0d53..9bd36e019 100644 --- a/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js +++ b/packages/react-error-overlay/src/containers/StackFrameCodeBlock.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/containers/StackTrace.js b/packages/react-error-overlay/src/containers/StackTrace.js index 8d4a487dc..0be342ddc 100644 --- a/packages/react-error-overlay/src/containers/StackTrace.js +++ b/packages/react-error-overlay/src/containers/StackTrace.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/effects/proxyConsole.js b/packages/react-error-overlay/src/effects/proxyConsole.js index ec50ae2ca..db270e9dd 100644 --- a/packages/react-error-overlay/src/effects/proxyConsole.js +++ b/packages/react-error-overlay/src/effects/proxyConsole.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/effects/stackTraceLimit.js b/packages/react-error-overlay/src/effects/stackTraceLimit.js index ea109cd98..a30ba856f 100644 --- a/packages/react-error-overlay/src/effects/stackTraceLimit.js +++ b/packages/react-error-overlay/src/effects/stackTraceLimit.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/effects/unhandledError.js b/packages/react-error-overlay/src/effects/unhandledError.js index 12f256c0e..d34253f75 100644 --- a/packages/react-error-overlay/src/effects/unhandledError.js +++ b/packages/react-error-overlay/src/effects/unhandledError.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/effects/unhandledRejection.js b/packages/react-error-overlay/src/effects/unhandledRejection.js index 638729e8d..e7292e9a0 100644 --- a/packages/react-error-overlay/src/effects/unhandledRejection.js +++ b/packages/react-error-overlay/src/effects/unhandledRejection.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index d44976713..23f9e7838 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/listenToRuntimeErrors.js b/packages/react-error-overlay/src/listenToRuntimeErrors.js index 341200afa..8146b377c 100644 --- a/packages/react-error-overlay/src/listenToRuntimeErrors.js +++ b/packages/react-error-overlay/src/listenToRuntimeErrors.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/styles.js b/packages/react-error-overlay/src/styles.js index d6557c5d9..077406285 100644 --- a/packages/react-error-overlay/src/styles.js +++ b/packages/react-error-overlay/src/styles.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/dom/absolutifyCaret.js b/packages/react-error-overlay/src/utils/dom/absolutifyCaret.js index d92167530..f0f87e495 100644 --- a/packages/react-error-overlay/src/utils/dom/absolutifyCaret.js +++ b/packages/react-error-overlay/src/utils/dom/absolutifyCaret.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/dom/css.js b/packages/react-error-overlay/src/utils/dom/css.js index 60b214b07..4f2dbf53c 100644 --- a/packages/react-error-overlay/src/utils/dom/css.js +++ b/packages/react-error-overlay/src/utils/dom/css.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/generateAnsiHTML.js b/packages/react-error-overlay/src/utils/generateAnsiHTML.js index 509daddc2..306165e85 100644 --- a/packages/react-error-overlay/src/utils/generateAnsiHTML.js +++ b/packages/react-error-overlay/src/utils/generateAnsiHTML.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/getLinesAround.js b/packages/react-error-overlay/src/utils/getLinesAround.js index 7cb2ea5c5..4a7ffc341 100644 --- a/packages/react-error-overlay/src/utils/getLinesAround.js +++ b/packages/react-error-overlay/src/utils/getLinesAround.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/getPrettyURL.js b/packages/react-error-overlay/src/utils/getPrettyURL.js index 47b834d08..1aa5dc779 100644 --- a/packages/react-error-overlay/src/utils/getPrettyURL.js +++ b/packages/react-error-overlay/src/utils/getPrettyURL.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/getSourceMap.js b/packages/react-error-overlay/src/utils/getSourceMap.js index 5c9e3aa9e..269f0bb71 100644 --- a/packages/react-error-overlay/src/utils/getSourceMap.js +++ b/packages/react-error-overlay/src/utils/getSourceMap.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/getStackFrames.js b/packages/react-error-overlay/src/utils/getStackFrames.js index e5a407310..9721e316c 100644 --- a/packages/react-error-overlay/src/utils/getStackFrames.js +++ b/packages/react-error-overlay/src/utils/getStackFrames.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/isBultinErrorName.js b/packages/react-error-overlay/src/utils/isBultinErrorName.js index cf732b838..570f72cfe 100644 --- a/packages/react-error-overlay/src/utils/isBultinErrorName.js +++ b/packages/react-error-overlay/src/utils/isBultinErrorName.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/isInternalFile.js b/packages/react-error-overlay/src/utils/isInternalFile.js index c78bbe3ed..97dbeaae5 100644 --- a/packages/react-error-overlay/src/utils/isInternalFile.js +++ b/packages/react-error-overlay/src/utils/isInternalFile.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/mapper.js b/packages/react-error-overlay/src/utils/mapper.js index 656c216c1..92407be53 100644 --- a/packages/react-error-overlay/src/utils/mapper.js +++ b/packages/react-error-overlay/src/utils/mapper.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/parser.js b/packages/react-error-overlay/src/utils/parser.js index 6bc65ed8d..2e8afaa8b 100644 --- a/packages/react-error-overlay/src/utils/parser.js +++ b/packages/react-error-overlay/src/utils/parser.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/stack-frame.js b/packages/react-error-overlay/src/utils/stack-frame.js index 49f9da7fa..41defc061 100644 --- a/packages/react-error-overlay/src/utils/stack-frame.js +++ b/packages/react-error-overlay/src/utils/stack-frame.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/unmapper.js b/packages/react-error-overlay/src/utils/unmapper.js index 40f4528c0..c61fad4fb 100644 --- a/packages/react-error-overlay/src/utils/unmapper.js +++ b/packages/react-error-overlay/src/utils/unmapper.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-error-overlay/src/utils/warnings.js b/packages/react-error-overlay/src/utils/warnings.js index 1cdb53dc0..4a99190ac 100644 --- a/packages/react-error-overlay/src/utils/warnings.js +++ b/packages/react-error-overlay/src/utils/warnings.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ /* @flow */ diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index a8f37e813..9de034ff0 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -1,11 +1,9 @@ #!/usr/bin/env node /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-scripts/config/env.js b/packages/react-scripts/config/env.js index ebef79ed9..fa42747f6 100644 --- a/packages/react-scripts/config/env.js +++ b/packages/react-scripts/config/env.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/config/jest/babelTransform.js b/packages/react-scripts/config/jest/babelTransform.js index bee55b1b1..02742e90c 100644 --- a/packages/react-scripts/config/jest/babelTransform.js +++ b/packages/react-scripts/config/jest/babelTransform.js @@ -1,10 +1,9 @@ // @remove-file-on-eject /** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-scripts/config/jest/cssTransform.js b/packages/react-scripts/config/jest/cssTransform.js index 0a9849f1f..99a8cb269 100644 --- a/packages/react-scripts/config/jest/cssTransform.js +++ b/packages/react-scripts/config/jest/cssTransform.js @@ -1,10 +1,9 @@ // @remove-on-eject-begin /** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/config/jest/fileTransform.js b/packages/react-scripts/config/jest/fileTransform.js index 89027bdc7..8f9b843ab 100644 --- a/packages/react-scripts/config/jest/fileTransform.js +++ b/packages/react-scripts/config/jest/fileTransform.js @@ -1,10 +1,9 @@ // @remove-on-eject-begin /** - * Copyright (c) 2014-present, Facebook, Inc. All rights reserved. + * Copyright (c) 2014-present, Facebook, Inc. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index 94e399f0f..718b898bb 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/config/polyfills.js b/packages/react-scripts/config/polyfills.js index 14031a168..673fb8399 100644 --- a/packages/react-scripts/config/polyfills.js +++ b/packages/react-scripts/config/polyfills.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 6417578f4..44669e605 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 81121a949..ef4ea1bc0 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index 9c3889aba..25b42d0de 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js index a7d4ff2a2..5138bc513 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/env.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/env.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { expect } from 'chai'; diff --git a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js index b865b5641..3d0eb7a1c 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/initDOM.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ const fs = require('fs'); diff --git a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js index fc2a717be..82e2c9e0d 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/syntax.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { expect } from 'chai'; diff --git a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js index e3845e79e..1fe5c9f64 100644 --- a/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js +++ b/packages/react-scripts/fixtures/kitchensink/integration/webpack.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import { expect } from 'chai'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/App.js b/packages/react-scripts/fixtures/kitchensink/src/App.js index cb342b062..5fe13accf 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/App.js +++ b/packages/react-scripts/fixtures/kitchensink/src/App.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component, createElement } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/absoluteLoad.js b/packages/react-scripts/fixtures/kitchensink/src/absoluteLoad.js index 0d01bc0a2..5c4f7842e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/absoluteLoad.js +++ b/packages/react-scripts/fixtures/kitchensink/src/absoluteLoad.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ export default () => [ diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js index 41c472e03..c601d2efd 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.test.js index 5a0fed4c6..8c628d215 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/FileEnvVariables.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js index a039cefed..f14c5d24f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js index 7e076dade..1de025d2f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/NodePath.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js index 4ea9b96f8..f3df96a35 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.test.js index c9e1be0e9..bda2e051f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/PublicUrl.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js index 8449097d6..2543779ac 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.test.js index 137076975..c1f5001cd 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/env/ShellEnvVariables.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js index be6c39f90..be605a01c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js index 42dde0f1c..e6ab4c9f2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArrayDestructuring.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js index eb7886aa4..be696ffa2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js index 9ed7633ea..4827bc222 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ArraySpread.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js index a60633460..ae135133b 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js index 027139817..b056cb705 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/AsyncAwait.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js index ed96d4f8c..b1a063cf0 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js index 5b038e76d..3ba3074a3 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ClassProperties.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js index 38dc797a8..ad27b8bb2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js index 91b697fe0..0442a6bc1 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ComputedProperties.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js index a6c9b69de..9d894de13 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js index ac468db76..854f3cebd 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/CustomInterpolation.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js index 0a519eba8..d86a989cc 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js index 26d5184eb..71c255200 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DefaultParameters.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js index d44f4cf22..a69167d44 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js index c7d74d801..ec9a9a9e1 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/DestructuringAndAwait.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js index 2fe473d13..7ad8fc8fa 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js index 3bbe2d4f7..5b59d6664 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Generators.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js index 2994d14af..be519175f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js index 503b2cb11..ea2b4bdc7 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectDestructuring.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js index 7349be2f9..3c62e38c9 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js index 09a92ce05..0f2aefd4e 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/ObjectSpread.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js index e626de5d8..f7fd34f0a 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js index 88ba04fe3..ee2ce709f 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/Promises.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js index dc2a1563a..3f22cc816 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js index e48b7dc59..36fc91d4c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestAndDefault.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js index e703a33cc..8e8c0b8b2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js index c1eb90e0d..9be970124 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/RestParameters.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js index 5aba5da62..9788ee5dc 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React, { Component } from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js index ff32baaed..10082088d 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/syntax/TemplateInterpolation.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.js index ab7c9a2d8..868a886a2 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.test.js index e315ee33b..7d85a6024 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/CssInclusion.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js index a6ca7aaa8..1a57bc36d 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.test.js index 042d2da30..ffe9cafbc 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/ImageInclusion.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js index e81f76397..653c3e744 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.test.js index ee150f629..42f458df1 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/JsonInclusion.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js index de8a5e4ab..98ead2dec 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.test.js index aa1e911ae..b850c2aa8 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/LinkedModules.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js index be22a6c9f..0eb794244 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.test.js index a08b5d21b..0d83b5f0c 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/NoExtInclusion.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.js index 8876021ae..c519423e6 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.test.js index 585c6c19d..4b6a9a686 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/SvgInclusion.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js index 5cae4516a..bdb81f178 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.test.js b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.test.js index 73a8016e1..538240dae 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.test.js +++ b/packages/react-scripts/fixtures/kitchensink/src/features/webpack/UnknownExtInclusion.test.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/index.js b/packages/react-scripts/fixtures/kitchensink/src/index.js index 46fb0dd2e..5268eacec 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/index.js +++ b/packages/react-scripts/fixtures/kitchensink/src/index.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ import React from 'react'; diff --git a/packages/react-scripts/fixtures/kitchensink/src/subfolder/lol.js b/packages/react-scripts/fixtures/kitchensink/src/subfolder/lol.js index 979cb3e72..7eecce497 100644 --- a/packages/react-scripts/fixtures/kitchensink/src/subfolder/lol.js +++ b/packages/react-scripts/fixtures/kitchensink/src/subfolder/lol.js @@ -1,10 +1,8 @@ /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ module.exports = function() { diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 9905cb5aa..38c757d71 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -3,7 +3,7 @@ "version": "1.0.13", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "engines": { "node": ">=6" }, diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index 7691bfd52..930897008 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 8f6af4f47..2b859694f 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -1,11 +1,9 @@ // @remove-file-on-eject /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index 0a62cc4a9..b283bad6e 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -1,11 +1,9 @@ // @remove-file-on-eject /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index b86943b4d..8df052d3b 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/scripts/test.js b/packages/react-scripts/scripts/test.js index e9adb48f0..b30113fe6 100644 --- a/packages/react-scripts/scripts/test.js +++ b/packages/react-scripts/scripts/test.js @@ -1,11 +1,9 @@ // @remove-on-eject-begin /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * 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'; diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index bc4ebf822..3e819b68e 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -1,11 +1,9 @@ // @remove-file-on-eject /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; diff --git a/tasks/cra.sh b/tasks/cra.sh index c94559406..696db3f96 100755 --- a/tasks/cra.sh +++ b/tasks/cra.sh @@ -1,10 +1,8 @@ #!/bin/bash # Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. + +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. # ****************************************************************************** # This creates an app with the global CLI and `react-scripts` from the source. diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 588642632..34d030746 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -1,10 +1,8 @@ #!/bin/bash # Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. + +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. # ****************************************************************************** # This is an end-to-end test intended to run on CI. diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 8ef0bc23d..944380359 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -1,10 +1,8 @@ #!/bin/bash # Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. + +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. # ****************************************************************************** # This is an end-to-end kitchensink test intended to run on CI. diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 48d705eef..2fdca687a 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -1,10 +1,8 @@ #!/bin/bash # Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. + +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. # ****************************************************************************** # This is an end-to-end test intended to run on CI. diff --git a/tasks/release.sh b/tasks/release.sh index d72a2bb44..c794cf2cb 100755 --- a/tasks/release.sh +++ b/tasks/release.sh @@ -1,10 +1,8 @@ #!/bin/bash # Copyright (c) 2015-present, Facebook, Inc. -# All rights reserved. -# -# This source code is licensed under the BSD-style license found in the -# LICENSE file in the root directory of this source tree. An additional grant -# of patent rights can be found in the PATENTS file in the same directory. + +This source code is licensed under the MIT license found in the +LICENSE file in the root directory of this source tree. # ****************************************************************************** # This releases an update to the `react-scripts` package. diff --git a/tasks/replace-own-deps.js b/tasks/replace-own-deps.js index 23a3f4a01..9178b0102 100755 --- a/tasks/replace-own-deps.js +++ b/tasks/replace-own-deps.js @@ -1,11 +1,9 @@ #!/usr/bin/env node /** * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. */ 'use strict'; From 9e966b4cdb7daa240bd625895fe9ae8022ad7881 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 26 Sep 2017 20:11:50 -0400 Subject: [PATCH 179/265] Changelog for 1.0.14 --- CHANGELOG.md | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a77c54b2..21f50c8e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,88 @@ +## 1.0.14 (September 26, 2017) + +#### :bug: Bug Fix + +* `react-dev-utils` + + * [#3098](https://github.com/facebookincubator/create-react-app/pull/3098) Always reload the page on next compile after a runtime error. ([@Timer](https://github.com/Timer)) + +* `react-error-overlay` + + * [#3079](https://github.com/facebookincubator/create-react-app/pull/3079) Fix code context on Windows. ([@Timer](https://github.com/Timer)) + +#### :nail_care: Enhancement + +* `react-dev-utils` + + * [#3077](https://github.com/facebookincubator/create-react-app/pull/3077) Auto-detect running editor on Linux for error overlay. ([@gulderov](https://github.com/gulderov)) + + * [#3131](https://github.com/facebookincubator/create-react-app/pull/3131) Display process pid in already running message. ([@Pajn](https://github.com/Pajn)) + +#### :memo: Documentation + +* Other + + * [#3163](https://github.com/facebookincubator/create-react-app/pull/3163) Add link to active CSS modules discussion. ([@NeekSandhu](https://github.com/NeekSandhu)) + +* `react-scripts` + + * [#2908](https://github.com/facebookincubator/create-react-app/pull/2908) Note that class fields have progressed to stage 3. ([@rickbeerendonk](https://github.com/rickbeerendonk)) + + * [#3160](https://github.com/facebookincubator/create-react-app/pull/3160) Update unclear wording in webpack configuration (file loader section). ([@kristiehoward](https://github.com/kristiehoward)) + +* `eslint-config-react-app` + + * [#3072](https://github.com/facebookincubator/create-react-app/pull/3072) Update eslint versions for install instructions. ([@jdcrensh](https://github.com/jdcrensh)) + +#### :house: Internal + +* `react-scripts` + + * [#3157](https://github.com/facebookincubator/create-react-app/pull/3157) Update `webpack-dev-server` to `2.8.2`. ([@nikolas](https://github.com/nikolas)) + + * [#2989](https://github.com/facebookincubator/create-react-app/pull/2989) Update install template to match accessibility guidelines. ([@davidleger95](https://github.com/davidleger95)) + +* `react-error-overlay` + + * [#3065](https://github.com/facebookincubator/create-react-app/pull/3065) Updated `react-error-overlay` to latest Flow (`0.54.0`). ([@duvet86](https://github.com/duvet86)) + + * [#3102](https://github.com/facebookincubator/create-react-app/pull/3102) Clean target directory before compiling overlay. ([@Timer](https://github.com/Timer)) + +* `create-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts` + + * [#3058](https://github.com/facebookincubator/create-react-app/pull/3058) Re-run prettier for all files and pin the version. ([@viankakrisna](https://github.com/viankakrisna)) + + * [#3107](https://github.com/facebookincubator/create-react-app/pull/3107) Run CI on `npm@^4`. ([@viankakrisna](https://github.com/viankakrisna)) + +#### Committers: 12 + +- Ade Viankakrisna Fadlil ([viankakrisna](https://github.com/viankakrisna)) +- David Leger ([davidleger95](https://github.com/davidleger95)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Jon Crenshaw ([jdcrensh](https://github.com/jdcrensh)) +- Kristie Howard ([kristiehoward](https://github.com/kristiehoward)) +- Luca ([duvet86](https://github.com/duvet86)) +- Neek Sandhu ([NeekSandhu](https://github.com/NeekSandhu)) +- Nik Nyby ([nikolas](https://github.com/nikolas)) +- Rasmus Eneman ([Pajn](https://github.com/Pajn)) +- Rick Beerendonk ([rickbeerendonk](https://github.com/rickbeerendonk)) +- Sophie Alpert ([sophiebits](https://github.com/sophiebits)) +- [gulderov](https://github.com/gulderov) + +### Migrating from 1.0.13 to 1.0.14 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.14 +``` + +or + +``` +yarn add --exact react-scripts@1.0.14 +``` + ## 1.0.13 (September 2, 2017) #### :bug: Bug Fix From fedc539246a155f11db8a1b64f6928914672d9db Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 26 Sep 2017 20:15:14 -0400 Subject: [PATCH 180/265] Fix license comments --- tasks/cra.sh | 6 +++--- tasks/e2e-installs.sh | 6 +++--- tasks/e2e-kitchensink.sh | 6 +++--- tasks/e2e-simple.sh | 6 +++--- tasks/local-test.sh | 4 ++++ tasks/release.sh | 6 +++--- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/tasks/cra.sh b/tasks/cra.sh index 696db3f96..7929cdbf5 100755 --- a/tasks/cra.sh +++ b/tasks/cra.sh @@ -1,8 +1,8 @@ #!/bin/bash # 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. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. # ****************************************************************************** # This creates an app with the global CLI and `react-scripts` from the source. diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 34d030746..f352a5448 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -1,8 +1,8 @@ #!/bin/bash # 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. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. # ****************************************************************************** # This is an end-to-end test intended to run on CI. diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 944380359..3d29e8a6f 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -1,8 +1,8 @@ #!/bin/bash # 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. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. # ****************************************************************************** # This is an end-to-end kitchensink test intended to run on CI. diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 2fdca687a..2c9709546 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -1,8 +1,8 @@ #!/bin/bash # 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. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. # ****************************************************************************** # This is an end-to-end test intended to run on CI. diff --git a/tasks/local-test.sh b/tasks/local-test.sh index 42d98ffcd..8ce44b640 100755 --- a/tasks/local-test.sh +++ b/tasks/local-test.sh @@ -1,4 +1,8 @@ #!/usr/bin/env bash +# 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. function print_help { echo "Usage: ${0} [OPTIONS]" diff --git a/tasks/release.sh b/tasks/release.sh index c794cf2cb..0f11bb0d6 100755 --- a/tasks/release.sh +++ b/tasks/release.sh @@ -1,8 +1,8 @@ #!/bin/bash # 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. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. # ****************************************************************************** # This releases an update to the `react-scripts` package. From b2c0b3f74b47f0f85e3f17f7d3249b7e536cda05 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 26 Sep 2017 20:19:49 -0400 Subject: [PATCH 181/265] Publish - babel-preset-react-app@3.0.3 - create-react-app@1.4.1 - eslint-config-react-app@2.0.1 - react-dev-utils@4.1.0 - react-error-overlay@2.0.2 - react-scripts@1.0.14 --- packages/babel-preset-react-app/package.json | 2 +- packages/create-react-app/package.json | 2 +- packages/eslint-config-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 4 ++-- packages/react-error-overlay/package.json | 6 +++--- packages/react-scripts/package.json | 8 ++++---- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 1149ba49a..058d1a4af 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-react-app", - "version": "3.0.2", + "version": "3.0.3", "description": "Babel preset used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 3dfe8ef47..73400bb03 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,6 +1,6 @@ { "name": "create-react-app", - "version": "1.4.0", + "version": "1.4.1", "keywords": [ "react" ], diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index e5eb50a19..a10ef6799 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-react-app", - "version": "2.0.0", + "version": "2.0.1", "description": "ESLint configuration used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 5ac2aeae5..48e1dc49d 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "4.0.1", + "version": "4.1.0", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -47,7 +47,7 @@ "inquirer": "3.2.1", "is-root": "1.0.0", "opn": "5.1.0", - "react-error-overlay": "^2.0.1", + "react-error-overlay": "^2.0.2", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 5c8e1b7b2..7640d1c5d 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "2.0.1", + "version": "2.0.2", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { @@ -43,10 +43,10 @@ "devDependencies": { "babel-cli": "6.24.1", "babel-eslint": "7.2.3", - "babel-preset-react-app": "^3.0.2", + "babel-preset-react-app": "^3.0.3", "cross-env": "5.0.5", "eslint": "4.4.1", - "eslint-config-react-app": "^2.0.0", + "eslint-config-react-app": "^2.0.1", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 38c757d71..123f966d0 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.13", + "version": "1.0.14", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -26,14 +26,14 @@ "babel-eslint": "7.2.3", "babel-jest": "20.0.3", "babel-loader": "7.1.1", - "babel-preset-react-app": "^3.0.2", + "babel-preset-react-app": "^3.0.3", "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", "css-loader": "0.28.4", "dotenv": "4.0.0", "eslint": "4.4.1", - "eslint-config-react-app": "^2.0.0", + "eslint-config-react-app": "^2.0.1", "eslint-loader": "1.9.0", "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", @@ -48,7 +48,7 @@ "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", - "react-dev-utils": "^4.0.1", + "react-dev-utils": "^4.1.0", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", From 6e5e2279a6e0035763d5dd1ce8e7eb023ce22ae1 Mon Sep 17 00:00:00 2001 From: Mohamed Oun <mohamed3on@gmail.com> Date: Fri, 29 Sep 2017 04:18:52 +0300 Subject: [PATCH 182/265] Improve grammar in README (#3211) Also, clarify hot reloading a bit. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f7b7a199..65b6bade3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Create React apps with no build configuration. * [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App. Create React App works on macOS, Windows, and Linux.<br> -If something doesn’t work please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new). +If something doesn’t work, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new). ## Quick Overview @@ -84,7 +84,7 @@ Once the installation is done, you can run some commands inside the project fold Runs the app in development mode.<br> Open [http://localhost:3000](http://localhost:3000) to view it in the browser. -The page will reload if you make edits.<br> +The page will automatically reload if you make changes to the code.<br> You will see the build errors and lint warnings in the console. <img src='https://camo.githubusercontent.com/41678b3254cf583d3186c365528553c7ada53c6e/687474703a2f2f692e696d6775722e636f6d2f466e4c566677362e706e67' width='600' alt='Build errors'> From a34701b718a6584c5c9012b1249839fbe9e2c2e2 Mon Sep 17 00:00:00 2001 From: Robert Panzer <Robert.Panzer.PB@googlemail.com> Date: Fri, 29 Sep 2017 04:59:51 +0200 Subject: [PATCH 183/265] Correct manual proxy documentation (#3185) Correct manual proxy documentation --- packages/react-scripts/template/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 98e26c98e..64b63ee8d 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1049,7 +1049,7 @@ You may also specify any configuration value [`http-proxy-middleware`](https://g All requests matching this path will be proxies, no exceptions. This includes requests for `text/html`, which the standard `proxy` option does not proxy. If you need to specify multiple proxies, you may do so by specifying additional entries. -You may also narrow down matches using `*` and/or `**`, to match the path exactly or any subpath. +Matches are regular expressions, so that you can use a regexp to match multiple paths. ```js { // ... @@ -1070,12 +1070,12 @@ You may also narrow down matches using `*` and/or `**`, to match the path exactl // ... }, // Matches /bar/abc.html but not /bar/sub/def.html - "/bar/*.html": { + "/bar/[^/]*[.]html": { "target": "<url_3>", // ... }, // Matches /baz/abc.html and /baz/sub/def.html - "/baz/**/*.html": { + "/baz/.*/.*[.]html": { "target": "<url_4>" // ... } From 8c8bbca7cad64acc0a179071030a579cc12221c1 Mon Sep 17 00:00:00 2001 From: David Beitey <david@davidjb.com> Date: Fri, 29 Sep 2017 13:02:22 +1000 Subject: [PATCH 184/265] Minor change to highlight dev proxy behaviour (#3075) --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 64b63ee8d..9daa9992f 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -983,7 +983,7 @@ To tell the development server to proxy any unknown requests to your API server "proxy": "http://localhost:4000", ``` -This way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will only attempt to send requests without a `text/html` accept header to the proxy. +This way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will **only** attempt to send requests without `text/html` in its `Accept` header to the proxy. Conveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development: From c00358376b50e44313671384c64faf420e8d0c0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Hu=C5=99=C5=A5=C3=A1k?= <petr.hurtak@gmail.com> Date: Fri, 29 Sep 2017 05:03:27 +0200 Subject: [PATCH 185/265] More spec compliant HTML template (#2914) Changed `<!doctype html>` to `<!DOCTYPE html>` According to the spec it should be uppercase (but parsing is case insensitive) --- packages/react-scripts/template/public/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/public/index.html b/packages/react-scripts/template/public/index.html index 7bee02710..ed0ebafa1 100644 --- a/packages/react-scripts/template/public/index.html +++ b/packages/react-scripts/template/public/index.html @@ -1,4 +1,4 @@ -<!doctype html> +<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> From 1e98d0f428fd72f0a700b0c096b0d1a9e717d7ec Mon Sep 17 00:00:00 2001 From: Joe Lim <xjlim@users.noreply.github.com> Date: Mon, 2 Oct 2017 19:57:02 -0700 Subject: [PATCH 186/265] Watch for changes in `src/**/node_modules` (#3230) * Allow the dev server to watch for changes in src/node_modules * fix eslint error * fix broken regex * handle trailing slash edge case for file paths Closes #2760 Fixes #3223 --- packages/react-dev-utils/getProcessForPort.js | 10 +++++++--- .../react-scripts/config/webpackDevServer.config.js | 8 +++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/packages/react-dev-utils/getProcessForPort.js b/packages/react-dev-utils/getProcessForPort.js index c91959a37..932f3e5bf 100644 --- a/packages/react-dev-utils/getProcessForPort.js +++ b/packages/react-dev-utils/getProcessForPort.js @@ -46,7 +46,7 @@ function getProcessCommand(processId, processDirectory) { execOptions ); - command = command.replace(/\n$/, '') + command = command.replace(/\n$/, ''); if (isProcessAReactApp(command)) { const packageName = getPackageNameInDirectory(processDirectory); @@ -68,8 +68,12 @@ function getProcessForPort(port) { var processId = getProcessIdOnPort(port); var directory = getDirectoryOfProcessById(processId); var command = getProcessCommand(processId, directory); - return chalk.cyan(command) + chalk.grey(' (pid ' + processId + ')\n') + - chalk.blue(' in ') + chalk.cyan(directory); + return ( + chalk.cyan(command) + + chalk.grey(' (pid ' + processId + ')\n') + + chalk.blue(' in ') + + chalk.cyan(directory) + ); } catch (e) { return null; } diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index 25b42d0de..a48a1fbc3 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -10,6 +10,7 @@ const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware'); const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware'); +const path = require('path'); const config = require('./webpack.config.dev'); const paths = require('./paths'); @@ -72,8 +73,13 @@ module.exports = function(proxy, allowedHost) { quiet: true, // Reportedly, this avoids CPU overload on some systems. // https://github.com/facebookincubator/create-react-app/issues/293 + // src/node_modules is not ignored to support absolute imports + // https://github.com/facebookincubator/create-react-app/issues/1065 watchOptions: { - ignored: /node_modules/, + ignored: new RegExp( + `^(?!${path.normalize(paths.appSrc + '/')}).+[\\/]node_modules[\\/]`, + 'g' + ), }, // Enable HTTPS if the HTTPS environment variable is set to 'true' https: protocol === 'https', From f498547408edac3c2ef6338ee6d1bf99116ae8ee Mon Sep 17 00:00:00 2001 From: Toshiharu Nishina <n.toshi.1.014@gmail.com> Date: Tue, 3 Oct 2017 12:30:44 +0900 Subject: [PATCH 187/265] Fix package management link in README (#3227) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65b6bade3..6009e8a6d 100644 --- a/README.md +++ b/README.md @@ -255,4 +255,4 @@ Notable alternatives also include: * [gluestick](https://github.com/TrueCar/gluestick) You can also use module bundlers like [webpack](http://webpack.js.org) and [Browserify](http://browserify.org/) directly.<br> -React documentation includes [a walkthrough](https://facebook.github.io/react/docs/package-management.html) on this topic. +React documentation includes [a walkthrough](https://reactjs.org/docs/installation.html#development-and-production-versions) on this topic. From 01a0d737c79e02140c3cc0996d05ebd8a4eb3f84 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Mon, 2 Oct 2017 23:45:20 -0400 Subject: [PATCH 188/265] Fix Windows compatibility (#3232) * Windows compatibility * Use regex for mutli-replace --- packages/react-scripts/config/webpackDevServer.config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index a48a1fbc3..f401f2cce 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -77,7 +77,9 @@ module.exports = function(proxy, allowedHost) { // https://github.com/facebookincubator/create-react-app/issues/1065 watchOptions: { ignored: new RegExp( - `^(?!${path.normalize(paths.appSrc + '/')}).+[\\/]node_modules[\\/]`, + `^(?!${path + .normalize(paths.appSrc + '/') + .replace(/[\\]+/g, '\\\\')}).+[\\\\/]node_modules[\\\\/]`, 'g' ), }, From beb13816a0ac96a5777bf8ef1ecd13bda957c0a4 Mon Sep 17 00:00:00 2001 From: nicolaserny <nicolas.erny@xcomponent.com> Date: Tue, 3 Oct 2017 10:50:43 +0200 Subject: [PATCH 189/265] Upgrade to typescript 2.5.3 --- packages/react-scripts/package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 7d690ff5e..01bb852f5 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts-ts", - "version": "2.7.0", + "version": "2.8.0", "description": "Configuration and scripts for Create React App.", "repository": "wmonk/create-react-app", "license": "BSD-3-Clause", @@ -38,11 +38,11 @@ "react-dev-utils": "^4.0.1", "style-loader": "0.18.2", "ts-jest": "^20.0.7", - "ts-loader": "^2.2.1", - "tslint": "^5.2.0", + "ts-loader": "^2.3.7", + "tslint": "^5.7.0", "tslint-loader": "^3.5.3", - "tslint-react": "^3.0.0", - "typescript": "~2.4.0", + "tslint-react": "^3.2.0", + "typescript": "~2.5.3", "source-map-loader": "^0.2.1", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.5.9", From cd3d04b71e91f533bdbdc3856775e1da81d445cf Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara <tharaka.nw@gmail.com> Date: Tue, 3 Oct 2017 21:45:15 +0530 Subject: [PATCH 190/265] Make error overlay to run in the context of the iframe (#3142) * Make error overlay to run in the context of the iframe * Configure webpack to build the entire package * Remove inline raw-loader config * Configure watch mode for error-overlay webpack build * Add polyfills to the error-overlay iframe script * Add header comment * Configure to fail CI on error or warning * Suppress flow-type error on importing iframe-bundle * Change webpack to a dev dependency and pin some versions * Disable webpack cache * Update license headers to MIT --- packages/react-error-overlay/build.js | 95 +++++++++++++++++++ packages/react-error-overlay/package.json | 18 ++-- .../react-error-overlay/src/iframeScript.js | 57 +++++++++++ packages/react-error-overlay/src/index.js | 87 ++++++++--------- .../src/utils/pollyfills.js | 18 ++++ .../webpack.config.iframe.js | 27 ++++++ .../react-error-overlay/webpack.config.js | 38 ++++++++ 7 files changed, 284 insertions(+), 56 deletions(-) create mode 100644 packages/react-error-overlay/build.js create mode 100644 packages/react-error-overlay/src/iframeScript.js create mode 100644 packages/react-error-overlay/src/utils/pollyfills.js create mode 100644 packages/react-error-overlay/webpack.config.iframe.js create mode 100644 packages/react-error-overlay/webpack.config.js diff --git a/packages/react-error-overlay/build.js b/packages/react-error-overlay/build.js new file mode 100644 index 000000000..592da141f --- /dev/null +++ b/packages/react-error-overlay/build.js @@ -0,0 +1,95 @@ +/** + * 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. + */ +const webpack = require('webpack'); +const chalk = require('chalk'); +const webpackConfig = require('./webpack.config.js'); +const iframeWebpackConfig = require('./webpack.config.iframe.js'); +const rimraf = require('rimraf'); +const chokidar = require('chokidar'); + +const args = process.argv.slice(2); +const watchMode = args[0] === '--watch' || args[0] === '-w'; + +const isCI = + process.env.CI && + (typeof process.env.CI !== 'string' || + process.env.CI.toLowerCase() !== 'false'); + +function build(config, name, callback) { + console.log(chalk.cyan('Compiling ' + name)); + webpack(config).run((error, stats) => { + if (error) { + console.log(chalk.red('Failed to compile.')); + console.log(error.message || error); + console.log(); + } + + if (stats.compilation.errors.length) { + console.log(chalk.red('Failed to compile.')); + console.log(stats.toString({ all: false, errors: true })); + } + + if (stats.compilation.warnings.length) { + console.log(chalk.yellow('Compiled with warnings.')); + console.log(stats.toString({ all: false, warnings: true })); + } + + // Fail the build if running in a CI server + if ( + error || + stats.compilation.errors.length || + stats.compilation.warnings.length + ) { + isCI && process.exit(1); + return; + } + + console.log( + stats.toString({ colors: true, modules: false, version: false }) + ); + console.log(); + + callback(stats); + }); +} + +function runBuildSteps() { + build(iframeWebpackConfig, 'iframeScript.js', () => { + build(webpackConfig, 'index.js', () => { + console.log(chalk.bold.green('Compiled successfully!\n\n')); + }); + }); +} + +function setupWatch() { + const watcher = chokidar.watch('./src', { + ignoreInitial: true, + }); + + watcher.on('change', runBuildSteps); + watcher.on('add', runBuildSteps); + + watcher.on('ready', () => { + runBuildSteps(); + }); + + process.on('SIGINT', function() { + watcher.close(); + process.exit(0); + }); + + watcher.on('error', error => { + console.error('Watcher failure', error); + process.exit(1); + }); +} + +// Clean up lib folder +rimraf('lib/', () => { + console.log('Cleaned up the lib folder.\n'); + watchMode ? setupWatch() : runBuildSteps(); +}); diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 7640d1c5d..82ae43ec6 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -5,10 +5,10 @@ "main": "lib/index.js", "scripts": { "prepublishOnly": "npm run build:prod && npm test", - "start": "rimraf lib/ && cross-env NODE_ENV=development npm run build -- --watch", - "test": "flow && jest", - "build": "rimraf lib/ && babel src/ -d lib/", - "build:prod": "rimraf lib/ && cross-env NODE_ENV=production babel src/ -d lib/" + "start": "cross-env NODE_ENV=development node build.js --watch", + "test": "flow && cross-env NODE_ENV=test jest", + "build": "cross-env NODE_ENV=development node build.js", + "build:prod": "cross-env NODE_ENV=production node build.js" }, "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -35,15 +35,19 @@ "babel-code-frame": "6.22.0", "babel-runtime": "6.26.0", "html-entities": "1.2.1", + "object-assign": "4.1.1", + "promise": "8.0.1", "react": "^15 || ^16", "react-dom": "^15 || ^16", "settle-promise": "1.0.0", "source-map": "0.5.6" }, "devDependencies": { - "babel-cli": "6.24.1", "babel-eslint": "7.2.3", "babel-preset-react-app": "^3.0.3", + "babel-loader": "^7.1.2", + "chalk": "^2.1.0", + "chokidar": "^1.7.0", "cross-env": "5.0.5", "eslint": "4.4.1", "eslint-config-react-app": "^2.0.1", @@ -54,7 +58,9 @@ "flow-bin": "^0.54.0", "jest": "20.0.4", "jest-fetch-mock": "1.2.1", - "rimraf": "^2.6.1" + "raw-loader": "^0.5.1", + "rimraf": "^2.6.1", + "webpack": "^3.6.0" }, "jest": { "setupFiles": [ diff --git a/packages/react-error-overlay/src/iframeScript.js b/packages/react-error-overlay/src/iframeScript.js new file mode 100644 index 000000000..c95ea36b1 --- /dev/null +++ b/packages/react-error-overlay/src/iframeScript.js @@ -0,0 +1,57 @@ +/** + * 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. + */ + +import './utils/pollyfills.js'; +import React from 'react'; +import ReactDOM from 'react-dom'; +import CompileErrorContainer from './containers/CompileErrorContainer'; +import RuntimeErrorContainer from './containers/RuntimeErrorContainer'; +import { overlayStyle } from './styles'; +import { applyStyles } from './utils/dom/css'; + +let iframeRoot = null; + +function render({ + currentBuildError, + currentRuntimeErrorRecords, + dismissRuntimeErrors, + launchEditorEndpoint, +}) { + if (currentBuildError) { + return <CompileErrorContainer error={currentBuildError} />; + } + if (currentRuntimeErrorRecords.length > 0) { + return ( + <RuntimeErrorContainer + errorRecords={currentRuntimeErrorRecords} + close={dismissRuntimeErrors} + launchEditorEndpoint={launchEditorEndpoint} + /> + ); + } + return null; +} + +window.updateContent = function updateContent(errorOverlayProps) { + let renderedElement = render(errorOverlayProps); + + if (renderedElement === null) { + ReactDOM.unmountComponentAtNode(iframeRoot); + return false; + } + // Update the overlay + ReactDOM.render(renderedElement, iframeRoot); + return true; +}; + +document.body.style.margin = '0'; +// Keep popup within body boundaries for iOS Safari +document.body.style['max-width'] = '100vw'; +iframeRoot = document.createElement('div'); +applyStyles(iframeRoot, overlayStyle); +document.body.appendChild(iframeRoot); +window.parent.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__.iframeReady(); diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index 23f9e7838..52ff9199b 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -6,15 +6,15 @@ */ /* @flow */ -import React from 'react'; -import type { Element } from 'react'; -import ReactDOM from 'react-dom'; -import CompileErrorContainer from './containers/CompileErrorContainer'; -import RuntimeErrorContainer from './containers/RuntimeErrorContainer'; import { listenToRuntimeErrors } from './listenToRuntimeErrors'; -import { iframeStyle, overlayStyle } from './styles'; +import { iframeStyle } from './styles'; import { applyStyles } from './utils/dom/css'; +// Importing iframe-bundle generated in the pre build step as +// a text using webpack raw-loader. See webpack.config.js file. +// $FlowFixMe +import iframeScript from 'iframeScript'; + import type { ErrorRecord } from './listenToRuntimeErrors'; type RuntimeReportingOptions = {| @@ -25,8 +25,8 @@ type RuntimeReportingOptions = {| let iframe: null | HTMLIFrameElement = null; let isLoadingIframe: boolean = false; +var isIframeReady: boolean = false; -let renderedElement: null | Element<any> = null; let currentBuildError: null | string = null; let currentRuntimeErrorRecords: Array<ErrorRecord> = []; let currentRuntimeErrorOptions: null | RuntimeReportingOptions = null; @@ -88,15 +88,14 @@ export function stopReportingRuntimeErrors() { } function update() { - renderedElement = render(); // Loading iframe can be either sync or async depending on the browser. if (isLoadingIframe) { // Iframe is loading. // First render will happen soon--don't need to do anything. return; } - if (iframe) { - // Iframe has already loaded. + if (isIframeReady) { + // Iframe is ready. // Just update it. updateIframeContent(); return; @@ -108,58 +107,46 @@ function update() { loadingIframe.onload = function() { const iframeDocument = loadingIframe.contentDocument; if (iframeDocument != null && iframeDocument.body != null) { - iframeDocument.body.style.margin = '0'; - // Keep popup within body boundaries for iOS Safari - iframeDocument.body.style['max-width'] = '100vw'; - const iframeRoot = iframeDocument.createElement('div'); - applyStyles(iframeRoot, overlayStyle); - iframeDocument.body.appendChild(iframeRoot); - - // Ready! Now we can update the UI. iframe = loadingIframe; - isLoadingIframe = false; - updateIframeContent(); + const script = loadingIframe.contentWindow.document.createElement( + 'script' + ); + script.type = 'text/javascript'; + script.innerHTML = iframeScript; + iframeDocument.body.appendChild(script); } }; const appDocument = window.document; appDocument.body.appendChild(loadingIframe); } -function render() { - if (currentBuildError) { - return <CompileErrorContainer error={currentBuildError} />; - } - if (currentRuntimeErrorRecords.length > 0) { - if (!currentRuntimeErrorOptions) { - throw new Error('Expected options to be injected.'); - } - return ( - <RuntimeErrorContainer - errorRecords={currentRuntimeErrorRecords} - close={dismissRuntimeErrors} - launchEditorEndpoint={currentRuntimeErrorOptions.launchEditorEndpoint} - /> - ); +function updateIframeContent() { + if (!currentRuntimeErrorOptions) { + throw new Error('Expected options to be injected.'); } - return null; -} -function updateIframeContent() { - if (iframe === null) { + if (!iframe) { throw new Error('Iframe has not been created yet.'); } - const iframeBody = iframe.contentDocument.body; - if (!iframeBody) { - throw new Error('Expected iframe to have a body.'); - } - const iframeRoot = iframeBody.firstChild; - if (renderedElement === null) { - // Destroy iframe and force it to be recreated on next error + + const isRendered = iframe.contentWindow.updateContent({ + currentBuildError, + currentRuntimeErrorRecords, + dismissRuntimeErrors, + launchEditorEndpoint: currentRuntimeErrorOptions.launchEditorEndpoint, + }); + + if (!isRendered) { window.document.body.removeChild(iframe); - ReactDOM.unmountComponentAtNode(iframeRoot); iframe = null; - return; + isIframeReady = false; } - // Update the overlay - ReactDOM.render(renderedElement, iframeRoot); } + +window.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__ = + window.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__ || {}; +window.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__.iframeReady = function iframeReady() { + isIframeReady = true; + isLoadingIframe = false; + updateIframeContent(); +}; diff --git a/packages/react-error-overlay/src/utils/pollyfills.js b/packages/react-error-overlay/src/utils/pollyfills.js new file mode 100644 index 000000000..ddd5aeb96 --- /dev/null +++ b/packages/react-error-overlay/src/utils/pollyfills.js @@ -0,0 +1,18 @@ +/** + * 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. + */ + +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'); +} + +// 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'); diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js new file mode 100644 index 000000000..9fa742b72 --- /dev/null +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -0,0 +1,27 @@ +/** + * 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. + */ +'use strict'; + +const path = require('path'); + +module.exports = { + devtool: 'cheap-module-source-map', + entry: './src/iframeScript.js', + output: { + path: path.join(__dirname, './lib'), + filename: 'iframe-bundle.js', + }, + module: { + rules: [ + { + test: /\.js$/, + include: path.resolve(__dirname, './src'), + use: 'babel-loader', + }, + ], + }, +}; diff --git a/packages/react-error-overlay/webpack.config.js b/packages/react-error-overlay/webpack.config.js new file mode 100644 index 000000000..5d640e05c --- /dev/null +++ b/packages/react-error-overlay/webpack.config.js @@ -0,0 +1,38 @@ +/** + * 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. + */ +'use strict'; + +const path = require('path'); + +module.exports = { + devtool: 'cheap-module-source-map', + entry: './src/index.js', + output: { + path: path.join(__dirname, './lib'), + filename: 'index.js', + library: 'ReactErrorOverlay', + libraryTarget: 'umd', + }, + module: { + rules: [ + { + test: /iframe-bundle\.js$/, + use: 'raw-loader', + }, + { + test: /\.js$/, + include: path.resolve(__dirname, './src'), + use: 'babel-loader', + }, + ], + }, + resolve: { + alias: { + iframeScript$: path.resolve(__dirname, './lib/iframe-bundle.js'), + }, + }, +}; From 62f0a83c5e1ac4df3d752cb727f648d8096f4110 Mon Sep 17 00:00:00 2001 From: Joshua Wiens <wiens.joshua@gmail.com> Date: Thu, 5 Oct 2017 18:49:07 -0500 Subject: [PATCH 191/265] Update url-loader to 0.6.2 for mime ReDoS vuln (#3246) - Changelog: https://github.com/webpack-contrib/url-loader/blob/master/CHANGELOG.md - Reference issue: https://nodesecurity.io/advisories/535 Fixes #3244 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 123f966d0..1d8ef515b 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -51,7 +51,7 @@ "react-dev-utils": "^4.1.0", "style-loader": "0.18.2", "sw-precache-webpack-plugin": "0.11.4", - "url-loader": "0.5.9", + "url-loader": "0.6.2", "webpack": "3.5.1", "webpack-dev-server": "2.8.2", "webpack-manifest-plugin": "1.2.1", From a0030fcf2df5387577ced165198f1f0264022fbd Mon Sep 17 00:00:00 2001 From: Jonny Buchanan <jonathan.buchanan@gmail.com> Date: Fri, 6 Oct 2017 10:02:32 +1000 Subject: [PATCH 192/265] Update style-loader and disable inclusion of its HMR code in builds (#3236) --- packages/react-scripts/config/webpack.config.prod.js | 7 ++++++- packages/react-scripts/package.json | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index ef4ea1bc0..124d5b3cb 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -197,7 +197,12 @@ module.exports = { loader: ExtractTextPlugin.extract( Object.assign( { - fallback: require.resolve('style-loader'), + fallback: { + loader: require.resolve('style-loader'), + options: { + hmr: false, + }, + }, use: [ { loader: require.resolve('css-loader'), diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 1d8ef515b..f5007fbe6 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -49,7 +49,7 @@ "postcss-loader": "2.0.6", "promise": "8.0.1", "react-dev-utils": "^4.1.0", - "style-loader": "0.18.2", + "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", "webpack": "3.5.1", From 00ed100b26adc519fd90e09ebffd83c8d7dc4343 Mon Sep 17 00:00:00 2001 From: Tharaka Wijebandara <tharaka.nw@gmail.com> Date: Fri, 6 Oct 2017 05:51:17 +0530 Subject: [PATCH 193/265] Add click-to-open support for build errors (#3100) * Implement click-to-open for babel syntax errors in build error overlay * Add click-to-open support for lint errors and refactor parser * Reactor code to reuse open-in-editor functionality in both build and runtime error overlays * Fix some eslint warnings * Add a comment about keeping middleware and dev client in sync * Remove es6 features from webpack dev client * Make open-in-editor functionality to work with new iframe script * Rename `openInEditor` to `editorHandler` - Remove indirection of openInEditorListener - Check editorHandler for null before styling error clickable * Fix flow errors --- .../react-dev-utils/webpackHotDevClient.js | 11 +++- .../src/containers/CompileErrorContainer.js | 20 ++++++- .../src/containers/RuntimeError.js | 7 ++- .../src/containers/RuntimeErrorContainer.js | 5 +- .../src/containers/StackFrame.js | 48 +++++++--------- .../src/containers/StackTrace.js | 12 ++-- .../react-error-overlay/src/iframeScript.js | 11 +++- packages/react-error-overlay/src/index.js | 21 ++++++- .../src/utils/parseCompileError.js | 57 +++++++++++++++++++ 9 files changed, 142 insertions(+), 50 deletions(-) create mode 100644 packages/react-error-overlay/src/utils/parseCompileError.js diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index 611fc6ba0..e375c3fab 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -23,6 +23,16 @@ var launchEditorEndpoint = require('./launchEditorEndpoint'); var formatWebpackMessages = require('./formatWebpackMessages'); var ErrorOverlay = require('react-error-overlay'); +ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) { + // Keep this sync with errorOverlayMiddleware.js + fetch( + `${launchEditorEndpoint}?fileName=` + + window.encodeURIComponent(errorLocation.fileName) + + '&lineNumber=' + + window.encodeURIComponent(errorLocation.lineNumber || 1) + ); +}); + // We need to keep track of if there has been a runtime error. // Essentially, we cannot guarantee application state was not corrupted by the // runtime error. To prevent confusing behavior, we forcibly reload the entire @@ -31,7 +41,6 @@ var ErrorOverlay = require('react-error-overlay'); // See https://github.com/facebookincubator/create-react-app/issues/3096 var hadRuntimeError = false; ErrorOverlay.startReportingRuntimeErrors({ - launchEditorEndpoint: launchEditorEndpoint, onError: function() { hadRuntimeError = true; }, diff --git a/packages/react-error-overlay/src/containers/CompileErrorContainer.js b/packages/react-error-overlay/src/containers/CompileErrorContainer.js index 5d491a9d4..9d1e399fd 100644 --- a/packages/react-error-overlay/src/containers/CompileErrorContainer.js +++ b/packages/react-error-overlay/src/containers/CompileErrorContainer.js @@ -12,18 +12,34 @@ import Footer from '../components/Footer'; import Header from '../components/Header'; import CodeBlock from '../components/CodeBlock'; import generateAnsiHTML from '../utils/generateAnsiHTML'; +import parseCompileError from '../utils/parseCompileError'; +import type { ErrorLocation } from '../utils/parseCompileError'; + +const codeAnchorStyle = { + cursor: 'pointer', +}; type Props = {| error: string, + editorHandler: (errorLoc: ErrorLocation) => void, |}; class CompileErrorContainer extends PureComponent<Props, void> { render() { - const { error } = this.props; + const { error, editorHandler } = this.props; + const errLoc: ?ErrorLocation = parseCompileError(error); + const canOpenInEditor = errLoc !== null && editorHandler !== null; return ( <ErrorOverlay> <Header headerText="Failed to compile" /> - <CodeBlock main={true} codeHTML={generateAnsiHTML(error)} /> + <a + onClick={ + canOpenInEditor && errLoc ? () => editorHandler(errLoc) : null + } + style={canOpenInEditor ? codeAnchorStyle : null} + > + <CodeBlock main={true} codeHTML={generateAnsiHTML(error)} /> + </a> <Footer line1="This error occurred during the build time and cannot be dismissed." /> </ErrorOverlay> ); diff --git a/packages/react-error-overlay/src/containers/RuntimeError.js b/packages/react-error-overlay/src/containers/RuntimeError.js index c247ba52a..1db2aba79 100644 --- a/packages/react-error-overlay/src/containers/RuntimeError.js +++ b/packages/react-error-overlay/src/containers/RuntimeError.js @@ -11,6 +11,7 @@ import Header from '../components/Header'; import StackTrace from './StackTrace'; import type { StackFrame } from '../utils/stack-frame'; +import type { ErrorLocation } from '../utils/parseCompileError'; const wrapperStyle = { display: 'flex', @@ -26,10 +27,10 @@ export type ErrorRecord = {| type Props = {| errorRecord: ErrorRecord, - launchEditorEndpoint: ?string, + editorHandler: (errorLoc: ErrorLocation) => void, |}; -function RuntimeError({ errorRecord, launchEditorEndpoint }: Props) { +function RuntimeError({ errorRecord, editorHandler }: Props) { const { error, unhandledRejection, contextSize, stackFrames } = errorRecord; const errorName = unhandledRejection ? 'Unhandled Rejection (' + error.name + ')' @@ -58,7 +59,7 @@ function RuntimeError({ errorRecord, launchEditorEndpoint }: Props) { stackFrames={stackFrames} errorName={errorName} contextSize={contextSize} - launchEditorEndpoint={launchEditorEndpoint} + editorHandler={editorHandler} /> </div> ); diff --git a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js index 80585f051..91d4a4f54 100644 --- a/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js +++ b/packages/react-error-overlay/src/containers/RuntimeErrorContainer.js @@ -14,11 +14,12 @@ import RuntimeError from './RuntimeError'; import Footer from '../components/Footer'; import type { ErrorRecord } from './RuntimeError'; +import type { ErrorLocation } from '../utils/parseCompileError'; type Props = {| errorRecords: ErrorRecord[], close: () => void, - launchEditorEndpoint: ?string, + editorHandler: (errorLoc: ErrorLocation) => void, |}; type State = {| @@ -74,7 +75,7 @@ class RuntimeErrorContainer extends PureComponent<Props, State> { )} <RuntimeError errorRecord={errorRecords[this.state.currentIndex]} - launchEditorEndpoint={this.props.launchEditorEndpoint} + editorHandler={this.props.editorHandler} /> <Footer line1="This screen is visible only in development. It will not appear if the app crashes in production." diff --git a/packages/react-error-overlay/src/containers/StackFrame.js b/packages/react-error-overlay/src/containers/StackFrame.js index f16ae6435..9ae910434 100644 --- a/packages/react-error-overlay/src/containers/StackFrame.js +++ b/packages/react-error-overlay/src/containers/StackFrame.js @@ -12,6 +12,7 @@ import { getPrettyURL } from '../utils/getPrettyURL'; import { darkGray } from '../styles'; import type { StackFrame as StackFrameType } from '../utils/stack-frame'; +import type { ErrorLocation } from '../utils/parseCompileError'; const linkStyle = { fontSize: '0.9em', @@ -45,10 +46,10 @@ const toggleStyle = { type Props = {| frame: StackFrameType, - launchEditorEndpoint: ?string, contextSize: number, critical: boolean, showCode: boolean, + editorHandler: (errorLoc: ErrorLocation) => void, |}; type State = {| @@ -66,47 +67,35 @@ class StackFrame extends Component<Props, State> { })); }; - getEndpointUrl(): string | null { - if (!this.props.launchEditorEndpoint) { - return null; - } - const { _originalFileName: sourceFileName } = this.props.frame; + getErrorLocation(): ErrorLocation | null { + const { + _originalFileName: fileName, + _originalLineNumber: lineNumber, + } = this.props.frame; // Unknown file - if (!sourceFileName) { + if (!fileName) { return null; } // e.g. "/path-to-my-app/webpack/bootstrap eaddeb46b67d75e4dfc1" - const isInternalWebpackBootstrapCode = - sourceFileName.trim().indexOf(' ') !== -1; + const isInternalWebpackBootstrapCode = fileName.trim().indexOf(' ') !== -1; if (isInternalWebpackBootstrapCode) { return null; } // Code is in a real file - return this.props.launchEditorEndpoint || null; + return { fileName, lineNumber: lineNumber || 1 }; } - openInEditor = () => { - const endpointUrl = this.getEndpointUrl(); - if (endpointUrl === null) { + editorHandler = () => { + const errorLoc = this.getErrorLocation(); + if (!errorLoc) { return; } - - const { - _originalFileName: sourceFileName, - _originalLineNumber: sourceLineNumber, - } = this.props.frame; - // Keep this in sync with react-error-overlay/middleware.js - fetch( - `${endpointUrl}?fileName=` + - window.encodeURIComponent(sourceFileName) + - '&lineNumber=' + - window.encodeURIComponent(sourceLineNumber || 1) - ).then(() => {}, () => {}); + this.props.editorHandler(errorLoc); }; onKeyDown = (e: SyntheticKeyboardEvent<>) => { if (e.key === 'Enter') { - this.openInEditor(); + this.editorHandler(); } }; @@ -166,14 +155,15 @@ class StackFrame extends Component<Props, State> { } } - const canOpenInEditor = this.getEndpointUrl() !== null; + const canOpenInEditor = + this.getErrorLocation() !== null && this.props.editorHandler !== null; return ( <div> <div>{functionName}</div> <div style={linkStyle}> <a style={canOpenInEditor ? anchorStyle : null} - onClick={canOpenInEditor ? this.openInEditor : null} + onClick={canOpenInEditor ? this.editorHandler : null} onKeyDown={canOpenInEditor ? this.onKeyDown : null} tabIndex={canOpenInEditor ? '0' : null} > @@ -183,7 +173,7 @@ class StackFrame extends Component<Props, State> { {codeBlockProps && ( <span> <a - onClick={canOpenInEditor ? this.openInEditor : null} + onClick={canOpenInEditor ? this.editorHandler : null} style={canOpenInEditor ? codeAnchorStyle : null} > <CodeBlock {...codeBlockProps} /> diff --git a/packages/react-error-overlay/src/containers/StackTrace.js b/packages/react-error-overlay/src/containers/StackTrace.js index 0be342ddc..abec286a3 100644 --- a/packages/react-error-overlay/src/containers/StackTrace.js +++ b/packages/react-error-overlay/src/containers/StackTrace.js @@ -13,6 +13,7 @@ import { isInternalFile } from '../utils/isInternalFile'; import { isBultinErrorName } from '../utils/isBultinErrorName'; import type { StackFrame as StackFrameType } from '../utils/stack-frame'; +import type { ErrorLocation } from '../utils/parseCompileError'; const traceStyle = { fontSize: '1em', @@ -25,17 +26,12 @@ type Props = {| stackFrames: StackFrameType[], errorName: string, contextSize: number, - launchEditorEndpoint: ?string, + editorHandler: (errorLoc: ErrorLocation) => void, |}; class StackTrace extends Component<Props> { renderFrames() { - const { - stackFrames, - errorName, - contextSize, - launchEditorEndpoint, - } = this.props; + const { stackFrames, errorName, contextSize, editorHandler } = this.props; const renderedFrames = []; let hasReachedAppCode = false, currentBundle = [], @@ -59,7 +55,7 @@ class StackTrace extends Component<Props> { contextSize={contextSize} critical={index === 0} showCode={!shouldCollapse} - launchEditorEndpoint={launchEditorEndpoint} + editorHandler={editorHandler} /> ); const lastElement = index === stackFrames.length - 1; diff --git a/packages/react-error-overlay/src/iframeScript.js b/packages/react-error-overlay/src/iframeScript.js index c95ea36b1..3da820264 100644 --- a/packages/react-error-overlay/src/iframeScript.js +++ b/packages/react-error-overlay/src/iframeScript.js @@ -19,17 +19,22 @@ function render({ currentBuildError, currentRuntimeErrorRecords, dismissRuntimeErrors, - launchEditorEndpoint, + editorHandler, }) { if (currentBuildError) { - return <CompileErrorContainer error={currentBuildError} />; + return ( + <CompileErrorContainer + error={currentBuildError} + editorHandler={editorHandler} + /> + ); } if (currentRuntimeErrorRecords.length > 0) { return ( <RuntimeErrorContainer errorRecords={currentRuntimeErrorRecords} close={dismissRuntimeErrors} - launchEditorEndpoint={launchEditorEndpoint} + editorHandler={editorHandler} /> ); } diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index 52ff9199b..a800595cf 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -16,22 +16,32 @@ import { applyStyles } from './utils/dom/css'; import iframeScript from 'iframeScript'; import type { ErrorRecord } from './listenToRuntimeErrors'; +import type { ErrorLocation } from './utils/parseCompileError'; type RuntimeReportingOptions = {| onError: () => void, - launchEditorEndpoint: string, filename?: string, |}; +type EditorHandler = (errorLoc: ErrorLocation) => void; + let iframe: null | HTMLIFrameElement = null; let isLoadingIframe: boolean = false; var isIframeReady: boolean = false; +let editorHandler: null | EditorHandler = null; let currentBuildError: null | string = null; let currentRuntimeErrorRecords: Array<ErrorRecord> = []; let currentRuntimeErrorOptions: null | RuntimeReportingOptions = null; let stopListeningToRuntimeErrors: null | (() => void) = null; +export function setEditorHandler(handler: EditorHandler | null) { + editorHandler = handler; + if (iframe) { + update(); + } +} + export function reportBuildError(error: string) { currentBuildError = error; update(); @@ -46,6 +56,13 @@ export function startReportingRuntimeErrors(options: RuntimeReportingOptions) { if (stopListeningToRuntimeErrors !== null) { throw new Error('Already listening'); } + if (options.launchEditorEndpoint) { + console.warn( + 'Warning: `startReportingRuntimeErrors` doesn’t accept ' + + '`launchEditorEndpoint` argument anymore. Use `listenToOpenInEditor` ' + + 'instead with your own implementation to open errors in editor ' + ); + } currentRuntimeErrorOptions = options; listenToRuntimeErrors(errorRecord => { try { @@ -133,7 +150,7 @@ function updateIframeContent() { currentBuildError, currentRuntimeErrorRecords, dismissRuntimeErrors, - launchEditorEndpoint: currentRuntimeErrorOptions.launchEditorEndpoint, + editorHandler, }); if (!isRendered) { diff --git a/packages/react-error-overlay/src/utils/parseCompileError.js b/packages/react-error-overlay/src/utils/parseCompileError.js new file mode 100644 index 000000000..2c9b6e60e --- /dev/null +++ b/packages/react-error-overlay/src/utils/parseCompileError.js @@ -0,0 +1,57 @@ +// @flow +import Anser from 'anser'; + +export type ErrorLocation = {| + fileName: string, + lineNumber: number, +|}; + +const filePathRegex = /^\.(\/[^/\n ]+)+\.[^/\n ]+$/; + +const lineNumberRegexes = [ + // Babel syntax errors + // Based on syntax error formating of babylon parser + // https://github.com/babel/babylon/blob/v7.0.0-beta.22/src/parser/location.js#L19 + /^.*\((\d+):(\d+)\)$/, + + // ESLint errors + // Based on eslintFormatter in react-dev-utils + /^Line (\d+):.+$/, +]; + +// Based on error formatting of webpack +// https://github.com/webpack/webpack/blob/v3.5.5/lib/Stats.js#L183-L217 +function parseCompileError(message: string): ?ErrorLocation { + const lines: Array<string> = message.split('\n'); + let fileName: string = ''; + let lineNumber: number = 0; + + for (let i = 0; i < lines.length; i++) { + const line: string = Anser.ansiToText(lines[i]).trim(); + if (!line) { + continue; + } + + if (!fileName && line.match(filePathRegex)) { + fileName = line; + } + + let k = 0; + while (k < lineNumberRegexes.length) { + const match: ?Array<string> = line.match(lineNumberRegexes[k]); + if (match) { + lineNumber = parseInt(match[1], 10); + break; + } + k++; + } + + if (fileName && lineNumber) { + break; + } + } + + return fileName && lineNumber ? { fileName, lineNumber } : null; +} + +export default parseCompileError; From 360fa27cf217aa8a86ae55484ebf850709b924da Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Wed, 11 Oct 2017 10:07:56 -0400 Subject: [PATCH 194/265] `react-error-overlay` has no dependencies now (#3263) * `react-error-overlay` has no dependencies now (it's bundled) * Use babel 6 for now --- packages/react-error-overlay/package.json | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 82ae43ec6..cb0a3193f 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -30,22 +30,14 @@ "lib/", "middleware.js" ], - "dependencies": { + "devDependencies": { "anser": "1.4.1", "babel-code-frame": "6.22.0", - "babel-runtime": "6.26.0", - "html-entities": "1.2.1", - "object-assign": "4.1.1", - "promise": "8.0.1", - "react": "^15 || ^16", - "react-dom": "^15 || ^16", - "settle-promise": "1.0.0", - "source-map": "0.5.6" - }, - "devDependencies": { + "babel-core": "^6.26.0", "babel-eslint": "7.2.3", - "babel-preset-react-app": "^3.0.3", "babel-loader": "^7.1.2", + "babel-preset-react-app": "^3.0.3", + "babel-runtime": "6.26.0", "chalk": "^2.1.0", "chokidar": "^1.7.0", "cross-env": "5.0.5", @@ -56,10 +48,17 @@ "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.1.0", "flow-bin": "^0.54.0", + "html-entities": "1.2.1", "jest": "20.0.4", "jest-fetch-mock": "1.2.1", + "object-assign": "4.1.1", + "promise": "8.0.1", "raw-loader": "^0.5.1", + "react": "^16.0.0", + "react-dom": "^16.0.0", "rimraf": "^2.6.1", + "settle-promise": "1.0.0", + "source-map": "0.5.6", "webpack": "^3.6.0" }, "jest": { From 86b4b6ab858f0e46709ef867dc246c7f79f2998b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Ericson?= <de.ericson@gmail.com> Date: Wed, 11 Oct 2017 11:27:40 -0300 Subject: [PATCH 195/265] Add external links to deployment services (#3265) --- packages/react-scripts/template/README.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 9daa9992f..61f326658 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1816,11 +1816,11 @@ If you are not using the HTML5 `pushState` history API or not using client-side This will make sure that all the asset paths are relative to `index.html`. You will then be able to move your app from `http://mywebsite.com` to `http://mywebsite.com/relativepath` or even `http://mywebsite.com/relative/path` without having to rebuild it. -### Azure +### [Azure](https://azure.microsoft.com/) -See [this](https://medium.com/@to_pe/deploying-create-react-app-on-microsoft-azure-c0f6686a4321) blog post on how to deploy your React app to [Microsoft Azure](https://azure.microsoft.com/). +See [this](https://medium.com/@to_pe/deploying-create-react-app-on-microsoft-azure-c0f6686a4321) blog post on how to deploy your React app to Microsoft Azure. -### Firebase +### [Firebase](https://firebase.google.com/) Install the Firebase CLI if you haven’t already by running `npm install -g firebase-tools`. Sign up for a [Firebase account](https://console.firebase.google.com/) and create a new project. Run `firebase login` and login with your previous created Firebase account. @@ -1881,7 +1881,7 @@ Now, after you create a production build with `npm run build`, you can deploy it For more information see [Add Firebase to your JavaScript Project](https://firebase.google.com/docs/web/setup). -### GitHub Pages +### [GitHub Pages](https://pages.github.com/) >Note: this feature is available with `react-scripts@0.2.0` and higher. @@ -1951,7 +1951,7 @@ GitHub Pages doesn’t support routers that use the HTML5 `pushState` history AP * You could switch from using HTML5 history API to routing with hashes. If you use React Router, you can switch to `hashHistory` for this effect, but the URL will be longer and more verbose (for example, `http://user.github.io/todomvc/#/todos/42?_k=yknaj`). [Read more](https://reacttraining.com/react-router/web/api/Router) about different history implementations in React Router. * Alternatively, you can use a trick to teach GitHub Pages to handle 404 by redirecting to your `index.html` page with a special redirect parameter. You would need to add a `404.html` file with the redirection code to the `build` folder before deploying your project, and you’ll need to add code handling the redirect parameter to `index.html`. You can find a detailed explanation of this technique [in this guide](https://github.com/rafrex/spa-github-pages). -### Heroku +### [Heroku](https://www.heroku.com/) Use the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).<br> You can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration). @@ -1989,7 +1989,7 @@ remote: npm ERR! argv "/tmp/build_a2875fc163b209225122d68916f1d4df/.heroku/node/ In this case, ensure that the file is there with the proper lettercase and that’s not ignored on your local `.gitignore` or `~/.gitignore_global`. -### Netlify +### [Netlify](https://www.netlify.com/) **To do a manual deploy to Netlify’s CDN:** @@ -2018,9 +2018,9 @@ To support `pushState`, make sure to create a `public/_redirects` file with the When you build the project, Create React App will place the `public` folder contents into the build output. -### Now +### [Now](https://zeit.co/now) -[now](https://zeit.co/now) offers a zero-configuration single-command deployment. You can use `now` to deploy your app for free. +Now offers a zero-configuration single-command deployment. You can use `now` to deploy your app for free. 1. Install the `now` command-line tool either via the recommended [desktop tool](https://zeit.co/download) or via node with `npm install -g now`. @@ -2038,11 +2038,11 @@ When you build the project, Create React App will place the `public` folder cont Details are available in [this article.](https://zeit.co/blog/unlimited-static) -### S3 and CloudFront +### [S3](https://aws.amazon.com/s3) and [CloudFront](https://aws.amazon.com/cloudfront/) -See this [blog post](https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af) on how to deploy your React app to Amazon Web Services [S3](https://aws.amazon.com/s3) and [CloudFront](https://aws.amazon.com/cloudfront/). +See this [blog post](https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af) on how to deploy your React app to Amazon Web Services S3 and CloudFront. -### Surge +### [Surge](https://surge.sh/) Install the Surge CLI if you haven’t already by running `npm install -g surge`. Run the `surge` command and log in you or create a new account. From 9ce144ed90c37f116b8457821d36dba2ceb0490a Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Wed, 11 Oct 2017 14:20:23 -0400 Subject: [PATCH 196/265] Add warning when using `react-error-overlay` in production (#3264) * Add a warning when running minified * Add more robust check * Update index.js --- packages/react-error-overlay/src/index.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-error-overlay/src/index.js b/packages/react-error-overlay/src/index.js index a800595cf..8bc61ca25 100644 --- a/packages/react-error-overlay/src/index.js +++ b/packages/react-error-overlay/src/index.js @@ -167,3 +167,10 @@ window.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__.iframeReady = function iframeReady() isLoadingIframe = false; updateIframeContent(); }; + +if (process.env.NODE_ENV === 'production') { + console.warn( + 'react-error-overlay is not meant for use in production. You should ' + + 'ensure it is not included in your build to reduce bundle size.' + ); +} From 991b092c893b916e6fd34e408e96a395d47b6008 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Wed, 11 Oct 2017 18:16:38 -0400 Subject: [PATCH 197/265] Use production React version for bundled overlay (#3267) * Use production React version * We cannot strip our own checks if production * Keep the sourcemap during minify * Prevent devtools pollution * Add some comments * sigh --- packages/react-error-overlay/package.json | 3 +-- .../webpack.config.iframe.js | 24 ++++++++++++++++++- .../react-error-overlay/webpack.config.js | 1 - 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index cb0a3193f..9e36bf7e8 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -27,8 +27,7 @@ ], "author": "Joe Haddad <timer150@gmail.com>", "files": [ - "lib/", - "middleware.js" + "lib/index.js" ], "devDependencies": { "anser": "1.4.1", diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 9fa742b72..031762e59 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -7,9 +7,9 @@ 'use strict'; const path = require('path'); +const webpack = require('webpack'); module.exports = { - devtool: 'cheap-module-source-map', entry: './src/iframeScript.js', output: { path: path.join(__dirname, './lib'), @@ -24,4 +24,26 @@ module.exports = { }, ], }, + plugins: [ + new webpack.DefinePlugin({ + // We set process.env.NODE_ENV to 'production' so that React is built + // in production mode. + 'process.env': { NODE_ENV: '"production"' }, + // This prevents our bundled React from accidentally hijacking devtools. + __REACT_DEVTOOLS_GLOBAL_HOOK__: + '__REACT_ERROR_OVERLAY_GLOBAL_HOOK_NOOP__', + }), + // This code is embedded as a string, so it would never be optimized + // elsewhere. + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false, + comparisons: false, + }, + output: { + comments: false, + ascii_only: false, + }, + }), + ], }; diff --git a/packages/react-error-overlay/webpack.config.js b/packages/react-error-overlay/webpack.config.js index 5d640e05c..bc8b363f7 100644 --- a/packages/react-error-overlay/webpack.config.js +++ b/packages/react-error-overlay/webpack.config.js @@ -9,7 +9,6 @@ const path = require('path'); module.exports = { - devtool: 'cheap-module-source-map', entry: './src/index.js', output: { path: path.join(__dirname, './lib'), From ce4406aa2ba76ff62541ecf2a099cf24340bfd5b Mon Sep 17 00:00:00 2001 From: William Monk <will@passfort.com> Date: Tue, 17 Oct 2017 10:03:14 +0100 Subject: [PATCH 198/265] v2.8.0 From 2d0ef6a43628ea17cafc112da012c7a3ae7df3c9 Mon Sep 17 00:00:00 2001 From: Alex <alexkrolick@users.noreply.github.com> Date: Tue, 17 Oct 2017 08:19:44 -0700 Subject: [PATCH 199/265] Fix dead link to Jest "expect" docs (#3289) Closes #3291 --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 61f326658..9948f499c 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1235,7 +1235,7 @@ it('sums numbers', () => { }); ``` -All `expect()` matchers supported by Jest are [extensively documented here](http://facebook.github.io/jest/docs/expect.html).<br> +All `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).<br> You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](http://facebook.github.io/jest/docs/expect.html#tohavebeencalled) to create “spies” or mock functions. ### Testing Components From 1a3017b71774bfe271ac6974f8111fc0390271fb Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Tue, 17 Oct 2017 14:37:28 -0400 Subject: [PATCH 200/265] Update README.md --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 9948f499c..04c9a6a0d 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1236,7 +1236,7 @@ it('sums numbers', () => { ``` All `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).<br> -You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](http://facebook.github.io/jest/docs/expect.html#tohavebeencalled) to create “spies” or mock functions. +You can also use [`jest.fn()` and `expect(fn).toBeCalled()`](https://facebook.github.io/jest/docs/en/expect.html#tohavebeencalled) to create “spies” or mock functions. ### Testing Components From a0c515c8ad6cc7a547cf85196e9129bb58fe614d Mon Sep 17 00:00:00 2001 From: Josh Branchaud <jbranchaud@gmail.com> Date: Thu, 19 Oct 2017 12:59:10 -0500 Subject: [PATCH 201/265] Update link to Jest Expect docs (#3303) The existing link lands on a 'this page has moved' placeholder that doesn't redirect to the correct location. This PR replaces it with the currently working URL. --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 04c9a6a0d..6447c1f0b 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1302,7 +1302,7 @@ it('renders welcome message', () => { }); ``` -All Jest matchers are [extensively documented here](http://facebook.github.io/jest/docs/expect.html).<br> +All Jest matchers are [extensively documented here](http://facebook.github.io/jest/docs/en/expect.html).<br> Nevertheless you can use a third-party assertion library like [Chai](http://chaijs.com/) if you want to, as described below. Additionally, you might find [jest-enzyme](https://github.com/blainekasten/enzyme-matchers) helpful to simplify your tests with readable matchers. The above `contains` code can be written simpler with jest-enzyme. From 72a02c7febe08db0754fd451e9331226cbe6b47a Mon Sep 17 00:00:00 2001 From: Matt Phillips <matt@mattphillips.io> Date: Sat, 21 Oct 2017 22:33:04 +0100 Subject: [PATCH 202/265] Add jest coverage configuration docs (#3279) --- packages/react-scripts/template/README.md | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 6447c1f0b..b31da24e7 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1374,6 +1374,41 @@ Run `npm test -- --coverage` (note extra `--` in the middle) to include a covera Note that tests run much slower with coverage so it is recommended to run it separately from your normal workflow. +#### Configuration + +The default Jest coverage configuration can be overriden by adding any of the following supported keys to a Jest config in your package.json. + +Supported overrides: + - [`collectCoverageFrom`](https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array) + - [`coverageReporters`](https://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string) + - [`coverageThreshold`](https://facebook.github.io/jest/docs/en/configuration.html#coveragethreshold-object) + - [`snapshotSerializers`](https://facebook.github.io/jest/docs/en/configuration.html#snapshotserializers-array-string) + +Example package.json: + +```json +{ + "name": "your-package", + "jest": { + "collectCoverageFrom" : [ + "src/**/*.{js,jsx}", + "!<rootDir>/node_modules/", + "!<rootDir>/path/to/dir/" + ], + "coverageThreshold": { + "global": { + "branches": 90, + "functions": 90, + "lines": 90, + "statements": 90 + } + }, + "coverageReporters": ["text"], + "snapshotSerializers": ["my-serializer-module"] + } +} +``` + ### Continuous Integration By default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI`. From 54f7da9bb92f0c809fb24c7f22d7457acbfe851f Mon Sep 17 00:00:00 2001 From: Lorenzo Palmes <lpalmes@gmail.com> Date: Mon, 23 Oct 2017 17:18:54 -0300 Subject: [PATCH 203/265] Update `eslint-plugin-react` (#3146) * update eslint-plugin-react to 7.3.0 * Updated eslint-plugin-react to 7.4.0 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index f5007fbe6..20f3ff814 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -38,7 +38,7 @@ "eslint-plugin-flowtype": "2.35.0", "eslint-plugin-import": "2.7.0", "eslint-plugin-jsx-a11y": "5.1.1", - "eslint-plugin-react": "7.1.0", + "eslint-plugin-react": "7.4.0", "extract-text-webpack-plugin": "3.0.0", "file-loader": "0.11.2", "fs-extra": "3.0.1", From 2c25d89442dd42769b3cf0b4b00659d7d2896559 Mon Sep 17 00:00:00 2001 From: William Monk <will@passfort.com> Date: Tue, 24 Oct 2017 15:01:29 +0100 Subject: [PATCH 204/265] --no-edit --- README.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9eba65f7f..fddffcbdd 100644 --- a/README.md +++ b/README.md @@ -14,13 +14,6 @@ cd my-app/ npm start ``` -## Features - -### Code highlighting on error -When you run `npm run build` the terminal will output the error, including the highlighted sourcecode (like babel)! - -![CodeHighlight](https://cloud.githubusercontent.com/assets/175278/22310149/1ee66ccc-e346-11e6-83ff-e3a053701fb4.gif) - ## Migration In general, most upgrades won't require any migration steps to work, but if you experience problems after an upgrade, please file an issue, and we'll add it to the list of migration steps below. @@ -43,6 +36,9 @@ To fix this, create a new file *in the root of the project* called `tsconfig.tes ## Changelog +### 2.8.0 +* Update typescript to 2.5.3 - @nicolaserny + ### 2.7.0 * Merge react-scripts@1.0.13 - @JohnNilsson * Fix git tempalte - @hktonylee From aa322d0893dd0f789d4dbb7ff1878096c69edf1c Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Thu, 26 Oct 2017 18:34:58 +0100 Subject: [PATCH 205/265] Clarify the npm precompilation advice It's confusing: https://mobile.twitter.com/brianleroux/status/923581596720013312 h/t @brianleroux --- packages/react-scripts/template/README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index b31da24e7..a65970b9b 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -2186,14 +2186,20 @@ This will only work for locales that have been explicitly imported before. ### `npm run build` fails to minify -You may occasionally find a package you depend on needs compiled or ships code for a non-browser environment.<br> -This is considered poor practice in the ecosystem and does not have an escape hatch in Create React App.<br> +Some third-party packages don't compile their code to ES5 before publishing to npm. This often causes problems in the ecosystem because neither browsers (except for most modern versions) nor some tools currently support all ES6 features. We recommend to publish code on npm as ES5 at least for a few more years. + <br> To resolve this: -1. Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled (retaining ES6 Modules). -2. Fork the package and publish a corrected version yourself. + +1. Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled. + * Note: Create React App can consume both CommonJS and ES modules. For Node.js compatibility, it is recommended that the main entry point is CommonJS. However, they can optionally provide an ES module entry point with the `module` field in `package.json`. Note that **even if a library provides an ES Modules version, it should still precompile other ES6 features to ES5 if it intends to support older browsers**. + +2. Fork the package and publish a corrected version yourself. + 3. If the dependency is small enough, copy it to your `src/` folder and treat it as application code. +In the future, we might start automatically compiling incompatible third-party modules, but it is not currently supported. This approach would also slow down the production builds. + ## Something Missing? If you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md) From 4d4cbf058347ce86dfff9b179e5750ca42db10c7 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sat, 28 Oct 2017 17:00:39 +0100 Subject: [PATCH 206/265] Use a simpler string replacement for the overlay --- packages/react-error-overlay/webpack.config.iframe.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/react-error-overlay/webpack.config.iframe.js b/packages/react-error-overlay/webpack.config.iframe.js index 031762e59..c80b15afa 100644 --- a/packages/react-error-overlay/webpack.config.iframe.js +++ b/packages/react-error-overlay/webpack.config.iframe.js @@ -30,8 +30,7 @@ module.exports = { // in production mode. 'process.env': { NODE_ENV: '"production"' }, // This prevents our bundled React from accidentally hijacking devtools. - __REACT_DEVTOOLS_GLOBAL_HOOK__: - '__REACT_ERROR_OVERLAY_GLOBAL_HOOK_NOOP__', + __REACT_DEVTOOLS_GLOBAL_HOOK__: '({})', }), // This code is embedded as a string, so it would never be optimized // elsewhere. From c66c296fd1994270675edc50a4467d6616e16453 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sat, 28 Oct 2017 17:10:07 +0100 Subject: [PATCH 207/265] Use React 16 in development --- packages/react-scripts/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 20f3ff814..2b793a35d 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -58,8 +58,8 @@ "whatwg-fetch": "2.0.3" }, "devDependencies": { - "react": "^15.5.4", - "react-dom": "^15.5.4" + "react": "^16.0.0", + "react-dom": "^16.0.0" }, "optionalDependencies": { "fsevents": "1.1.2" From fe4dc744d74bf7e82b5ce5293106871c5146bfb0 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sat, 28 Oct 2017 17:57:27 +0100 Subject: [PATCH 208/265] Polyfill rAF in test environment (#3340) --- packages/react-scripts/config/polyfills.js | 6 ++++++ packages/react-scripts/package.json | 1 + 2 files changed, 7 insertions(+) diff --git a/packages/react-scripts/config/polyfills.js b/packages/react-scripts/config/polyfills.js index 673fb8399..8d97fb4ac 100644 --- a/packages/react-scripts/config/polyfills.js +++ b/packages/react-scripts/config/polyfills.js @@ -22,3 +22,9 @@ 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/packages/react-scripts/package.json b/packages/react-scripts/package.json index 2b793a35d..1eedb9e99 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -48,6 +48,7 @@ "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", + "raf": "3.4.0", "react-dev-utils": "^4.1.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", From 0f5deb6a8e3e07b847c6ed9b283daa0cf622b423 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sat, 28 Oct 2017 18:38:05 +0100 Subject: [PATCH 209/265] Update appveyor.cleanup-cache.txt --- appveyor.cleanup-cache.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.cleanup-cache.txt b/appveyor.cleanup-cache.txt index 19d0b989b..ea6d1b9c0 100644 --- a/appveyor.cleanup-cache.txt +++ b/appveyor.cleanup-cache.txt @@ -3,3 +3,4 @@ http://help.appveyor.com/discussions/questions/1310-delete-cache ---- Just testing if this works. +lalala. From c51258b8a8e04af29472c384999a21e0449f388d Mon Sep 17 00:00:00 2001 From: Aaron Shafovaloff <aaronshaf@gmail.com> Date: Sat, 28 Oct 2017 14:18:01 -0600 Subject: [PATCH 210/265] recommend react-snap; react-snapshot isn't upgraded for React 16 (#3328) --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index a65970b9b..9670eac22 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1156,7 +1156,7 @@ If you use a Node server, you can even share the route matching logic between th ## Pre-Rendering into Static HTML Files -If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. +If you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded. There are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes. From d98b7565b48c46b8ddd57a8899bfa28d966e0bc4 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Sat, 28 Oct 2017 21:34:47 +0100 Subject: [PATCH 211/265] Bump dependencies (#3342) * Bump dependencies * Downgrade source-map back to 0.5.x Not sure what changed there but our bundle snapshot doesn't match with minor changes. I couldn't figure out how to update it, and also whether we need to tweak getPrettyURL in response. --- packages/babel-preset-react-app/package.json | 8 +++--- packages/react-dev-utils/package.json | 8 +++--- packages/react-error-overlay/package.json | 4 +-- packages/react-scripts/package.json | 26 ++++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 058d1a4af..d092ae9af 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -11,17 +11,17 @@ "index.js" ], "dependencies": { - "babel-plugin-dynamic-import-node": "1.0.2", + "babel-plugin-dynamic-import-node": "1.1.0", "babel-plugin-syntax-dynamic-import": "6.18.0", "babel-plugin-transform-class-properties": "6.24.1", - "babel-plugin-transform-object-rest-spread": "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.24.1", + "babel-plugin-transform-regenerator": "6.26.0", "babel-plugin-transform-runtime": "6.23.0", - "babel-preset-env": "1.5.2", + "babel-preset-env": "1.6.1", "babel-preset-react": "6.24.1" }, "peerDependencies": { diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 48e1dc49d..6e2637423 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -35,16 +35,16 @@ "webpackHotDevClient.js" ], "dependencies": { - "address": "1.0.2", - "babel-code-frame": "6.22.0", + "address": "1.0.3", + "babel-code-frame": "6.26.0", "chalk": "1.1.3", "cross-spawn": "5.1.0", "detect-port-alt": "1.1.3", "escape-string-regexp": "1.0.5", - "filesize": "3.5.10", + "filesize": "3.5.11", "global-modules": "1.0.0", "gzip-size": "3.0.0", - "inquirer": "3.2.1", + "inquirer": "3.3.0", "is-root": "1.0.0", "opn": "5.1.0", "react-error-overlay": "^2.0.2", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 9e36bf7e8..06e488cd7 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -30,8 +30,8 @@ "lib/index.js" ], "devDependencies": { - "anser": "1.4.1", - "babel-code-frame": "6.22.0", + "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", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 1eedb9e99..b6a377b00 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -21,41 +21,41 @@ "react-scripts": "./bin/react-scripts.js" }, "dependencies": { - "autoprefixer": "7.1.2", - "babel-core": "6.25.0", + "autoprefixer": "7.1.6", + "babel-core": "6.26.0", "babel-eslint": "7.2.3", "babel-jest": "20.0.3", - "babel-loader": "7.1.1", + "babel-loader": "7.1.2", "babel-preset-react-app": "^3.0.3", "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", - "css-loader": "0.28.4", + "css-loader": "0.28.7", "dotenv": "4.0.0", - "eslint": "4.4.1", + "eslint": "4.10.0", "eslint-config-react-app": "^2.0.1", "eslint-loader": "1.9.0", - "eslint-plugin-flowtype": "2.35.0", - "eslint-plugin-import": "2.7.0", + "eslint-plugin-flowtype": "2.39.1", + "eslint-plugin-import": "2.8.0", "eslint-plugin-jsx-a11y": "5.1.1", "eslint-plugin-react": "7.4.0", - "extract-text-webpack-plugin": "3.0.0", - "file-loader": "0.11.2", + "extract-text-webpack-plugin": "3.0.2", + "file-loader": "1.1.5", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", "jest": "20.0.4", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", - "postcss-loader": "2.0.6", + "postcss-loader": "2.0.8", "promise": "8.0.1", "raf": "3.4.0", "react-dev-utils": "^4.1.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", - "webpack": "3.5.1", - "webpack-dev-server": "2.8.2", - "webpack-manifest-plugin": "1.2.1", + "webpack": "3.8.1", + "webpack-dev-server": "2.9.3", + "webpack-manifest-plugin": "1.3.2", "whatwg-fetch": "2.0.3" }, "devDependencies": { From 8c7b6e766ec081dff6f26a6844463ab763aa358c Mon Sep 17 00:00:00 2001 From: Ryan Sullivan <ryansully@users.noreply.github.com> Date: Sat, 28 Oct 2017 13:39:26 -0700 Subject: [PATCH 212/265] Fix favicon sizes value in manifest (#3287) Fixes #3284. --- packages/react-scripts/template/public/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/public/manifest.json b/packages/react-scripts/template/public/manifest.json index be607e417..36680959d 100644 --- a/packages/react-scripts/template/public/manifest.json +++ b/packages/react-scripts/template/public/manifest.json @@ -4,7 +4,7 @@ "icons": [ { "src": "favicon.ico", - "sizes": "192x192", + "sizes": "64x64", "type": "image/png" } ], From 1fa16ace5f83fa0ed66c3846cb6b5fe4c86500c0 Mon Sep 17 00:00:00 2001 From: Satya van Heummen <satya.vh@gmail.com> Date: Sat, 28 Oct 2017 22:42:41 +0200 Subject: [PATCH 213/265] Make uglify work in Safari 10.0 - fixes #3280 (#3281) Implement settings as suggested here: https://github.com/mishoo/UglifyJS2/tree/harmony#mangle-options To solve this Safari bug: https://bugs.webkit.org/show_bug.cgi?id=171041 --- packages/react-scripts/config/webpack.config.prod.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 124d5b3cb..23708af5a 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -299,6 +299,9 @@ module.exports = { // 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 From 4add16dc77a7ab5a27b3ef709e69ad141a445c6e Mon Sep 17 00:00:00 2001 From: Ryan Sullivan <ryansully@users.noreply.github.com> Date: Sat, 28 Oct 2017 13:44:27 -0700 Subject: [PATCH 214/265] Add documentation for Enzyme 3 integration (#3286) This resolves #3272. --- packages/react-scripts/template/README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 9670eac22..ee3eaff5b 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1262,16 +1262,28 @@ When you encounter bugs caused by changing components, you will gain a deeper in If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: ```sh -npm install --save enzyme react-test-renderer +npm install --save enzyme enzyme-adapter-react-16 react-test-renderer ``` Alternatively you may use `yarn`: ```sh -yarn add enzyme react-test-renderer +yarn add enzyme enzyme-adapter-react-16 react-test-renderer ``` -You can write a smoke test with it too: +As of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.) + +The adapter will also need to be configured in your [global setup file](#initializing-test-environment): + +#### `src/setupTests.js` +```js +import { configure } from 'enzyme'; +import Adapter from 'enzyme-adapter-react-16'; + +configure({ adapter: new Adapter() }); +``` + +Now you can write a smoke test with it: ```js import React from 'react'; From 5c8000f300a003e9bd8aee70c0796fa4e20b34f0 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Sat, 28 Oct 2017 16:48:42 -0400 Subject: [PATCH 215/265] Add `.mjs` support (#3239) --- .../config/webpack.config.dev.js | 6 ++--- .../config/webpack.config.prod.js | 6 ++--- .../scripts/utils/createJestConfig.js | 24 +++++++++++++------ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 44669e605..c9b65984b 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -92,7 +92,7 @@ module.exports = { // https://github.com/facebookincubator/create-react-app/issues/290 // `web` extension prefixes have been added for better support // for React Native Web. - extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'], + extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'], alias: { // @remove-on-eject-begin // Resolve Babel runtime relative to react-scripts. @@ -126,7 +126,7 @@ module.exports = { // First, run the linter. // It's important to do this before Babel processes the JS. { - test: /\.(js|jsx)$/, + test: /\.(js|jsx|mjs)$/, enforce: 'pre', use: [ { @@ -164,7 +164,7 @@ module.exports = { }, // Process JS with Babel. { - test: /\.(js|jsx)$/, + test: /\.(js|jsx|mjs)$/, include: paths.appSrc, loader: require.resolve('babel-loader'), options: { diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 23708af5a..c32eb0f08 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -96,7 +96,7 @@ module.exports = { // https://github.com/facebookincubator/create-react-app/issues/290 // `web` extension prefixes have been added for better support // for React Native Web. - extensions: ['.web.js', '.js', '.json', '.web.jsx', '.jsx'], + extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'], alias: { // @remove-on-eject-begin // Resolve Babel runtime relative to react-scripts. @@ -130,7 +130,7 @@ module.exports = { // First, run the linter. // It's important to do this before Babel processes the JS. { - test: /\.(js|jsx)$/, + test: /\.(js|jsx|mjs)$/, enforce: 'pre', use: [ { @@ -169,7 +169,7 @@ module.exports = { }, // Process JS with Babel. { - test: /\.(js|jsx)$/, + test: /\.(js|jsx|mjs)$/, include: paths.appSrc, loader: require.resolve('babel-loader'), options: { diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 3e819b68e..b4c2cfa5e 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -21,27 +21,37 @@ module.exports = (resolve, rootDir, isEjecting) => { // TODO: I don't know if it's safe or not to just use / as path separator // in Jest configs. We need help from somebody with Windows to determine this. const config = { - collectCoverageFrom: ['src/**/*.{js,jsx}'], + collectCoverageFrom: ['src/**/*.{js,jsx,mjs}'], setupFiles: [resolve('config/polyfills.js')], setupTestFrameworkScriptFile: setupTestsFile, testMatch: [ - '<rootDir>/src/**/__tests__/**/*.js?(x)', - '<rootDir>/src/**/?(*.)(spec|test).js?(x)', + '<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}', + '<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}', ], testEnvironment: 'node', testURL: 'http://localhost', transform: { - '^.+\\.(js|jsx)$': isEjecting + '^.+\\.(js|jsx|mjs)$': isEjecting ? '<rootDir>/node_modules/babel-jest' : resolve('config/jest/babelTransform.js'), '^.+\\.css$': resolve('config/jest/cssTransform.js'), - '^(?!.*\\.(js|jsx|css|json)$)': resolve('config/jest/fileTransform.js'), + '^(?!.*\\.(js|jsx|mjs|css|json)$)': resolve( + 'config/jest/fileTransform.js' + ), }, - transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$'], + transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$'], moduleNameMapper: { '^react-native$': 'react-native-web', }, - moduleFileExtensions: ['web.js', 'js', 'json', 'web.jsx', 'jsx', 'node'], + moduleFileExtensions: [ + 'web.js', + 'mjs', + 'js', + 'json', + 'web.jsx', + 'jsx', + 'node', + ], }; if (rootDir) { config.rootDir = rootDir; From 70e0c08ef7de8845b1a4c6700822e27e45b481a8 Mon Sep 17 00:00:00 2001 From: Nik Nyby <nnyby@columbia.edu> Date: Sat, 28 Oct 2017 16:58:09 -0400 Subject: [PATCH 216/265] Remove output.path from dev webpack config (#3158) According to this parameter's comment, it's unused but webpack-dev-server crashes without it. However, webpack-dev-server is running fine for me without this parameter. --- packages/react-scripts/config/webpack.config.dev.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index c9b65984b..a6be022ba 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -61,8 +61,6 @@ module.exports = { // changing JS code would still trigger a refresh. ], output: { - // Next line is not used in dev but WebpackDevServer crashes without it: - path: paths.appBuild, // Add /* filename */ comments to generated require()s in the output. pathinfo: true, // This does not produce a real file. It's just the virtual path that is From 15d8e53daf3d7fee077efe3bb83a19a55fe363a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= <dunglas@gmail.com> Date: Sat, 28 Oct 2017 23:01:24 +0200 Subject: [PATCH 217/265] Remove an useless negation in registerServiceWorker.js (#3150) --- .../react-scripts/template/src/registerServiceWorker.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/template/src/registerServiceWorker.js b/packages/react-scripts/template/src/registerServiceWorker.js index 4a3ccf021..12542ba22 100644 --- a/packages/react-scripts/template/src/registerServiceWorker.js +++ b/packages/react-scripts/template/src/registerServiceWorker.js @@ -32,12 +32,12 @@ export default function register() { window.addEventListener('load', () => { const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`; - if (!isLocalhost) { - // Is not local host. Just register service worker - registerValidSW(swUrl); - } else { + if (isLocalhost) { // This is running on localhost. Lets check if a service worker still exists or not. checkValidServiceWorker(swUrl); + } else { + // Is not local host. Just register service worker + registerValidSW(swUrl); } }); } From 5a336ad117d66ac27929859987bf4ad55c73c291 Mon Sep 17 00:00:00 2001 From: captDaylight <paul.christophe6@gmail.com> Date: Sat, 28 Oct 2017 17:03:57 -0400 Subject: [PATCH 218/265] Updating the Service Worker opt-out documentation (#3108) --- packages/react-scripts/template/README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index ee3eaff5b..cd197b3b5 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1628,14 +1628,18 @@ that your web app is reliably fast, even on a slow or unreliable network. ### Opting Out of Caching If you would prefer not to enable service workers prior to your initial -production deployment, then remove the call to `serviceWorkerRegistration.register()` +production deployment, then remove the call to `registerServiceWorker()` from [`src/index.js`](src/index.js). If you had previously enabled service workers in your production deployment and have decided that you would like to disable them for all your existing users, -you can swap out the call to `serviceWorkerRegistration.register()` in -[`src/index.js`](src/index.js) with a call to `serviceWorkerRegistration.unregister()`. -After the user visits a page that has `serviceWorkerRegistration.unregister()`, +you can swap out the call to `registerServiceWorker()` in +[`src/index.js`](src/index.js) first by modifying the service worker import: +```javascript +import { unregister } from './registerServiceWorker'; +``` +and then call `unregister()` instead. +After the user visits a page that has `unregister()`, the service worker will be uninstalled. Note that depending on how `/service-worker.js` is served, it may take up to 24 hours for the cache to be invalidated. From fc885a03d9672832c2f4eec777a46ae60b304f8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hrvoje=20=C5=A0imi=C4=87?= <hrvoje@twobucks.co> Date: Sat, 28 Oct 2017 23:11:19 +0200 Subject: [PATCH 219/265] start using npm-run-all to build scss and js (#2957) instead of using `&&` to run multiple commands in `package.json`, guide users to use `npm-run-all` --- packages/react-scripts/template/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index cd197b3b5..e5acc6b77 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -599,7 +599,8 @@ Then we can change `start` and `build` scripts to include the CSS preprocessor c - "build": "react-scripts build", + "start-js": "react-scripts start", + "start": "npm-run-all -p watch-css start-js", -+ "build": "npm run build-css && react-scripts build", ++ "build-js": "react-scripts build", ++ "build": "npm-run-all build-css build-js", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject" } From e05a5fe49bdd3c2971e569901cba6c87a40bb5f1 Mon Sep 17 00:00:00 2001 From: Rami <evilchuck11@gmail.com> Date: Sat, 28 Oct 2017 22:13:02 +0100 Subject: [PATCH 220/265] Mention that start_url needs to be "." for client side routing * Change template manifest start_url to dot to make it react-router friendly * Revert "Change template manifest start_url to dot to make it react-router friendly" This reverts commit 02f53e81caea999ddba45f2cd012a9fb976c839e. * Add a note about PWA manifest and client-side routing --- packages/react-scripts/template/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index e5acc6b77..7cf2db5d5 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1836,6 +1836,12 @@ service worker navigation routing can be configured or disabled by 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: + +```js + "start_url": ".", +``` + ### Building for Relative Paths By default, Create React App produces a build assuming your app is hosted at the server root.<br> From 345f5508610a96e720b91785b49c7a934bbc477b Mon Sep 17 00:00:00 2001 From: IJAJ MULANI <ijajmulani786@gmail.com> Date: Sun, 29 Oct 2017 02:43:43 +0530 Subject: [PATCH 221/265] Fix for add .gitattributes file #3080 (#3122) --- packages/react-error-overlay/.gitattributes | 1 + 1 file changed, 1 insertion(+) create mode 100644 packages/react-error-overlay/.gitattributes diff --git a/packages/react-error-overlay/.gitattributes b/packages/react-error-overlay/.gitattributes new file mode 100644 index 000000000..cbdcbbc25 --- /dev/null +++ b/packages/react-error-overlay/.gitattributes @@ -0,0 +1 @@ +*.js text eol=lf From de1beec690acd0b0c091b4569cbf0bac7f129b42 Mon Sep 17 00:00:00 2001 From: Joe Haddad <timer150@gmail.com> Date: Mon, 30 Oct 2017 10:18:25 -0400 Subject: [PATCH 222/265] Stop using `npm link` in tests (#3345) * Try a custom function * fix path * install rsync * Test with node 8 * Ensure package is removed from the tree * Remove ours * matching functions * try cygwin * try c:/ * sigh * Try /cygdrive/ * Try /cygdrive/ * Revert "Try /cygdrive/" This reverts commit ab1ed779456d39bedbdb128a7aec3bb88b8eeb1c. * Use sub-optimal copy * Remove rsync install * Fix variable * Continue on err * Don't link react-scripts, lol * run yarn after eject * re-enable cleanup * uninstall yarn * try with force * appveyor ... seriously? * swallow bad eject * remove eject error swallow * Revert "run yarn after eject" This reverts commit eebf1dbc19aeb6e1f66d5ec27bda2d076bea0956. * Run yarn after eject * add a comment --- appveyor.yml | 6 ++--- tasks/e2e-kitchensink.sh | 55 ++++++++++++++++++++++++++++++---------- tasks/e2e-simple.sh | 40 ++++++++++++++++++++++++++--- 3 files changed, 80 insertions(+), 21 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index e00da3943..ffe48fc85 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,11 +2,11 @@ image: Visual Studio 2017 environment: matrix: - - nodejs_version: 7 + - nodejs_version: 8 test_suite: "simple" - - nodejs_version: 7 + - nodejs_version: 8 test_suite: "installs" - - nodejs_version: 7 + - nodejs_version: 8 test_suite: "kitchensink" - nodejs_version: 6 test_suite: "simple" diff --git a/tasks/e2e-kitchensink.sh b/tasks/e2e-kitchensink.sh index 3d29e8a6f..c1167c1de 100755 --- a/tasks/e2e-kitchensink.sh +++ b/tasks/e2e-kitchensink.sh @@ -44,6 +44,31 @@ function create_react_app { node "$temp_cli_path"/node_modules/create-react-app/index.js "$@" } +function install_package { + local pkg=$(basename $1) + + # Clean target (for safety) + rm -rf node_modules/$pkg/ + rm -rf node_modules/**/$pkg/ + + # Copy package into node_modules/ ignoring installed deps + # rsync -a ${1%/} node_modules/ --exclude node_modules + cp -R ${1%/} node_modules/ + rm -rf node_modules/$pkg/node_modules/ + + # Install `dependencies` + cd node_modules/$pkg/ + if [ "$USE_YARN" = "yes" ] + then + yarn install --production + else + npm install --only=production + fi + # Remove our packages to ensure side-by-side versions are used (which we link) + rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} + cd ../.. +} + # Check for the existence of one or more files. function exists { for f in $*; do @@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1 cd "$temp_app_path/test-kitchensink" # Link to our preset -npm link "$root_path"/packages/babel-preset-react-app +install_package "$root_path"/packages/babel-preset-react-app # Link to error overlay package because now it's a dependency # of react-dev-utils and not react-scripts -npm link "$root_path"/packages/react-error-overlay +install_package "$root_path"/packages/react-error-overlay # Link to test module -npm link "$temp_module_path/node_modules/test-integrity" +install_package "$temp_module_path/node_modules/test-integrity" # Test the build REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ @@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \ # Finally, let's check that everything still works after ejecting. # ****************************************************************************** -# Unlink our preset -npm unlink "$root_path"/packages/babel-preset-react-app -# Unlink error overlay -npm unlink "$root_path"/packages/react-error-overlay - # Eject... echo yes | npm run eject +# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn +# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove +# this in the near future. +if hash yarnpkg 2>/dev/null +then + yarn install --check-files +fi + # ...but still link to the local packages -npm link "$root_path"/packages/babel-preset-react-app -npm link "$root_path"/packages/eslint-config-react-app -npm link "$root_path"/packages/react-error-overlay -npm link "$root_path"/packages/react-dev-utils -npm link "$root_path"/packages/react-scripts +install_package "$root_path"/packages/babel-preset-react-app +install_package "$root_path"/packages/eslint-config-react-app +install_package "$root_path"/packages/react-error-overlay +install_package "$root_path"/packages/react-dev-utils # Link to test module -npm link "$temp_module_path/node_modules/test-integrity" +install_package "$temp_module_path/node_modules/test-integrity" # Test the build REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 2c9709546..867b6dc95 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -43,6 +43,31 @@ function create_react_app { node "$temp_cli_path"/node_modules/create-react-app/index.js "$@" } +function install_package { + local pkg=$(basename $1) + + # Clean target (for safety) + rm -rf node_modules/$pkg/ + rm -rf node_modules/**/$pkg/ + + # Copy package into node_modules/ ignoring installed deps + # rsync -a ${1%/} node_modules/ --exclude node_modules + cp -R ${1%/} node_modules/ + rm -rf node_modules/$pkg/node_modules/ + + # Install `dependencies` + cd node_modules/$pkg/ + if [ "$USE_YARN" = "yes" ] + then + yarn install --production + else + npm install --only=production + fi + # Remove our packages to ensure side-by-side versions are used (which we link) + rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts} + cd ../.. +} + # Check for the existence of one or more files. function exists { for f in $*; do @@ -306,11 +331,18 @@ verify_module_scope # Eject... echo yes | npm run eject +# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn +# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove +# this in the near future. +if hash yarnpkg 2>/dev/null +then + yarnpkg install --check-files +fi + # ...but still link to the local packages -npm link "$root_path"/packages/babel-preset-react-app -npm link "$root_path"/packages/eslint-config-react-app -npm link "$root_path"/packages/react-dev-utils -npm link "$root_path"/packages/react-scripts +install_package "$root_path"/packages/babel-preset-react-app +install_package "$root_path"/packages/eslint-config-react-app +install_package "$root_path"/packages/react-dev-utils # Test the build npm run build From 1a61cd452e8f391d676d1b6b47f163bab745c427 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Mon, 30 Oct 2017 21:24:06 +0000 Subject: [PATCH 223/265] Add preflight CWD check for npm (#3355) * Add preflight CWD check for npm * Typos --- packages/create-react-app/createReactApp.js | 79 ++++++++++++++++++++- 1 file changed, 76 insertions(+), 3 deletions(-) diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index 161beab50..9ff7c08cf 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -158,8 +158,13 @@ function createApp(name, verbose, version, template) { path.join(root, 'package.json'), JSON.stringify(packageJson, null, 2) ); + + const useYarn = shouldUseYarn(); const originalDirectory = process.cwd(); process.chdir(root); + if (!useYarn && !checkThatNpmCanReadCwd()) { + process.exit(1); + } if (!semver.satisfies(process.version, '>=6.0.0')) { console.log( @@ -172,7 +177,6 @@ function createApp(name, verbose, version, template) { version = 'react-scripts@0.9.x'; } - const useYarn = shouldUseYarn(); if (!useYarn) { const npmInfo = checkNpmVersion(); if (!npmInfo.hasMinNpm) { @@ -200,7 +204,7 @@ function shouldUseYarn() { } } -function install(useYarn, dependencies, verbose, isOnline) { +function install(root, useYarn, dependencies, verbose, isOnline) { return new Promise((resolve, reject) => { let command; let args; @@ -212,6 +216,14 @@ function install(useYarn, dependencies, verbose, isOnline) { } [].push.apply(args, dependencies); + // Explicitly set cwd() to work around issues like + // https://github.com/facebookincubator/create-react-app/issues/3326. + // Unfortunately we can only do this for Yarn because npm support for + // equivalent --prefix flag doesn't help with this issue. + // This is why for npm, we run checkThatNpmCanReadCwd() early instead. + args.push('--cwd'); + args.push(root); + if (!isOnline) { console.log(chalk.yellow('You appear to be offline.')); console.log(chalk.yellow('Falling back to the local Yarn cache.')); @@ -275,7 +287,7 @@ function run( ); console.log(); - return install(useYarn, allDependencies, verbose, isOnline).then( + return install(root, useYarn, allDependencies, verbose, isOnline).then( () => packageName ); }) @@ -606,6 +618,67 @@ function isSafeToCreateProjectIn(root, name) { return false; } +function checkThatNpmCanReadCwd() { + const cwd = process.cwd(); + let childOutput = null; + try { + // Note: intentionally using spawn over exec since + // the problem doesn't reproduce otherwise. + // `npm config list` is the only reliable way I could find + // to reproduce the wrong path. Just printing process.cwd() + // in a Node process was not enough. + childOutput = spawn.sync('npm', ['config', 'list']).output.join(''); + } catch (err) { + // Something went wrong spawning node. + // Not great, but it means we can't do this check. + // We might fail later on, but let's continue. + return true; + } + if (typeof childOutput !== 'string') { + return true; + } + const lines = childOutput.split('\n'); + // `npm config list` output includes the following line: + // "; cwd = C:\path\to\current\dir" (unquoted) + // I couldn't find an easier way to get it. + const prefix = '; cwd = '; + const line = lines.find(line => line.indexOf(prefix) === 0); + if (typeof line !== 'string') { + // Fail gracefully. They could remove it. + return true; + } + const npmCWD = line.substring(prefix.length); + if (npmCWD === cwd) { + return true; + } + console.error( + chalk.red( + `Could not start an npm process in the right directory.\n\n` + + `The current directory is: ${chalk.bold(cwd)}\n` + + `However, a newly started npm process runs in: ${chalk.bold( + npmCWD + )}\n\n` + + `This is probably caused by a misconfigured system terminal shell.` + ) + ); + if (process.platform === 'win32') { + console.error( + chalk.red(`On Windows, this can usually be fixed by running:\n\n`) + + ` ${chalk.cyan( + 'reg' + )} delete "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n` + + ` ${chalk.cyan( + 'reg' + )} delete "HKLM\\Software\\Microsoft\\Command Processor" /v AutoRun /f\n\n` + + chalk.red(`Try to run the above two lines in the terminal.\n`) + + chalk.red( + `To learn more about this problem, read: https://blogs.msdn.microsoft.com/oldnewthing/20071121-00/?p=24433/` + ) + ); + } + return false; +} + function checkIfOnline(useYarn) { if (!useYarn) { // Don't ping the Yarn registry. From 5e7b9675aa66de7ec73addfd15ec81b2e5eb7300 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Mon, 30 Oct 2017 21:48:34 +0000 Subject: [PATCH 224/265] Publish - babel-preset-react-app@3.1.0 - react-dev-utils@4.2.0 - react-error-overlay@3.0.0 - react-scripts@1.0.15 --- packages/babel-preset-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 4 ++-- packages/react-error-overlay/package.json | 4 ++-- packages/react-scripts/package.json | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index d092ae9af..f020f99e0 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -1,6 +1,6 @@ { "name": "babel-preset-react-app", - "version": "3.0.3", + "version": "3.1.0", "description": "Babel preset used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 6e2637423..fe242cfed 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "4.1.0", + "version": "4.2.0", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -47,7 +47,7 @@ "inquirer": "3.3.0", "is-root": "1.0.0", "opn": "5.1.0", - "react-error-overlay": "^2.0.2", + "react-error-overlay": "^3.0.0", "recursive-readdir": "2.2.1", "shell-quote": "1.6.1", "sockjs-client": "1.1.4", diff --git a/packages/react-error-overlay/package.json b/packages/react-error-overlay/package.json index 06e488cd7..d4e528ea6 100644 --- a/packages/react-error-overlay/package.json +++ b/packages/react-error-overlay/package.json @@ -1,6 +1,6 @@ { "name": "react-error-overlay", - "version": "2.0.2", + "version": "3.0.0", "description": "An overlay for displaying stack frames.", "main": "lib/index.js", "scripts": { @@ -35,7 +35,7 @@ "babel-core": "^6.26.0", "babel-eslint": "7.2.3", "babel-loader": "^7.1.2", - "babel-preset-react-app": "^3.0.3", + "babel-preset-react-app": "^3.1.0", "babel-runtime": "6.26.0", "chalk": "^2.1.0", "chokidar": "^1.7.0", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index b6a377b00..d506fee50 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.14", + "version": "1.0.15", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -26,7 +26,7 @@ "babel-eslint": "7.2.3", "babel-jest": "20.0.3", "babel-loader": "7.1.2", - "babel-preset-react-app": "^3.0.3", + "babel-preset-react-app": "^3.1.0", "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", @@ -49,7 +49,7 @@ "postcss-loader": "2.0.8", "promise": "8.0.1", "raf": "3.4.0", - "react-dev-utils": "^4.1.0", + "react-dev-utils": "^4.2.0", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", From 87643fdb2f6740954b57b22120dc249bca16c021 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Mon, 30 Oct 2017 21:56:37 +0000 Subject: [PATCH 225/265] CLI@1.4.2 Lerna is acting up. --- packages/create-react-app/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 73400bb03..962f3d2cc 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,6 +1,6 @@ { "name": "create-react-app", - "version": "1.4.1", + "version": "1.4.2", "keywords": [ "react" ], From e62bfdd7ce7fb9f305e0f0591d2c63c535189eb2 Mon Sep 17 00:00:00 2001 From: Pete Feltham <peter@feltham.com.au> Date: Tue, 31 Oct 2017 16:22:25 +1100 Subject: [PATCH 226/265] Replace template literal; fixes #3367 (#3368) --- packages/react-dev-utils/webpackHotDevClient.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-dev-utils/webpackHotDevClient.js b/packages/react-dev-utils/webpackHotDevClient.js index e375c3fab..296e38046 100644 --- a/packages/react-dev-utils/webpackHotDevClient.js +++ b/packages/react-dev-utils/webpackHotDevClient.js @@ -26,7 +26,8 @@ var ErrorOverlay = require('react-error-overlay'); ErrorOverlay.setEditorHandler(function editorHandler(errorLocation) { // Keep this sync with errorOverlayMiddleware.js fetch( - `${launchEditorEndpoint}?fileName=` + + launchEditorEndpoint + + '?fileName=' + window.encodeURIComponent(errorLocation.fileName) + '&lineNumber=' + window.encodeURIComponent(errorLocation.lineNumber || 1) From a9257ec978036f739f78cbda5027efdef96e8c35 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Mon, 30 Oct 2017 21:40:36 +0000 Subject: [PATCH 227/265] Changelog for 1.0.15 (#3357) * Changelog for 1.0.15 * Update CHANGELOG.md * Update CHANGELOG.md --- CHANGELOG.md | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f50c8e5..68b17fc62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,119 @@ +## 1.0.15 (October 30, 2017) + +#### :bug: Bug Fix + +* `react-scripts` + + * [#3287](https://github.com/facebookincubator/create-react-app/pull/3287) Fix favicon sizes value in the project manifest. ([@ryansully](https://github.com/ryansully)) + +* `react-dev-utils`, `react-scripts` + + * [#3230](https://github.com/facebookincubator/create-react-app/pull/3230) Fix watching for changes in `src/node_modules`. ([@xjlim](https://github.com/xjlim)) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#3239](https://github.com/facebookincubator/create-react-app/pull/3239) Allow importing `.mjs` files. ([@Timer](https://github.com/Timer)) + * [#3340](https://github.com/facebookincubator/create-react-app/pull/3340) Polyfill `requestAnimationFrame` in test environment. ([@gaearon](https://github.com/gaearon)) + +* `babel-preset-react-app`, `react-dev-utils`, `react-error-overlay`, `react-scripts` + + * [#3342](https://github.com/facebookincubator/create-react-app/pull/3342) Bump dependencies. ([@gaearon](https://github.com/gaearon)) + +* `react-dev-utils`, `react-error-overlay` + + * [#3100](https://github.com/facebookincubator/create-react-app/pull/3100) Add click-to-open support for build errors. ([@tharakawj](https://github.com/tharakawj)) + +* `create-react-app` + + * [#3355](https://github.com/facebookincubator/create-react-app/pull/3355) Add preflight CWD check for npm to detect bad Windows setups. ([@gaearon](https://github.com/gaearon)) + +#### :memo: Documentation + +* User Guide + + * [#2957](https://github.com/facebookincubator/create-react-app/pull/2957) Use `npm-run-all` to build Sass and JS. ([@shime](https://github.com/shime)) + * [#3108](https://github.com/facebookincubator/create-react-app/pull/3108) Update the Service Worker opt-out documentation. ([@captDaylight](https://github.com/captDaylight)) + * [#3286](https://github.com/facebookincubator/create-react-app/pull/3286) Add documentation for Enzyme 3 integration. ([@ryansully](https://github.com/ryansully)) + * [#3328](https://github.com/facebookincubator/create-react-app/pull/3328) Recommend react-snap as an alternative to react-snapshot. ([@aaronshaf](https://github.com/aaronshaf)) + * [#3279](https://github.com/facebookincubator/create-react-app/pull/3279) Add jest coverage configuration docs. ([@mattphillips](https://github.com/mattphillips)) + * [#3303](https://github.com/facebookincubator/create-react-app/pull/3303) Update link to Jest Expect docs. ([@jbranchaud](https://github.com/jbranchaud)) + * [#3289](https://github.com/facebookincubator/create-react-app/pull/3289) Fix dead link to Jest "expect" docs. ([@alexkrolick](https://github.com/alexkrolick)) + * [#3265](https://github.com/facebookincubator/create-react-app/pull/3265) Add external links to deployment services. ([@aericson](https://github.com/aericson)) + * [#3075](https://github.com/facebookincubator/create-react-app/pull/3075) Minor docs change to highlight dev proxy behaviour. ([@davidjb](https://github.com/davidjb)) + * [#3185](https://github.com/facebookincubator/create-react-app/pull/3185) Correct manual proxy documentation. ([@robertpanzer](https://github.com/robertpanzer)) + +* README + + * [#3227](https://github.com/facebookincubator/create-react-app/pull/3227) Fix package management link in README for issue #3218. ([@nishina555](https://github.com/nishina555)) + * [#3211](https://github.com/facebookincubator/create-react-app/pull/3211) Improve grammar in README. ([@Mohamed3on](https://github.com/Mohamed3on)) + +#### :house: Internal + +* Other + + * [#3345](https://github.com/facebookincubator/create-react-app/pull/3345) Stop using `npm link` in tests. ([@Timer](https://github.com/Timer)) + +* `react-error-overlay` + + * [#3122](https://github.com/facebookincubator/create-react-app/pull/3122) Fix for add .gitattributes file #3080. ([@ijajmulani](https://github.com/ijajmulani)) + * [#3267](https://github.com/facebookincubator/create-react-app/pull/3267) Use production React version for bundled overlay. ([@Timer](https://github.com/Timer)) + * [#3264](https://github.com/facebookincubator/create-react-app/pull/3264) Add warning when using `react-error-overlay` in production. ([@Timer](https://github.com/Timer)) + * [#3263](https://github.com/facebookincubator/create-react-app/pull/3263) `react-error-overlay` has no dependencies now (it's bundled). ([@Timer](https://github.com/Timer)) + * [#3142](https://github.com/facebookincubator/create-react-app/pull/3142) Make error overlay run in the context of the iframe. ([@tharakawj](https://github.com/tharakawj)) + +* `react-scripts` + + * [#3150](https://github.com/facebookincubator/create-react-app/pull/3150) Remove an useless negation in `registerServiceWorker.js`. ([@dunglas](https://github.com/dunglas)) + * [#3158](https://github.com/facebookincubator/create-react-app/pull/3158) Remove `output.path` from dev webpack config. ([@nikolas](https://github.com/nikolas)) + * [#3281](https://github.com/facebookincubator/create-react-app/pull/3281) Add a workaround for Uglify incompatiblity with Safari 10.0 in the future. ([@satyavh](https://github.com/satyavh)) + * [#3146](https://github.com/facebookincubator/create-react-app/pull/3146) Fix `reason-react` support. ([@lpalmes](https://github.com/lpalmes)) + * [#3236](https://github.com/facebookincubator/create-react-app/pull/3236) Update `style-loader` and disable inclusion of its HMR code in builds. ([@insin](https://github.com/insin)) + * [#3246](https://github.com/facebookincubator/create-react-app/pull/3246) Update `url-loader` to 0.6.2 for mime ReDoS vulnerability. ([@d3viant0ne](https://github.com/d3viant0ne)) + * [#2914](https://github.com/facebookincubator/create-react-app/pull/2914) `<!doctype html>` -> `<!DOCTYPE html>`. ([@Hurtak](https://github.com/Hurtak)) + +#### Committers: 24 + +- Aaron Shafovaloff ([aaronshaf](https://github.com/aaronshaf)) +- Alex ([alexkrolick](https://github.com/alexkrolick)) +- André Ericson ([aericson](https://github.com/aericson)) +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- David Beitey ([davidjb](https://github.com/davidjb)) +- Hrvoje Šimić ([shime](https://github.com/shime)) +- IJAJ MULANI ([ijajmulani](https://github.com/ijajmulani)) +- Joe Haddad ([Timer](https://github.com/Timer)) +- Joe Lim ([xjlim](https://github.com/xjlim)) +- Jonny Buchanan ([insin](https://github.com/insin)) +- Josh Branchaud ([jbranchaud](https://github.com/jbranchaud)) +- Joshua Wiens ([d3viant0ne](https://github.com/d3viant0ne)) +- Kévin Dunglas ([dunglas](https://github.com/dunglas)) +- Lorenzo Palmes ([lpalmes](https://github.com/lpalmes)) +- Matt Phillips ([mattphillips](https://github.com/mattphillips)) +- Mohamed Oun ([Mohamed3on](https://github.com/Mohamed3on)) +- Nik Nyby ([nikolas](https://github.com/nikolas)) +- Petr Huřťák ([Hurtak](https://github.com/Hurtak)) +- Robert Panzer ([robertpanzer](https://github.com/robertpanzer)) +- Ryan Sullivan ([ryansully](https://github.com/ryansully)) +- Satya van Heummen ([satyavh](https://github.com/satyavh)) +- Tharaka Wijebandara ([tharakawj](https://github.com/tharakawj)) +- Toshiharu Nishina ([nishina555](https://github.com/nishina555)) +- [captDaylight](https://github.com/captDaylight) + +### Migrating from 1.0.14 to 1.0.15 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.15 +``` + +or + +``` +yarn add --exact react-scripts@1.0.15 +``` + ## 1.0.14 (September 26, 2017) #### :bug: Bug Fix From 1740c3fe61fc48df429b609af5ee2ccd38e1c7a4 Mon Sep 17 00:00:00 2001 From: Piotr <hello@piotr.cz> Date: Tue, 31 Oct 2017 11:25:11 +0100 Subject: [PATCH 228/265] Update favicon description (#3374) --- packages/react-scripts/template/public/manifest.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/public/manifest.json b/packages/react-scripts/template/public/manifest.json index 36680959d..ef19ec243 100644 --- a/packages/react-scripts/template/public/manifest.json +++ b/packages/react-scripts/template/public/manifest.json @@ -4,8 +4,8 @@ "icons": [ { "src": "favicon.ico", - "sizes": "64x64", - "type": "image/png" + "sizes": "64x64 32x32 24x24 16x16", + "type": "image/x-icon" } ], "start_url": "./index.html", From 7ae6ab101714296aceab6223a087388862229e50 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Tue, 31 Oct 2017 10:38:03 +0000 Subject: [PATCH 229/265] Changelog for 1.0.16 (#3376) --- CHANGELOG.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68b17fc62..3974893e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,34 @@ +## 1.0.16 (October 31, 2017) 🎃 + +#### :bug: Bug Fix + +* `react-scripts` + + * [#3374](https://github.com/facebookincubator/create-react-app/pull/3374) Set correct image type and sizes in `manifest.json`. ([@piotr-cz](https://github.com/piotr-cz)) + +* `react-dev-utils` + + * [#3368](https://github.com/facebookincubator/create-react-app/pull/3368) Fix a crash in development mode in older browsers. ([@felthy](https://github.com/felthy)) + +#### Committers: 2 + +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Piotr ([piotr-cz](https://github.com/piotr-cz)) + +### Migrating from 1.0.15 to 1.0.16 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.16 +``` + +or + +``` +yarn add --exact react-scripts@1.0.16 +``` + ## 1.0.15 (October 30, 2017) #### :bug: Bug Fix From b8e6ba3c4a9e68b8bffbbb3d9c060e5e41813696 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Tue, 31 Oct 2017 10:40:27 +0000 Subject: [PATCH 230/265] Reorder publishing instructions --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68a9c4e09..86b392f2f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -108,9 +108,9 @@ More detailed information are in the dedicated [README](/packages/react-scripts/ * Add a four-space indented paragraph after each non-trivial list item, explaining what changed and why. For each breaking change also write who it affects and instructions for migrating existing code. * Maybe add some newlines here and there. Preview the result on GitHub to get a feel for it. Changelog generator output is a bit too terse for my taste, so try to make it visually pleasing and well grouped. 6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them. -7. After merging the changelog update, create a GitHub Release with the same text. See previous Releases for inspiration. -8. **Do not run `npm publish`. Instead, run `npm run publish`.** -9. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages. +7. **Do not run `npm publish`. Instead, run `npm run publish`.** +8. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages. +9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration. Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- --tag next` instead of `npm run publish`. From dc95d18c9ccbf69ccc2e85b11de638f6462d7181 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Tue, 31 Oct 2017 10:41:25 +0000 Subject: [PATCH 231/265] Publish - create-react-app@1.4.3 - react-dev-utils@4.2.1 - react-scripts@1.0.16 --- packages/create-react-app/package.json | 2 +- packages/react-dev-utils/package.json | 2 +- packages/react-scripts/package.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/create-react-app/package.json b/packages/create-react-app/package.json index 962f3d2cc..569985f5c 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,6 +1,6 @@ { "name": "create-react-app", - "version": "1.4.2", + "version": "1.4.3", "keywords": [ "react" ], diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index fe242cfed..db7114a26 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "4.2.0", + "version": "4.2.1", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "MIT", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index d506fee50..8e24165e8 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.15", + "version": "1.0.16", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "MIT", @@ -49,7 +49,7 @@ "postcss-loader": "2.0.8", "promise": "8.0.1", "raf": "3.4.0", - "react-dev-utils": "^4.2.0", + "react-dev-utils": "^4.2.1", "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", From 74c523c461dda80fe35b60afa6f0956480ca6206 Mon Sep 17 00:00:00 2001 From: Ryan Swapp <ryancswapp@gmail.com> Date: Thu, 2 Nov 2017 11:54:40 -0600 Subject: [PATCH 232/265] Update README.md (#3392) Fixed a small grammatical issue that I noticed while browsing the README today --- packages/react-scripts/template/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 7cf2db5d5..13576b6e2 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -911,7 +911,7 @@ REACT_APP_SECRET_CODE=abcdef `.env` files **should be** checked into source control (with the exclusion of `.env*.local`). -#### What other `.env` files are can be used? +#### What other `.env` files can be used? >Note: this feature is **available with `react-scripts@1.0.0` and higher**. From 35fa70e9243dc1a322ed343d136f0e2c3159e024 Mon Sep 17 00:00:00 2001 From: Kenneth Auchenberg <kenneth@auchenberg.dk> Date: Fri, 3 Nov 2017 11:08:24 -0700 Subject: [PATCH 233/265] Update VS Code debug configuration (#3400) --- packages/react-scripts/template/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 13576b6e2..6842ed635 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -262,7 +262,6 @@ Then add the block below to your `launch.json` file and put it inside the `.vsco "request": "launch", "url": "http://localhost:3000", "webRoot": "${workspaceRoot}/src", - "userDataDir": "${workspaceRoot}/.vscode/chrome", "sourceMapPathOverrides": { "webpack:///src/*": "${webRoot}/*" } From 2cb48716ec567a7f578154c10d5bdfac26eb43d8 Mon Sep 17 00:00:00 2001 From: Kenneth Auchenberg <kenneth@auchenberg.dk> Date: Fri, 3 Nov 2017 11:09:29 -0700 Subject: [PATCH 234/265] Add link to VS Code troubleshooting guide (#3399) * Add link to VS Code troubleshooting guide * Update README.md --- packages/react-scripts/template/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 6842ed635..0322806f0 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -272,6 +272,8 @@ Then add the block below to your `launch.json` file and put it inside the `.vsco Start your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor. +Having problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting). + ### WebStorm You would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed. From 90c83f79273b6eabc9ef2eb342c81ff39d29829d Mon Sep 17 00:00:00 2001 From: Loren Sands-Ramshaw <lorensr@gmail.com> Date: Fri, 3 Nov 2017 14:11:12 -0400 Subject: [PATCH 235/265] Fix grammar in README (#3394) "subway" by itself is not a proper noun --- packages/react-scripts/template/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 0322806f0..b8c0b74df 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -204,7 +204,7 @@ In addition to [ES6](https://github.com/lukehoban/es6features) syntax features, Learn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-). -While we recommend to use experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future. +While we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future. Note that **the project only includes a few ES6 [polyfills](https://en.wikipedia.org/wiki/Polyfill)**: @@ -1616,7 +1616,7 @@ By default, the production build is a fully functional, offline-first Progressive Web Apps are faster and more reliable than traditional web pages, and provide an engaging mobile experience: * All static site assets are cached so that your page loads fast on subsequent visits, regardless of network connectivity (such as 2G or 3G). Updates are downloaded in the background. - * Your app will work regardless of network state, even if offline. This means your users will be able to use your app at 10,000 feet and on the Subway. + * Your app will work regardless of network state, even if offline. This means your users will be able to use your app at 10,000 feet and on the subway. * On mobile devices, your app can be added directly to the user's home screen, app icon and all. You can also re-engage users using web **push notifications**. This eliminates the need for the app store. The [`sw-precache-webpack-plugin`](https://github.com/goldhand/sw-precache-webpack-plugin) From 5811d55f700cdecbf1f661f17f19f00c3372d661 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Fri, 3 Nov 2017 18:18:57 +0000 Subject: [PATCH 236/265] Use new WebpackDevServer option (#3401) --- packages/react-scripts/config/webpackDevServer.config.js | 2 +- packages/react-scripts/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index f401f2cce..5ff5d0abb 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -94,7 +94,7 @@ module.exports = function(proxy, allowedHost) { }, public: allowedHost, proxy, - setup(app) { + before(app) { // This lets us open files from the runtime error overlay. app.use(errorOverlayMiddleware()); // This service worker file is effectively a 'no-op' that will reset any diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 8e24165e8..1767ac231 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -54,7 +54,7 @@ "sw-precache-webpack-plugin": "0.11.4", "url-loader": "0.6.2", "webpack": "3.8.1", - "webpack-dev-server": "2.9.3", + "webpack-dev-server": "2.9.4", "webpack-manifest-plugin": "1.3.2", "whatwg-fetch": "2.0.3" }, From cfbd468ae39f203b377ab00d4f93a73488886fe1 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Fri, 3 Nov 2017 18:27:24 +0000 Subject: [PATCH 237/265] Add 1.0.17 changelog (#3402) --- CHANGELOG.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3974893e3..f233de0ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,38 @@ +## 1.0.17 (November 3, 2017) + +#### :nail_care: Enhancement + +* `react-scripts` + + * [#3401](https://github.com/facebookincubator/create-react-app/pull/3401) Stop using a deprecated option. ([@gaearon](https://github.com/gaearon)) + +#### :memo: Documentation + +* `react-scripts` + + * [#3399](https://github.com/facebookincubator/create-react-app/pull/3399) Add link to VS Code troubleshooting guide. ([@auchenberg](https://github.com/auchenberg)) + * [#3400](https://github.com/facebookincubator/create-react-app/pull/3400) Update VS Code debug configuration. ([@auchenberg](https://github.com/auchenberg)) + +#### Committers: 3 + +- Dan Abramov ([gaearon](https://github.com/gaearon)) +- Kenneth Auchenberg ([auchenberg](https://github.com/auchenberg)) +- Loren Sands-Ramshaw ([lorensr](https://github.com/lorensr)) + +### Migrating from 1.0.16 to 1.0.17 + +Inside any created project that has not been ejected, run: + +``` +npm install --save --save-exact react-scripts@1.0.17 +``` + +or + +``` +yarn add --exact react-scripts@1.0.17 +``` + ## 1.0.16 (October 31, 2017) 🎃 #### :bug: Bug Fix From 4b55193f0ad479f26b0f5e153bb4b152a1ee03e7 Mon Sep 17 00:00:00 2001 From: Dan Abramov <dan.abramov@gmail.com> Date: Fri, 3 Nov 2017 18:27:41 +0000 Subject: [PATCH 238/265] Publish - react-scripts@1.0.17 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 1767ac231..dcac53cf4 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "1.0.16", + "version": "1.0.17", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "MIT", From 9e4589f48eb30f356a71912a4786d8624650da9f Mon Sep 17 00:00:00 2001 From: Will Monk <will@williammonk.co.uk> Date: Mon, 27 Nov 2017 17:10:02 +0000 Subject: [PATCH 239/265] Merge pull request #165 from johnnyreilly/master Add support for fork-ts-checker-webpack-plugin --- packages/react-scripts/config/paths.js | 10 ++-- .../config/webpack.config.dev.js | 26 +++++---- .../config/webpack.config.prod.js | 20 +++++-- packages/react-scripts/package.json | 54 +++++++++++-------- 4 files changed, 71 insertions(+), 39 deletions(-) diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index e860d9b04..76c165ba4 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -43,8 +43,8 @@ const getPublicUrl = appPackageJson => // like /todos/42/static/js/bundle.7289d.js. We have to know the root. function getServedPath(appPackageJson) { const publicUrl = getPublicUrl(appPackageJson); - const servedUrl = - envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/'); + const servedUrl = envPublicUrl || + (publicUrl ? url.parse(publicUrl).pathname : '/'); return ensureSlash(servedUrl, true); } @@ -61,6 +61,7 @@ module.exports = { testsSetup: resolveApp('src/setupTests.ts'), appNodeModules: resolveApp('node_modules'), appTsConfig: resolveApp('tsconfig.json'), + appTsLint: resolveApp('tslint.json'), publicUrl: getPublicUrl(resolveApp('package.json')), servedPath: getServedPath(resolveApp('package.json')), }; @@ -83,6 +84,7 @@ module.exports = { appNodeModules: resolveApp('node_modules'), appTsConfig: resolveApp('tsconfig.json'), appTsTestConfig: resolveApp('tsconfig.test.json'), + appTsLint: resolveApp('tslint.json'), publicUrl: getPublicUrl(resolveApp('package.json')), servedPath: getServedPath(resolveApp('package.json')), // These properties only exist before ejecting: @@ -92,8 +94,7 @@ module.exports = { const ownPackageJson = require('../package.json'); const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`); -const reactScriptsLinked = - fs.existsSync(reactScriptsPath) && +const reactScriptsLinked = fs.existsSync(reactScriptsPath) && fs.lstatSync(reactScriptsPath).isSymbolicLink(); // config before publish: we're in ./packages/react-scripts/config/ @@ -114,6 +115,7 @@ if ( testsSetup: resolveOwn('template/src/setupTests.ts'), appNodeModules: resolveOwn('node_modules'), appTsConfig: resolveOwn('template/tsconfig.json'), + appTsLint: resolveOwn('template/tslint.json'), appTsTestConfig: resolveOwn('template/tsconfig.test.json'), publicUrl: getPublicUrl(resolveOwn('package.json')), servedPath: getServedPath(resolveOwn('package.json')), diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 07c0a3adf..6c619f4f4 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -18,6 +18,7 @@ const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin'); const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const getClientEnvironment = require('./env'); const paths = require('./paths'); @@ -134,14 +135,6 @@ module.exports = { // We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176. // { parser: { requireEnsure: false } }, - // First, run the linter. - // It's important to do this before Babel processes the JS. - { - test: /\.(ts|tsx)$/, - loader: require.resolve('tslint-loader'), - enforce: 'pre', - include: paths.appSrc, - }, { test: /\.js$/, loader: require.resolve('source-map-loader'), @@ -168,7 +161,15 @@ module.exports = { { test: /\.(ts|tsx)$/, include: paths.appSrc, - loader: require.resolve('ts-loader'), + use: [ + { + loader: require.resolve('ts-loader'), + options: { + // disable type checker - we will use it in fork plugin + transpileOnly: true, + }, + }, + ], }, // "postcss" loader applies autoprefixer to our CSS. // "css" loader resolves paths in CSS and adds assets as dependencies. @@ -262,6 +263,13 @@ module.exports = { // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack // You can remove this if you don't use Moment.js: new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), + // Perform type checking and linting in a separate process to speed up compilation + new ForkTsCheckerWebpackPlugin({ + async: false, + watch: paths.appSrc, + tsconfig: paths.appTsConfig, + tslint: paths.appTsLint, + }), ], // Some libraries import Node modules but don't use them in the browser. // Tell Webpack to provide empty mocks for them so importing them works. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 9582ee731..366dcd108 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -19,6 +19,7 @@ const ManifestPlugin = require('webpack-manifest-plugin'); const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin'); const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const paths = require('./paths'); const getClientEnvironment = require('./env'); @@ -137,7 +138,6 @@ module.exports = { // 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 } }, - // First, run the linter. // It's important to do this before Typescript runs. { @@ -167,11 +167,19 @@ module.exports = { name: 'static/media/[name].[hash:8].[ext]', }, }, - //Compile .tsx? + // Compile .tsx? { test: /\.(ts|tsx)$/, include: paths.appSrc, - loader: require.resolve('ts-loader') + use: [ + { + loader: require.resolve('ts-loader'), + options: { + // disable type checker - we will use it in fork plugin + transpileOnly: true, + }, + }, + ], }, // The notation here is somewhat confusing. // "postcss" loader applies autoprefixer to our CSS. @@ -341,6 +349,12 @@ module.exports = { // https://github.com/jmblog/how-to-optimize-momentjs-with-webpack // You can remove this if you don't use Moment.js: new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), + // Perform type checking and linting in a separate process to speed up compilation + new ForkTsCheckerWebpackPlugin({ + async: false, + tsconfig: paths.appTsConfig, + tslint: paths.appTsLint, + }), ], // Some libraries import Node modules but don't use them in the browser. // Tell Webpack to provide empty mocks for them so importing them works. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 01bb852f5..e299a11b7 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,9 +1,9 @@ { "name": "react-scripts-ts", - "version": "2.8.0", + "version": "2.9.0", "description": "Configuration and scripts for Create React App.", "repository": "wmonk/create-react-app", - "license": "BSD-3-Clause", + "license": "MIT", "engines": { "node": ">=6" }, @@ -21,41 +21,49 @@ "react-scripts-ts": "./bin/react-scripts-ts.js" }, "dependencies": { - "autoprefixer": "7.1.2", + "autoprefixer": "7.1.6", + "babel-core": "6.26.0", + "babel-eslint": "7.2.3", + "babel-jest": "20.0.3", + "babel-loader": "7.1.2", + "babel-preset-react-app": "^3.1.0", + "babel-runtime": "6.26.0", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", - "css-loader": "0.28.4", + "css-loader": "0.28.7", "dotenv": "4.0.0", - "extract-text-webpack-plugin": "3.0.0", - "file-loader": "0.11.2", + "extract-text-webpack-plugin": "3.0.2", + "file-loader": "1.1.5", + "fork-ts-checker-webpack-plugin": "^0.2.8", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", "jest": "20.0.4", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", - "postcss-loader": "2.0.6", + "postcss-loader": "2.0.8", "promise": "8.0.1", - "react-dev-utils": "^4.0.1", - "style-loader": "0.18.2", - "ts-jest": "^20.0.7", - "ts-loader": "^2.3.7", - "tslint": "^5.7.0", - "tslint-loader": "^3.5.3", - "tslint-react": "^3.2.0", - "typescript": "~2.5.3", - "source-map-loader": "^0.2.1", + "raf": "3.4.0", + "react-dev-utils": "^4.2.1", + "style-loader": "0.19.0", "sw-precache-webpack-plugin": "0.11.4", - "url-loader": "0.5.9", - "webpack": "3.5.1", - "webpack-dev-server": "2.7.1", - "webpack-manifest-plugin": "1.2.1", - "whatwg-fetch": "2.0.3" + "url-loader": "0.6.2", + "webpack": "3.8.1", + "webpack-dev-server": "2.9.4", + "webpack-manifest-plugin": "1.3.2", + "whatwg-fetch": "2.0.3", + "ts-jest": "^21.1.4", + "ts-loader": "^3.1.1", + "tslint": "^5.8.0", + "tslint-react": "^3.2.0", + "typescript": "~2.6.1", + "source-map-loader": "^0.2.3" }, "devDependencies": { - "react": "^15.5.4", - "react-dom": "^15.5.4" + "react": "^16.0.0", + "react-dom": "^16.0.0" }, "optionalDependencies": { "fsevents": "1.1.2" } } + From 05d5a6cbbb2f60a3547ff581c4aa647844883612 Mon Sep 17 00:00:00 2001 From: Christian Linne <ShadowVampire@web.de> Date: Thu, 30 Nov 2017 19:48:42 +0100 Subject: [PATCH 240/265] Merge pull request #199 from DorianGrey/master Adjust 'Testing components' section to use the correct TS versions. --- packages/react-scripts/template/README.md | 36 ++++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index c55ccdf94..36dcb1c40 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1244,9 +1244,9 @@ There is a broad spectrum of component testing techniques. They range from a “ Different projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components: -```js -import React from 'react'; -import ReactDOM from 'react-dom'; +```ts +import * as React from 'react'; +import * asReactDOM from 'react-dom'; import App from './App'; it('renders without crashing', () => { @@ -1255,26 +1255,34 @@ it('renders without crashing', () => { }); ``` -This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`. +This test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.tsx`. When you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior. If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: ```sh -npm install --save enzyme react-test-renderer +npm install --save enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer ``` Alternatively you may use `yarn`: ```sh -yarn add enzyme react-test-renderer +yarn add enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer +``` + +#### `src/setupTests.ts` +```ts +import * as Enzyme from 'enzyme'; +import * as Adapter from 'enzyme-adapter-react-16'; + +Enzyme.configure({ adapter: new Adapter() }); ``` You can write a smoke test with it too: -```js -import React from 'react'; +```ts +import * as React from 'react'; import { shallow } from 'enzyme'; import App from './App'; @@ -1289,8 +1297,8 @@ You can read the [Enzyme documentation](http://airbnb.io/enzyme/) for more testi Here is an example from Enzyme documentation that asserts specific output, rewritten to use Jest matchers: -```js -import React from 'react'; +```ts +import * as React from 'react'; import { shallow } from 'enzyme'; import App from './App'; @@ -1323,7 +1331,7 @@ Alternatively you may use `yarn`: yarn add jest-enzyme ``` -Import it in [`src/setupTests.js`](#initializing-test-environment) to make its matchers available in every test: +Import it in [`src/setupTests.ts`](#initializing-test-environment) to make its matchers available in every test: ```js import 'jest-enzyme'; @@ -1346,12 +1354,12 @@ and then use them in your tests like you normally do. >Note: this feature is available with `react-scripts@0.4.0` and higher. -If your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.js` to your project. It will be automatically executed before running your tests. +If your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.ts` to your project. It will be automatically executed before running your tests. For example: -#### `src/setupTests.js` -```js +#### `src/setupTests.ts` +```ts const localStorageMock = { getItem: jest.fn(), setItem: jest.fn(), From 586a50fb207fedd02b3a4d1552e46dd4e8cbe348 Mon Sep 17 00:00:00 2001 From: Christian Linne <ShadowVampire@web.de> Date: Wed, 6 Dec 2017 12:40:58 +0100 Subject: [PATCH 241/265] Merge pull request #201 from StefanSchoof/patch-1 Add link to typescript User Guide --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index fddffcbdd..038ab1233 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ Create React apps (with Typescript) with no build configuration. + * [Getting Started](#tldr) – How to create a new app. + * [User Guide](https://github.com/wmonk/create-react-app-typescript/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with react scripts ts. + _Do you know react and want to try out typescript? Or do you know typescript and want to try out react?_ Get all the benefits from `create-react-app` but you use typescript! 🚀 ## tl;dr From 10d283eae30c2bce148286bba1688de19af6fd51 Mon Sep 17 00:00:00 2001 From: Christian Linne <ShadowVampire@web.de> Date: Wed, 6 Dec 2017 18:48:28 +0100 Subject: [PATCH 242/265] Merge pull request #204 from StefanSchoof/patch-1 @types into devDependencies --- packages/react-scripts/template/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 36dcb1c40..c57a0ebd7 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -1262,13 +1262,13 @@ When you encounter bugs caused by changing components, you will gain a deeper in If you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run: ```sh -npm install --save enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer +npm install --save-dev enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer ``` Alternatively you may use `yarn`: ```sh -yarn add enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer +yarn add --dev enzyme @types/enzyme enzyme-adapter-react-16 @types/enzyme-adapter-react-16 react-test-renderer @types/react-test-renderer ``` #### `src/setupTests.ts` From cc52d217b48f7f958b161e2e95ce61c8d71260b3 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Thu, 11 Jan 2018 08:44:27 +0000 Subject: [PATCH 243/265] Fix package.json --- packages/react-scripts/package.json | 52 +++++++++++++---------------- 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index e299a11b7..cc3a6f9d1 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,9 +1,9 @@ { "name": "react-scripts-ts", - "version": "2.9.0", + "version": "2.8.0", "description": "Configuration and scripts for Create React App.", "repository": "wmonk/create-react-app", - "license": "MIT", + "license": "BSD-3-Clause", "engines": { "node": ">=6" }, @@ -21,46 +21,40 @@ "react-scripts-ts": "./bin/react-scripts-ts.js" }, "dependencies": { - "autoprefixer": "7.1.6", - "babel-core": "6.26.0", - "babel-eslint": "7.2.3", - "babel-jest": "20.0.3", - "babel-loader": "7.1.2", - "babel-preset-react-app": "^3.1.0", - "babel-runtime": "6.26.0", + "autoprefixer": "7.1.2", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", - "css-loader": "0.28.7", + "css-loader": "0.28.4", "dotenv": "4.0.0", - "extract-text-webpack-plugin": "3.0.2", - "file-loader": "1.1.5", + "extract-text-webpack-plugin": "3.0.0", + "file-loader": "0.11.2", "fork-ts-checker-webpack-plugin": "^0.2.8", "fs-extra": "3.0.1", "html-webpack-plugin": "2.29.0", "jest": "20.0.4", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", - "postcss-loader": "2.0.8", + "postcss-loader": "2.0.6", "promise": "8.0.1", - "raf": "3.4.0", - "react-dev-utils": "^4.2.1", - "style-loader": "0.19.0", - "sw-precache-webpack-plugin": "0.11.4", - "url-loader": "0.6.2", - "webpack": "3.8.1", - "webpack-dev-server": "2.9.4", - "webpack-manifest-plugin": "1.3.2", - "whatwg-fetch": "2.0.3", - "ts-jest": "^21.1.4", - "ts-loader": "^3.1.1", - "tslint": "^5.8.0", + "react-dev-utils": "^4.0.1", + "style-loader": "0.18.2", + "ts-jest": "^20.0.7", + "ts-loader": "^2.3.7", + "tslint": "^5.7.0", + "tslint-loader": "^3.5.3", "tslint-react": "^3.2.0", - "typescript": "~2.6.1", - "source-map-loader": "^0.2.3" + "typescript": "~2.5.3", + "source-map-loader": "^0.2.1", + "sw-precache-webpack-plugin": "0.11.4", + "url-loader": "0.5.9", + "webpack": "3.5.1", + "webpack-dev-server": "2.7.1", + "webpack-manifest-plugin": "1.2.1", + "whatwg-fetch": "2.0.3" }, "devDependencies": { - "react": "^16.0.0", - "react-dom": "^16.0.0" + "react": "^15.5.4", + "react-dom": "^15.5.4" }, "optionalDependencies": { "fsevents": "1.1.2" From 237c0faf6d38ed51770f24fcf32e55d45978a674 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Thu, 11 Jan 2018 09:14:12 +0000 Subject: [PATCH 244/265] Fix Missing Variable --- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 679af60f4..68467a641 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -11,7 +11,7 @@ const fs = require('fs'); const chalk = require('chalk'); const paths = require('../../config/paths'); -module.exports = (resolve, rootDir) => { +module.exports = (resolve, rootDir, isEjecting) => { // Use this instead of `paths.testsSetup` to avoid putting // an absolute filename into configuration after ejecting. const setupTestsFile = fs.existsSync(paths.testsSetup) From 6f0c62f43cda6b6eba7e8ace9754505ae34536a7 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Thu, 11 Jan 2018 09:26:49 +0000 Subject: [PATCH 245/265] Fix --- .../src/utils/getStackFrames.js | 48 +++++++++++++++++++ .../config/jest/babelTransform.js | 15 ------ .../scripts/utils/createJestConfig.js | 6 +-- 3 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 packages/react-error-overlay/src/utils/getStackFrames.js delete mode 100644 packages/react-scripts/config/jest/babelTransform.js diff --git a/packages/react-error-overlay/src/utils/getStackFrames.js b/packages/react-error-overlay/src/utils/getStackFrames.js new file mode 100644 index 000000000..9721e316c --- /dev/null +++ b/packages/react-error-overlay/src/utils/getStackFrames.js @@ -0,0 +1,48 @@ +/** + * 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. + */ + +/* @flow */ +import type { StackFrame } from './stack-frame'; +import { parse } from './parser'; +import { map } from './mapper'; +import { unmap } from './unmapper'; + +function getStackFrames( + error: Error, + unhandledRejection: boolean = false, + contextSize: number = 3 +): Promise<StackFrame[] | null> { + const parsedFrames = parse(error); + let enhancedFramesPromise; + if (error.__unmap_source) { + enhancedFramesPromise = unmap( + // $FlowFixMe + error.__unmap_source, + parsedFrames, + contextSize + ); + } else { + enhancedFramesPromise = map(parsedFrames, contextSize); + } + return enhancedFramesPromise.then(enhancedFrames => { + if ( + enhancedFrames + .map(f => f._originalFileName) + .filter(f => f != null && f.indexOf('node_modules') === -1).length === 0 + ) { + return null; + } + return enhancedFrames.filter( + ({ functionName }) => + functionName == null || + functionName.indexOf('__stack_frame_overlay_proxy_console__') === -1 + ); + }); +} + +export default getStackFrames; +export { getStackFrames }; diff --git a/packages/react-scripts/config/jest/babelTransform.js b/packages/react-scripts/config/jest/babelTransform.js deleted file mode 100644 index 02742e90c..000000000 --- a/packages/react-scripts/config/jest/babelTransform.js +++ /dev/null @@ -1,15 +0,0 @@ -// @remove-file-on-eject -/** - * Copyright (c) 2014-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. - */ -'use strict'; - -const babelJest = require('babel-jest'); - -module.exports = babelJest.createTransformer({ - presets: [require.resolve('babel-preset-react-app')], - babelrc: false, -}); diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 68467a641..5962038c5 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -11,7 +11,7 @@ const fs = require('fs'); const chalk = require('chalk'); const paths = require('../../config/paths'); -module.exports = (resolve, rootDir, isEjecting) => { +module.exports = (resolve, rootDir) => { // Use this instead of `paths.testsSetup` to avoid putting // an absolute filename into configuration after ejecting. const setupTestsFile = fs.existsSync(paths.testsSetup) @@ -32,9 +32,7 @@ module.exports = (resolve, rootDir, isEjecting) => { testURL: 'http://localhost', transform: { '^.+\\.tsx?$': resolve('config/jest/typescriptTransform.js'), - '^.+\\.(js|jsx|mjs)$': isEjecting - ? '<rootDir>/node_modules/babel-jest' - : resolve('config/jest/babelTransform.js'), + '^.+\\.(js|jsx|mjs)$': '<rootDir>/node_modules/babel-jest', '^.+\\.css$': resolve('config/jest/cssTransform.js'), '^(?!.*\\.(js|jsx|mjs|css|json)$)': resolve( 'config/jest/fileTransform.js' From bb74fb6aea6e91197f1170eccd9a6db0b5a13740 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Thu, 11 Jan 2018 22:02:02 +0000 Subject: [PATCH 246/265] Update JestConfig Creation --- packages/react-scripts/scripts/utils/createJestConfig.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 5962038c5..c0900b398 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -32,7 +32,6 @@ module.exports = (resolve, rootDir) => { testURL: 'http://localhost', transform: { '^.+\\.tsx?$': resolve('config/jest/typescriptTransform.js'), - '^.+\\.(js|jsx|mjs)$': '<rootDir>/node_modules/babel-jest', '^.+\\.css$': resolve('config/jest/cssTransform.js'), '^(?!.*\\.(js|jsx|mjs|css|json)$)': resolve( 'config/jest/fileTransform.js' From 16af26f17f4cbee4a3150493e4b38489f1a9ca09 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Thu, 11 Jan 2018 22:09:40 +0000 Subject: [PATCH 247/265] Readd Missing raf Package --- packages/react-scripts/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index cc3a6f9d1..378d0b2d6 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -36,6 +36,7 @@ "postcss-flexbugs-fixes": "3.2.0", "postcss-loader": "2.0.6", "promise": "8.0.1", + "raf": "3.4.0", "react-dev-utils": "^4.0.1", "style-loader": "0.18.2", "ts-jest": "^20.0.7", From 0d436266049d914e282af68c27e67b7db241658d Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Thu, 11 Jan 2018 22:20:07 +0000 Subject: [PATCH 248/265] Update package.json dependencies --- packages/react-scripts/package.json | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 378d0b2d6..8dc442f9b 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -21,12 +21,12 @@ "react-scripts-ts": "./bin/react-scripts-ts.js" }, "dependencies": { - "autoprefixer": "7.1.2", + "autoprefixer": "7.1.6", "case-sensitive-paths-webpack-plugin": "2.1.1", "chalk": "1.1.3", - "css-loader": "0.28.4", + "css-loader": "0.28.7", "dotenv": "4.0.0", - "extract-text-webpack-plugin": "3.0.0", + "extract-text-webpack-plugin": "3.0.2", "file-loader": "0.11.2", "fork-ts-checker-webpack-plugin": "^0.2.8", "fs-extra": "3.0.1", @@ -34,11 +34,11 @@ "jest": "20.0.4", "object-assign": "4.1.1", "postcss-flexbugs-fixes": "3.2.0", - "postcss-loader": "2.0.6", + "postcss-loader": "2.0.8", "promise": "8.0.1", "raf": "3.4.0", - "react-dev-utils": "^4.0.1", - "style-loader": "0.18.2", + "react-dev-utils": "^4.2.1", + "style-loader": "0.19.0", "ts-jest": "^20.0.7", "ts-loader": "^2.3.7", "tslint": "^5.7.0", @@ -47,10 +47,10 @@ "typescript": "~2.5.3", "source-map-loader": "^0.2.1", "sw-precache-webpack-plugin": "0.11.4", - "url-loader": "0.5.9", - "webpack": "3.5.1", - "webpack-dev-server": "2.7.1", - "webpack-manifest-plugin": "1.2.1", + "url-loader": "0.6.2", + "webpack": "3.8.1", + "webpack-dev-server": "2.9.4", + "webpack-manifest-plugin": "1.3.2", "whatwg-fetch": "2.0.3" }, "devDependencies": { From b07285717f9546902e1740fe285a6fd00cefc5c5 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Thu, 11 Jan 2018 22:59:02 +0000 Subject: [PATCH 249/265] Update react-dev-utils --- .../react-dev-utils/WebpackDevServerUtils.js | 2 +- .../react-dev-utils/errorOverlayMiddleware.js | 21 +++++++++++++++++++ .../react-dev-utils/launchEditorEndpoint.js | 10 +++++++++ packages/react-scripts/package.json | 3 +-- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 packages/react-dev-utils/errorOverlayMiddleware.js create mode 100644 packages/react-dev-utils/launchEditorEndpoint.js diff --git a/packages/react-dev-utils/WebpackDevServerUtils.js b/packages/react-dev-utils/WebpackDevServerUtils.js index 1f0942e4c..6bc91ab03 100644 --- a/packages/react-dev-utils/WebpackDevServerUtils.js +++ b/packages/react-dev-utils/WebpackDevServerUtils.js @@ -183,7 +183,7 @@ function createCompiler(webpack, config, appName, urls, useYarn) { ); console.log( 'To ignore, add ' + - chalk.cyan('// tslint:disable-next-line') + + chalk.cyan('// eslint-disable-next-line') + ' to the line before.\n' ); } diff --git a/packages/react-dev-utils/errorOverlayMiddleware.js b/packages/react-dev-utils/errorOverlayMiddleware.js new file mode 100644 index 000000000..b756b0ef6 --- /dev/null +++ b/packages/react-dev-utils/errorOverlayMiddleware.js @@ -0,0 +1,21 @@ +/** + * 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. + */ +'use strict'; + +const launchEditor = require('./launchEditor'); +const launchEditorEndpoint = require('./launchEditorEndpoint'); + +module.exports = function createLaunchEditorMiddleware() { + return function launchEditorMiddleware(req, res, next) { + if (req.url.startsWith(launchEditorEndpoint)) { + launchEditor(req.query.fileName, req.query.lineNumber); + res.end(); + } else { + next(); + } + }; +}; diff --git a/packages/react-dev-utils/launchEditorEndpoint.js b/packages/react-dev-utils/launchEditorEndpoint.js new file mode 100644 index 000000000..99b5935d9 --- /dev/null +++ b/packages/react-dev-utils/launchEditorEndpoint.js @@ -0,0 +1,10 @@ +/** + * 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. + */ +'use strict'; + +// TODO: we might want to make this injectable to support DEV-time non-root URLs. +module.exports = '/__open-stack-frame-in-editor'; diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 8dc442f9b..fa61b9108 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -37,7 +37,7 @@ "postcss-loader": "2.0.8", "promise": "8.0.1", "raf": "3.4.0", - "react-dev-utils": "^4.2.1", + "react-dev-utils": "4.2.1", "style-loader": "0.19.0", "ts-jest": "^20.0.7", "ts-loader": "^2.3.7", @@ -61,4 +61,3 @@ "fsevents": "1.1.2" } } - From 13c0e7fe6a1c787929236815b17c873d9f047e6a Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Fri, 12 Jan 2018 21:09:12 +0000 Subject: [PATCH 250/265] Readd transformIgnorePatterns --- packages/react-scripts/scripts/utils/createJestConfig.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index c0900b398..95cf28925 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -37,6 +37,9 @@ module.exports = (resolve, rootDir) => { 'config/jest/fileTransform.js' ), }, + transformIgnorePatterns: [ + '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$', + ], moduleNameMapper: { '^react-native$': 'react-native-web', }, From bbdefca170f7ccd33e75946ed638b33086599c1e Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Sat, 13 Jan 2018 11:47:47 +0000 Subject: [PATCH 251/265] v2.10.0 --- packages/react-scripts/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index cc3a6f9d1..648e0956e 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts-ts", - "version": "2.8.0", + "version": "2.10.0", "description": "Configuration and scripts for Create React App.", "repository": "wmonk/create-react-app", "license": "BSD-3-Clause", @@ -60,4 +60,3 @@ "fsevents": "1.1.2" } } - From 22e52e14a79cb3cc48453f96b684721096aeed59 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Sat, 13 Jan 2018 11:50:24 +0000 Subject: [PATCH 252/265] Update changelog for 2.10.0 --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 038ab1233..1f26c0d02 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,14 @@ To fix this, create a new file *in the root of the project* called `tsconfig.tes ## Changelog +### 2.10.0 +* README updates - StefanSchoof +* README updates - DorianGrey +* Add support for fork-ts-checker-webpack-plugin - johnnyreilly + +### 2.9.0 - UNPUBLISHED +This included changes that were not published by the facebook upstream, so was unpublished. + ### 2.8.0 * Update typescript to 2.5.3 - @nicolaserny From e637c79284a80f70fb4f42f0adc9d684273d846b Mon Sep 17 00:00:00 2001 From: Will Monk <will@williammonk.co.uk> Date: Sat, 13 Jan 2018 13:38:13 +0000 Subject: [PATCH 253/265] Update createJestConfig.js --- packages/react-scripts/scripts/utils/createJestConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/utils/createJestConfig.js b/packages/react-scripts/scripts/utils/createJestConfig.js index 95cf28925..3a744c971 100644 --- a/packages/react-scripts/scripts/utils/createJestConfig.js +++ b/packages/react-scripts/scripts/utils/createJestConfig.js @@ -38,7 +38,7 @@ module.exports = (resolve, rootDir) => { ), }, transformIgnorePatterns: [ - '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$', + '[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|ts|tsx)$' ], moduleNameMapper: { '^react-native$': 'react-native-web', From d5b370d8abb6f187a8e901f5673a8146050f9bb8 Mon Sep 17 00:00:00 2001 From: dawidboruta <diabelb@gmail.com> Date: Sat, 13 Jan 2018 19:30:58 +0100 Subject: [PATCH 254/265] Fixed problem with tsconfig.json baseUrl and paths --- packages/react-scripts/config/webpack.config.dev.js | 2 ++ packages/react-scripts/config/webpack.config.prod.js | 2 ++ packages/react-scripts/package.json | 1 + 3 files changed, 5 insertions(+) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index 6c619f4f4..269a18ad6 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -21,6 +21,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const getClientEnvironment = require('./env'); const paths = require('./paths'); +const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); // Webpack uses `publicPath` to determine where the app is being served from. // In development, we always serve from the root. This makes config easier. @@ -126,6 +127,7 @@ module.exports = { // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), + new TsconfigPathsPlugin({configFile: paths.appTsConfig}) ], }, module: { diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 366dcd108..a18869245 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -22,6 +22,7 @@ const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); const paths = require('./paths'); const getClientEnvironment = require('./env'); +const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); // Webpack uses `publicPath` to determine where the app is being served from. // It requires a trailing slash, or the file assets will get an incorrect path. @@ -130,6 +131,7 @@ module.exports = { // please link the files into your node_modules/ and let module-resolution kick in. // Make sure your source files are compiled, as they will not be processed in any way. new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]), + new TsconfigPathsPlugin({configFile: paths.appTsConfig}) ], }, module: { diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 648e0956e..f8f6fe79c 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -40,6 +40,7 @@ "style-loader": "0.18.2", "ts-jest": "^20.0.7", "ts-loader": "^2.3.7", + "tsconfig-paths-webpack-plugin": "^2.0.0", "tslint": "^5.7.0", "tslint-loader": "^3.5.3", "tslint-react": "^3.2.0", From de8f8eac8c8dda43c8bb226d21ab9e749e016aa7 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Sun, 14 Jan 2018 17:41:34 +0000 Subject: [PATCH 255/265] Update changelog for 2.11.0 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1f26c0d02..7ee46f344 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ To fix this, create a new file *in the root of the project* called `tsconfig.tes ## Changelog +### 2.11.0 +* Upgrade to [`react-scripts@1.0.17`](https://github.com/facebookincubator/create-react-app/releases/tag/v1.0.17) + ### 2.10.0 * README updates - StefanSchoof * README updates - DorianGrey From 69c215b3f1a53d68361a89aa36f3bf92e86814f9 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Sun, 14 Jan 2018 17:41:50 +0000 Subject: [PATCH 256/265] v2.11.0 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 3b8e4cb2e..f82685539 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts-ts", - "version": "2.10.0", + "version": "2.11.0", "description": "Configuration and scripts for Create React App.", "repository": "wmonk/create-react-app", "license": "BSD-3-Clause", From 4e654437d932aa1d07c238cdd2d922b83235f5f6 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Sun, 14 Jan 2018 18:20:48 +0000 Subject: [PATCH 257/265] Update typescript to 2.6.2 --- packages/react-scripts/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index f82685539..c4393f6c3 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -38,15 +38,15 @@ "promise": "8.0.1", "raf": "3.4.0", "react-dev-utils": "4.2.1", + "source-map-loader": "^0.2.1", "style-loader": "0.19.0", + "sw-precache-webpack-plugin": "0.11.4", "ts-jest": "^20.0.7", "ts-loader": "^2.3.7", "tslint": "^5.7.0", "tslint-loader": "^3.5.3", "tslint-react": "^3.2.0", - "typescript": "~2.5.3", - "source-map-loader": "^0.2.1", - "sw-precache-webpack-plugin": "0.11.4", + "typescript": "^2.6.2", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4", From fe2f3a761c682e972e324686c510dc0f0a25f698 Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Sun, 14 Jan 2018 18:59:23 +0000 Subject: [PATCH 258/265] Update README For 2.12.0 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 7ee46f344..83973eeca 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,9 @@ To fix this, create a new file *in the root of the project* called `tsconfig.tes ## Changelog +### 2.12.0 +* Update typescript to 2.6.2 + ### 2.11.0 * Upgrade to [`react-scripts@1.0.17`](https://github.com/facebookincubator/create-react-app/releases/tag/v1.0.17) From d467b98c61adc6b0ca37089bd8e260c81c0431df Mon Sep 17 00:00:00 2001 From: William Monk <will@williammonk.co.uk> Date: Sun, 14 Jan 2018 18:59:43 +0000 Subject: [PATCH 259/265] v2.12.0 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index c4393f6c3..a18a7008f 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts-ts", - "version": "2.11.0", + "version": "2.12.0", "description": "Configuration and scripts for Create React App.", "repository": "wmonk/create-react-app", "license": "BSD-3-Clause", From 934fb112a448dbd766e03c15ebd23cd26968e3c2 Mon Sep 17 00:00:00 2001 From: Josh Tynjala <joshtynjala@gmail.com> Date: Thu, 18 Jan 2018 10:31:39 -0800 Subject: [PATCH 260/265] Documented how to define custom module formats for the TypeScript compiler so that you can import images and other files (references #172) --- packages/react-scripts/template/README.md | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index c57a0ebd7..6f0338d7e 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -623,11 +623,26 @@ Now running `npm start` and `npm run build` also builds Sass files. With Webpack, using static assets like images and fonts works similarly to CSS. -You can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. +You can **`import` a file right in a TypeScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF. To reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebookincubator/create-react-app/issues/1153). -Here is an example: +Before getting started, you must define each type of asset as a valid module format. Otherwise, the TypeScript compiler will generate an error like this: + +>Cannot find module './logo.png'. + +To import asset files in TypeScript, create a new type definition file in your project, and name it something like `assets.d.ts`. Then, add a line for each type of asset that you need to import: + +```ts +declare module "*.gif"; +declare module "*.jpg"; +declare module "*.jpeg"; +declare module "*.png"; +``` + +In this case, we've added several image file extensions as valid module formats. + +Now that the compiler is configured, here is an example of importing an image file: ```js import React from 'react'; From 3a40ac03b0c563765679f92b866667a10c04ed23 Mon Sep 17 00:00:00 2001 From: Ian Schmitz <ianschmitz@gmail.com> Date: Sat, 4 Nov 2017 18:13:57 -0800 Subject: [PATCH 261/265] Include TypeScript as devDependency in boilerplate output --- packages/react-scripts/package.json | 4 +++- packages/react-scripts/scripts/init.js | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 1b410744a..484576207 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -47,7 +47,6 @@ "tslint": "^5.7.0", "tslint-loader": "^3.5.3", "tslint-react": "^3.2.0", - "typescript": "^2.6.2", "url-loader": "0.6.2", "webpack": "3.8.1", "webpack-dev-server": "2.9.4", @@ -58,6 +57,9 @@ "react": "^15.5.4", "react-dom": "^15.5.4" }, + "peerDependencies": { + "typescript": "2.x" + }, "optionalDependencies": { "fsevents": "1.1.2" } diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index f4d2023b1..1490efa4f 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -109,6 +109,7 @@ module.exports = function( '@types/react', '@types/react-dom', '@types/jest', + 'typescript', ]; console.log( From b40c8c56d430679d6b1da94650a6320c13a46e4c Mon Sep 17 00:00:00 2001 From: DorianGrey <ShadowVampire@web.de> Date: Mon, 22 Jan 2018 08:34:12 +0100 Subject: [PATCH 262/265] Remove tslint-loader from prod build (again) --- packages/react-scripts/config/webpack.config.prod.js | 8 -------- packages/react-scripts/package.json | 1 - 2 files changed, 9 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index 72c73d433..5fb2fb056 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -139,14 +139,6 @@ module.exports = { // 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 } }, - // First, run the linter. - // It's important to do this before Typescript runs. - { - test: /\.(ts|tsx)$/, - loader: require.resolve('tslint-loader'), - enforce: 'pre', - include: paths.appSrc, - }, { test: /\.(js|jsx|mjs)$/, loader: require.resolve('source-map-loader'), diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 1b410744a..6ab7625c2 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -45,7 +45,6 @@ "ts-loader": "^2.3.7", "tsconfig-paths-webpack-plugin": "^2.0.0", "tslint": "^5.7.0", - "tslint-loader": "^3.5.3", "tslint-react": "^3.2.0", "typescript": "^2.6.2", "url-loader": "0.6.2", From 6e288ac24225705deecd658f98dfefd2af2a924f Mon Sep 17 00:00:00 2001 From: William Monk <will@passfort.com> Date: Mon, 22 Jan 2018 17:23:29 +0000 Subject: [PATCH 263/265] v2.13.0 --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index bd06e6fb8..713b5eaed 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts-ts", - "version": "2.12.0", + "version": "2.13.0", "description": "Configuration and scripts for Create React App.", "repository": "wmonk/create-react-app", "license": "BSD-3-Clause", From 875552b4015276b62df3b4ae42c3910512de5b51 Mon Sep 17 00:00:00 2001 From: William Monk <will@passfort.com> Date: Mon, 22 Jan 2018 17:26:44 +0000 Subject: [PATCH 264/265] Update README For 2.13.0 --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 83973eeca..d9879b1d6 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,12 @@ To fix this, create a new file *in the root of the project* called `tsconfig.tes ## Changelog +### 2.13.0 +* Remove tslint-loader from prod builds - @DorianGrey +* Include typescript as devDependency in boilerplate - @ianschmitz +* Document custom module formats - @joshtynjala +* Fix tscofnig.json - @diabelb + ### 2.12.0 * Update typescript to 2.6.2 From 679d4708b51ab045aedb763e4934543f9f706490 Mon Sep 17 00:00:00 2001 From: Stephan <stephantroyer@live.at> Date: Mon, 22 Jan 2018 20:28:19 +0100 Subject: [PATCH 265/265] fix typo in changelog --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d9879b1d6..ff389d1f0 100644 --- a/README.md +++ b/README.md @@ -39,11 +39,11 @@ To fix this, create a new file *in the root of the project* called `tsconfig.tes ## Changelog -### 2.13.0 +### 2.13.0 * Remove tslint-loader from prod builds - @DorianGrey * Include typescript as devDependency in boilerplate - @ianschmitz * Document custom module formats - @joshtynjala -* Fix tscofnig.json - @diabelb +* Fix tsconfig.json - @diabelb ### 2.12.0 * Update typescript to 2.6.2