From be9bd88467af7828122190bb8b0030ace3344628 Mon Sep 17 00:00:00 2001 From: ad222kr Date: Mon, 17 Oct 2016 16:10:19 +0200 Subject: [PATCH 001/143] Added Rails link to User Guide --- README.md | 1 + packages/react-scripts/template/README.md | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index 334dd477e8..cd23b231ff 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast - [Adding Custom Environment Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables) - [Can I Use Decorators?](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#can-i-use-decorators) - [Integrating with a Node Backend](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#integrating-with-a-node-backend) +- [Integrating with a Rails Backend](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#integrating-with-a-rails-backend) - [Proxying API Requests in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development) - [Using HTTPS in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-https-in-development) - [Generating Dynamic `` 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) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 268265bdb6..293c98050e 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -25,6 +25,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Adding Custom Environment Variables](#adding-custom-environment-variables) - [Can I Use Decorators?](#can-i-use-decorators) - [Integrating with a Node Backend](#integrating-with-a-node-backend) +- [Integrating with a Rails Backend](#integrating-with-a-rails-backend) - [Proxying API Requests in Development](#proxying-api-requests-in-development) - [Using HTTPS in Development](#using-https-in-development) - [Generating Dynamic `` Tags on the Server](#generating-dynamic-meta-tags-on-the-server) @@ -546,6 +547,10 @@ Create React App will add decorator support when the specification advances to a Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/) for instructions on integrating an app with a Node backend running on another port, and using `fetch()` to access it. You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo). +## Integrating with a Rails Backend + +Check out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/) for instructions on integrating an app with a Rails backend running on another port, and using `fetch()` to access it. You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails). + ## Proxying API Requests in Development >Note: this feature is available with `react-scripts@0.2.3` and higher. From 8df641db7134d7cfb890856cf46cc659d8dc3927 Mon Sep 17 00:00:00 2001 From: Michael Scholtz Date: Mon, 17 Oct 2016 21:51:22 +0200 Subject: [PATCH 002/143] Fix Travis CI config in template README.md (#910) --- 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 293c98050e..0ac0e0b892 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -807,8 +807,8 @@ node_js: - 6 cache: directories: - - node_modules -script + - node_modules +script: - npm test ``` 1. Trigger your first build with a git push. From 74742c62e97f4cd823b7eda74739f7843088707c Mon Sep 17 00:00:00 2001 From: Jeffrey Carl Faden Date: Tue, 18 Oct 2016 10:31:58 -0700 Subject: [PATCH 003/143] Enable babel parameters/destructuring for all versions of Node (#927) * Enable babel parameters/destructuring for all versions of Node * Add more descriptive comment explaining plugin use --- packages/babel-preset-react-app/index.js | 10 +++++++++- packages/babel-preset-react-app/package.json | 2 ++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index d3063aee30..d6e9c4519d 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -27,7 +27,15 @@ const plugins = [ regenerator: true, // Resolve the Babel runtime relative to the config. moduleName: path.dirname(require.resolve('babel-runtime/package')) - }] + }], + // The following two plugins are currently necessary to get + // babel-preset-env to work with rest/spread. More info here: + // https://github.com/babel/babel-preset-env#caveats + // https://github.com/babel/babel/issues/4074 + // const { a, ...z } = obj; + require.resolve('babel-plugin-transform-es2015-destructuring'), + // const fn = ({ a, ...otherProps }) => otherProps; + require.resolve('babel-plugin-transform-es2015-parameters') ]; // This is similar to how `env` works in Babel: diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index bd1db0f572..3778880b5c 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -12,6 +12,8 @@ ], "dependencies": { "babel-plugin-transform-class-properties": "6.11.5", + "babel-plugin-transform-es2015-destructuring": "6.16.0", + "babel-plugin-transform-es2015-parameters": "6.17.0", "babel-plugin-transform-object-rest-spread": "6.8.0", "babel-plugin-transform-react-constant-elements": "6.9.1", "babel-plugin-transform-react-jsx-self": "6.11.0", From 4ad58dbbee6f65ae4a57416bdce7aa0ef35af330 Mon Sep 17 00:00:00 2001 From: Nathan Hunzaker Date: Wed, 19 Oct 2016 05:19:12 -0400 Subject: [PATCH 004/143] PostCSS should run on @import statements. (#929) --- 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 8a8b59ed85..d875c63e8d 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -137,7 +137,7 @@ module.exports = { // in development "style" loader enables hot editing of CSS. { test: /\.css$/, - loader: 'style!css!postcss' + loader: 'style!css?importLoaders=1!postcss' }, // JSON is not enabled by default in Webpack but both Node and Browserify // allow it implicitly so we also enable it. diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index fa787d43ea..e0141b851b 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -150,7 +150,7 @@ module.exports = { // Webpack 1.x uses Uglify plugin as a signal to minify *all* the assets // including CSS. This is confusing and will be removed in Webpack 2: // https://github.com/webpack/webpack/issues/283 - loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer!postcss') + loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1&-autoprefixer!postcss') // Note: this won't work without `new ExtractTextPlugin()` in `plugins`. }, // JSON is not enabled by default in Webpack but both Node and Browserify From 44377b2312c4c50af600dfc7eec99203b5c98833 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sat, 22 Oct 2016 22:36:15 +0300 Subject: [PATCH 005/143] Update dependencies (#945) * Update dependencies * Use published version of eslint-config-react-app for development We dogfood on our eslint-config-react-app by using it as our ESLint config, but installing it from the local folder causes problems when its peerDependencies are updated, because npm won't update it unless the version number changes. Use the published version for dogfooding so it can be installed from npm. --- lerna.json | 2 +- package.json | 4 +-- packages/babel-preset-react-app/package.json | 10 +++--- packages/eslint-config-react-app/README.md | 2 +- packages/eslint-config-react-app/package.json | 12 +++---- packages/react-scripts/package.json | 36 +++++++++---------- packages/react-scripts/template/README.md | 2 +- 7 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lerna.json b/lerna.json index efe8073fd0..dfcc2e9f35 100644 --- a/lerna.json +++ b/lerna.json @@ -1,4 +1,4 @@ { - "lerna": "2.0.0-beta.29", + "lerna": "2.0.0-beta.30", "version": "independent" } diff --git a/package.json b/package.json index 1029bc4775..1ac6081b7b 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,11 @@ "devDependencies": { "babel-eslint": "6.1.2", "eslint": "3.5.0", - "eslint-config-react-app": "file:packages/eslint-config-react-app", + "eslint-config-react-app": "0.2.1", "eslint-plugin-flowtype": "2.18.1", "eslint-plugin-import": "1.12.0", "eslint-plugin-jsx-a11y": "2.2.2", "eslint-plugin-react": "6.3.0", - "lerna": "2.0.0-beta.29" + "lerna": "2.0.0-beta.30" } } diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 3778880b5c..28c61a31d8 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -11,18 +11,18 @@ "index.js" ], "dependencies": { - "babel-plugin-transform-class-properties": "6.11.5", + "babel-plugin-transform-class-properties": "6.16.0", "babel-plugin-transform-es2015-destructuring": "6.16.0", "babel-plugin-transform-es2015-parameters": "6.17.0", - "babel-plugin-transform-object-rest-spread": "6.8.0", + "babel-plugin-transform-object-rest-spread": "6.16.0", "babel-plugin-transform-react-constant-elements": "6.9.1", "babel-plugin-transform-react-jsx-self": "6.11.0", "babel-plugin-transform-react-jsx-source": "6.9.0", "babel-plugin-transform-regenerator": "6.16.1", "babel-plugin-transform-runtime": "6.15.0", - "babel-preset-env": "0.0.4", - "babel-preset-latest": "6.14.0", - "babel-preset-react": "6.11.1", + "babel-preset-env": "0.0.6", + "babel-preset-latest": "6.16.0", + "babel-preset-react": "6.16.0", "babel-runtime": "6.11.6" } } diff --git a/packages/eslint-config-react-app/README.md b/packages/eslint-config-react-app/README.md index e4fac03e54..5c20f50ca2 100644 --- a/packages/eslint-config-react-app/README.md +++ b/packages/eslint-config-react-app/README.md @@ -17,7 +17,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@6.1.2 eslint@3.5.0 eslint-plugin-flowtype@2.18.1 eslint-plugin-import@1.12.0 eslint-plugin-jsx-a11y@2.2.2 eslint-plugin-react@6.3.0 + npm install --save-dev eslint-config-react-app babel-eslint@7.0.0 eslint@3.8.1 eslint-plugin-flowtype@2.21.0 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@2.2.3 eslint-plugin-react@6.4.1 ``` Then create a file named `.eslintrc` with following contents in the root folder of your project: diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 90c6a21f26..8ae92c5f48 100644 --- a/packages/eslint-config-react-app/package.json +++ b/packages/eslint-config-react-app/package.json @@ -11,11 +11,11 @@ "index.js" ], "peerDependencies": { - "babel-eslint": "6.1.2", - "eslint": "3.5.0", - "eslint-plugin-flowtype": "2.18.1", - "eslint-plugin-import": "1.12.0", - "eslint-plugin-jsx-a11y": "2.2.2", - "eslint-plugin-react": "6.3.0" + "babel-eslint": "7.0.0", + "eslint": "3.8.1", + "eslint-plugin-flowtype": "2.21.0", + "eslint-plugin-import": "2.0.1", + "eslint-plugin-jsx-a11y": "2.2.3", + "eslint-plugin-react": "6.4.1" } } diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 004ba9ee08..fb0ea4ebe8 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -23,39 +23,39 @@ "react-scripts": "./bin/react-scripts.js" }, "dependencies": { - "autoprefixer": "6.4.1", - "babel-core": "6.14.0", - "babel-eslint": "6.1.2", + "autoprefixer": "6.5.1", + "babel-core": "6.17.0", + "babel-eslint": "7.0.0", "babel-jest": "16.0.0", "babel-loader": "6.2.5", "babel-preset-react-app": "^0.2.1", "case-sensitive-paths-webpack-plugin": "1.1.4", "chalk": "1.1.3", "connect-history-api-fallback": "1.3.0", - "cross-spawn": "4.0.0", - "css-loader": "0.24.0", - "detect-port": "1.0.0", + "cross-spawn": "4.0.2", + "css-loader": "0.25.0", + "detect-port": "1.0.1", "dotenv": "2.0.0", - "eslint": "3.5.0", + "eslint": "3.8.1", "eslint-config-react-app": "^0.2.1", - "eslint-loader": "1.5.0", - "eslint-plugin-flowtype": "2.18.1", - "eslint-plugin-import": "1.12.0", - "eslint-plugin-jsx-a11y": "2.2.2", - "eslint-plugin-react": "6.3.0", + "eslint-loader": "1.6.0", + "eslint-plugin-flowtype": "2.21.0", + "eslint-plugin-import": "2.0.1", + "eslint-plugin-jsx-a11y": "2.2.3", + "eslint-plugin-react": "6.4.1", "extract-text-webpack-plugin": "1.0.1", "file-loader": "0.9.0", "filesize": "3.3.0", "find-cache-dir": "0.1.1", "fs-extra": "0.30.0", "gzip-size": "3.0.0", - "html-webpack-plugin": "2.22.0", - "http-proxy-middleware": "0.17.1", - "jest": "16.0.1", + "html-webpack-plugin": "2.24.0", + "http-proxy-middleware": "0.17.2", + "jest": "16.0.2", "json-loader": "0.5.4", "object-assign": "4.1.0", "path-exists": "2.1.0", - "postcss-loader": "0.13.0", + "postcss-loader": "1.0.0", "promise": "7.1.1", "react-dev-utils": "^0.2.1", "recursive-readdir": "2.1.0", @@ -64,8 +64,8 @@ "style-loader": "0.13.1", "url-loader": "0.5.7", "webpack": "1.13.2", - "webpack-dev-server": "1.16.1", - "webpack-manifest-plugin": "1.0.1", + "webpack-dev-server": "1.16.2", + "webpack-manifest-plugin": "1.1.0", "whatwg-fetch": "1.0.0" }, "devDependencies": { diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 0ac0e0b892..d7167ba5aa 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -175,7 +175,7 @@ Then add this block to the `package.json` file of your project: Finally, you will need to install some packages *globally*: ```sh -npm install -g eslint-config-react-app@0.2.1 eslint@3.5.0 babel-eslint@6.1.2 eslint-plugin-react@6.3.0 eslint-plugin-import@1.12.0 eslint-plugin-jsx-a11y@2.2.2 eslint-plugin-flowtype@2.18.1 +npm install -g eslint-config-react-app@0.2.1 eslint@3.8.1 babel-eslint@7.0.0 eslint-plugin-react@6.4.1 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@2.2.3 eslint-plugin-flowtype@2.21.0 ``` We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already [working on a solution to this](https://github.com/eslint/eslint/issues/3458) so this may become unnecessary in a couple of months. From 545c3447a6b3b4d1a4fb68e43858b10a2bc1ec44 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sat, 22 Oct 2016 23:11:25 +0300 Subject: [PATCH 006/143] Forbid Webpack loader syntax in imports (#803) Enable no-webpack-loader-syntax rule in eslint-config-react-app. --- packages/eslint-config-react-app/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index 7689a83544..f2f79a2dcc 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -21,8 +21,7 @@ module.exports = { parser: 'babel-eslint', - // import plugin is temporarily disabled, scroll below to see why - plugins: [/*'import', */'flowtype', 'jsx-a11y', 'react'], + plugins: ['import', 'flowtype', 'jsx-a11y', 'react'], env: { browser: true, @@ -170,6 +169,9 @@ module.exports = { // This is probably fixable with a patch to eslint-loader. // When file A is saved, we want to invalidate all files that import it // *and* that currently have lint errors. This should fix the problem. + // (As an exception, import/no-webpack-loader-syntax can be enabled already + // because it doesn't depend on whether the file exists, so this issue + // doesn't apply to it.) // 'import/default': 'warn', // 'import/export': 'warn', @@ -181,6 +183,9 @@ module.exports = { // 'import/no-named-as-default': 'warn', // 'import/no-named-as-default-member': 'warn', // 'import/no-unresolved': ['warn', { commonjs: true }], + // We don't support configuring Webpack using import source strings, so this + // is always an error. + 'import/no-webpack-loader-syntax': 'error', // https://github.com/yannickcr/eslint-plugin-react/tree/master/docs/rules 'react/jsx-equals-spacing': ['warn', 'never'], From ddd1bdb6bd0015f8e95b166c40cad1489bdc9187 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sat, 22 Oct 2016 23:13:43 +0300 Subject: [PATCH 007/143] Revert "Temporarily remove 0.7.0 changelog as it's not out yet" This reverts commit 1ef6ea52922a705f36a4cc704eac12cfa1c9bba3. --- CHANGELOG.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a37b867c6a..3577ad354d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,59 @@ +## 0.7.0 (October 13, 2016) + +### Build Dependency (`react-scripts`) + +* Updates Jest to [version 16.0](http://facebook.github.io/jest/blog/2016/10/03/jest-16.html), with an upgraded CLI, improved snapshot testing, new matchers and more. ([@chase](https://github.com/chase) in [#858](https://github.com/facebookincubator/create-react-app/pull/858)) +* Test setup file `src/setupTests.js` is now called after test framework initialization to support loading custom matchers. ([@just-boris](https://github.com/just-boris) in [#846](https://github.com/facebookincubator/create-react-app/pull/846)) +* Build command shows better instructions for deploying the app to GitHub Pages ([@Janpot](https://github.com/Janpot) in [#841](https://github.com/facebookincubator/create-react-app/pull/841)) +* Build command now generates an asset manifest with mappings from each filename to its final output filename. ([@lukyth](https://github.com/lukyth) in [#891](https://github.com/facebookincubator/create-react-app/pull/891)) +* Build command exits, if there are errors from UglifyJS ([@pdillon](https://github.com/pdillon) in [#859](https://github.com/facebookincubator/create-react-app/pull/859)) +* Eject output is more beautiful now. ([@azakordonets](https://github.com/azakordonets) in [#769](https://github.com/facebookincubator/create-react-app/pull/769)) +* Fixes opening the app in a new tab in Chrome. ([@unixdev](https://github.com/unixdev) in [#831](https://github.com/facebookincubator/create-react-app/pull/831)) +* Fixes environment variables not being defined as normal properties of the `process.env` object. ([@jobi](https://github.com/jobi) in [#795](https://github.com/facebookincubator/create-react-app/issues/795)) + +### ESLint Config (`eslint-config-react-app`) + +* `react/react-in-jsx-scope` rule ("React must be in scope") is now an error. ([@gaearon](https://github.com/gaearon) in [#822](https://github.com/facebookincubator/create-react-app/pull/822)) +* `no-unused-expressions` rule now allows the use of short circuit and ternary expressions. ([@cannona](https://github.com/cannona) in [#724](https://github.com/facebookincubator/create-react-app/pull/724)) + +### Babel Preset (`babel-preset-react-app`) + +* The preset now detects the Node.js version in test environment and disables unnecessary ES2015 transforms using using `babel-preset-env`. ([@shubheksha](https://github.com/shubheksha) in [#878](https://github.com/facebookincubator/create-react-app/pull/878)) +* Fixes a duplicate dependency on `babel-plugin-transform-regenerator`. ([@akofman](https://github.com/akofman) in [#864](https://github.com/facebookincubator/create-react-app/pull/864)) + +### Utilities (`react-dev-utils`) + +* The error overlay is now disposed after fixing linting errors. ([@jarlef](https://github.com/jarlef) in [#856](https://github.com/facebookincubator/create-react-app/pull/856)) +* Adds support for Webpack 2 to `webpackHotDevClient`. ([@michalkvasnicak](https://github.com/michalkvasnicak) in [#840](https://github.com/facebookincubator/create-react-app/pull/840)) + +### Global CLI (`create-react-app`) + +* Adds support for passing a scoped package name to the `--scripts-version` argument. ([@pdillon](https://github.com/pdillon) in [#826](https://github.com/facebookincubator/create-react-app/pull/826)) +* Fixes installing pre-release versions using a tarball URL with the `--scripts-version` argument. ([@jihchi](https://github.com/jihchi) in [#876](https://github.com/facebookincubator/create-react-app/pull/876)) + +### Migrating from 0.6.1 to 0.7.0 + +You may optionally update the global command (it’s not required): + +``` +npm install -g create-react-app@0.7.0 +``` + +Inside any created project that has not been ejected, run: + +``` +npm install --save-dev --save-exact react-scripts@0.7.0 +``` + +### Breaking Change in 0.7.0 + +#### Updating Snapshots + +Jest 16 includes [improvements to snapshot testing and changes to the snapshot format](https://facebook.github.io/jest/blog/2016/10/03/jest-16.html#snapshot-updates). If your project uses snapshot testing, you'll need to update the snapshot files. To update the snapshots, run: +``` +npm test -- -u +``` + ## 0.6.1 (September 27, 2016) ### Build Dependency (`react-scripts`) From 5bd37ebeda2c227c3ab32487a039bbd630b0fb67 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sat, 22 Oct 2016 23:29:31 +0300 Subject: [PATCH 008/143] Update changelog for 0.7.0 --- CHANGELOG.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3577ad354d..1261bbd14c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.7.0 (October 13, 2016) +## 0.7.0 (October 22, 2016) ### Build Dependency (`react-scripts`) @@ -10,15 +10,18 @@ * Eject output is more beautiful now. ([@azakordonets](https://github.com/azakordonets) in [#769](https://github.com/facebookincubator/create-react-app/pull/769)) * Fixes opening the app in a new tab in Chrome. ([@unixdev](https://github.com/unixdev) in [#831](https://github.com/facebookincubator/create-react-app/pull/831)) * Fixes environment variables not being defined as normal properties of the `process.env` object. ([@jobi](https://github.com/jobi) in [#795](https://github.com/facebookincubator/create-react-app/issues/795)) +* Fixes PostCSS autoprefixer not processing CSS files imported with CSS `@import` statements. ([@nhunzaker](https://github.com/nhunzaker) in [##929](https://github.com/facebookincubator/create-react-app/pull/929)) ### ESLint Config (`eslint-config-react-app`) +* Adds `import/no-webpack-loader-syntax` rule that forbids using custom Webpack specific syntax to specify Webpack loaders in import statements. ([@fson](https://github.com/fson) in [#803](https://github.com/facebookincubator/create-react-app/pull/803)) * `react/react-in-jsx-scope` rule ("React must be in scope") is now an error. ([@gaearon](https://github.com/gaearon) in [#822](https://github.com/facebookincubator/create-react-app/pull/822)) * `no-unused-expressions` rule now allows the use of short circuit and ternary expressions. ([@cannona](https://github.com/cannona) in [#724](https://github.com/facebookincubator/create-react-app/pull/724)) ### Babel Preset (`babel-preset-react-app`) -* The preset now detects the Node.js version in test environment and disables unnecessary ES2015 transforms using using `babel-preset-env`. ([@shubheksha](https://github.com/shubheksha) in [#878](https://github.com/facebookincubator/create-react-app/pull/878)) +* The preset now detects the Node.js version in test environment and disables unnecessary ES2015 transforms using using `babel-preset-env`. ([@shubheksha](https://github.com/shubheksha) in [#878](https://github.com/facebookincubator/create-react-app/pull/878), [@JeffreyATW](https://github.com/JeffreyATW) in [#927 +](https://github.com/facebookincubator/create-react-app/pull/927)) * Fixes a duplicate dependency on `babel-plugin-transform-regenerator`. ([@akofman](https://github.com/akofman) in [#864](https://github.com/facebookincubator/create-react-app/pull/864)) ### Utilities (`react-dev-utils`) From 04ea0ef7039aa342f86e3263e657c042f8c1d505 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sat, 22 Oct 2016 23:32:46 +0300 Subject: [PATCH 009/143] Update eslint-config-react-app version in the 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 d7167ba5aa..ad3b27ce19 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -175,7 +175,7 @@ Then add this block to the `package.json` file of your project: Finally, you will need to install some packages *globally*: ```sh -npm install -g eslint-config-react-app@0.2.1 eslint@3.8.1 babel-eslint@7.0.0 eslint-plugin-react@6.4.1 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@2.2.3 eslint-plugin-flowtype@2.21.0 +npm install -g eslint-config-react-app@0.3.0 eslint@3.8.1 babel-eslint@7.0.0 eslint-plugin-react@6.4.1 eslint-plugin-import@2.0.1 eslint-plugin-jsx-a11y@2.2.3 eslint-plugin-flowtype@2.21.0 ``` We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already [working on a solution to this](https://github.com/eslint/eslint/issues/3458) so this may become unnecessary in a couple of months. From 9aa77a726d8dcaeea0b43eb5ba0f59ab030ccafb Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sat, 22 Oct 2016 23:49:30 +0300 Subject: [PATCH 010/143] Publish - babel-preset-react-app@1.0.0 - create-react-app@0.6.0 - eslint-config-react-app@0.3.0 - react-dev-utils@0.3.0 - react-scripts@0.7.0 --- 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-scripts/package.json | 9 +++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 28c61a31d8..bba2df1e0b 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": "0.2.1", + "version": "1.0.0", "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 5094b9c78d..4dd8b0f1a6 100644 --- a/packages/create-react-app/package.json +++ b/packages/create-react-app/package.json @@ -1,6 +1,6 @@ { "name": "create-react-app", - "version": "0.5.0", + "version": "0.6.0", "keywords": [ "react" ], diff --git a/packages/eslint-config-react-app/package.json b/packages/eslint-config-react-app/package.json index 8ae92c5f48..e0321bd47e 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": "0.2.1", + "version": "0.3.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 8de715d191..14c860999a 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -1,6 +1,6 @@ { "name": "react-dev-utils", - "version": "0.2.1", + "version": "0.3.0", "description": "Webpack utilities used by Create React App", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index fb0ea4ebe8..58bb4ab1d0 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,6 +1,6 @@ { "name": "react-scripts", - "version": "0.6.1", + "version": "0.7.0", "description": "Configuration and scripts for Create React App.", "repository": "facebookincubator/create-react-app", "license": "BSD-3-Clause", @@ -28,7 +28,7 @@ "babel-eslint": "7.0.0", "babel-jest": "16.0.0", "babel-loader": "6.2.5", - "babel-preset-react-app": "^0.2.1", + "babel-preset-react-app": "^1.0.0", "case-sensitive-paths-webpack-plugin": "1.1.4", "chalk": "1.1.3", "connect-history-api-fallback": "1.3.0", @@ -37,7 +37,7 @@ "detect-port": "1.0.1", "dotenv": "2.0.0", "eslint": "3.8.1", - "eslint-config-react-app": "^0.2.1", + "eslint-config-react-app": "^0.3.0", "eslint-loader": "1.6.0", "eslint-plugin-flowtype": "2.21.0", "eslint-plugin-import": "2.0.1", @@ -57,7 +57,7 @@ "path-exists": "2.1.0", "postcss-loader": "1.0.0", "promise": "7.1.1", - "react-dev-utils": "^0.2.1", + "react-dev-utils": "^0.3.0", "recursive-readdir": "2.1.0", "rimraf": "2.5.4", "strip-ansi": "3.0.1", @@ -119,6 +119,7 @@ "url-loader", "webpack", "webpack-dev-server", + "webpack-manifest-plugin", "whatwg-fetch" ] } From bc995afdcdcf497ed3efe19a677159bf83b22ebf Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sun, 23 Oct 2016 00:01:27 +0300 Subject: [PATCH 011/143] Update CLI version in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1261bbd14c..e73b0eeca5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,7 @@ You may optionally update the global command (it’s not required): ``` -npm install -g create-react-app@0.7.0 +npm install -g create-react-app@0.6.0 ``` Inside any created project that has not been ejected, run: From d2e5091b2daf81a280ee5b86f258da80de28974c Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sun, 23 Oct 2016 16:36:29 +0300 Subject: [PATCH 012/143] Fix an attribution link in 0.7.0 changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e73b0eeca5..b7d168daee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,8 @@ * Build command exits, if there are errors from UglifyJS ([@pdillon](https://github.com/pdillon) in [#859](https://github.com/facebookincubator/create-react-app/pull/859)) * Eject output is more beautiful now. ([@azakordonets](https://github.com/azakordonets) in [#769](https://github.com/facebookincubator/create-react-app/pull/769)) * Fixes opening the app in a new tab in Chrome. ([@unixdev](https://github.com/unixdev) in [#831](https://github.com/facebookincubator/create-react-app/pull/831)) -* Fixes environment variables not being defined as normal properties of the `process.env` object. ([@jobi](https://github.com/jobi) in [#795](https://github.com/facebookincubator/create-react-app/issues/795)) -* Fixes PostCSS autoprefixer not processing CSS files imported with CSS `@import` statements. ([@nhunzaker](https://github.com/nhunzaker) in [##929](https://github.com/facebookincubator/create-react-app/pull/929)) +* Fixes environment variables not being defined as normal properties of the `process.env` object. ([@dvkndn](https://github.com/dvkndn) in [#807](https://github.com/facebookincubator/create-react-app/pull/807)) +* Fixes PostCSS autoprefixer not processing CSS files imported with CSS `@import` statements. ([@nhunzaker](https://github.com/nhunzaker) in [#929](https://github.com/facebookincubator/create-react-app/pull/929)) ### ESLint Config (`eslint-config-react-app`) From c02ffe2cf67cbf4b56bc6708e984fc0c38320d60 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 24 Oct 2016 17:53:05 +0100 Subject: [PATCH 013/143] Encourage people to try recent npm --- ISSUE_TEMPLATE.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 2bcdd77dc3..e85da85b4c 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -1,5 +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? + +Run: + +``` +npm install -g npm@latest + +cd your_project_directory +rm -rf node_modules +npm install +``` + +and try to reproduce the issue again. + +Can you still reproduce it? + ### Description What are you reporting? From 7ea3e2b7514560d62c832712dcdcc7665f7cb70e Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 25 Oct 2016 12:01:58 +0100 Subject: [PATCH 014/143] Point people to npm Windows instructions --- ISSUE_TEMPLATE.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index e85da85b4c..374dbf1795 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -2,7 +2,11 @@ If you are reporting a bug, please fill in below. Otherwise feel free to remove ### Can you reproduce the problem with latest npm? -Run: +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: ``` npm install -g npm@latest @@ -12,7 +16,7 @@ rm -rf node_modules npm install ``` -and try to reproduce the issue again. +Then try to reproduce the issue again. Can you still reproduce it? From 38579f09382104eca2a86835263987b7e5d3d24c Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 25 Oct 2016 23:07:28 +0100 Subject: [PATCH 015/143] Add next.js to Alternatives --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index cd23b231ff..c9bde213f2 100644 --- a/README.md +++ b/README.md @@ -206,6 +206,7 @@ Some of the more popular and actively maintained ones are: * [insin/nwb](https://github.com/insin/nwb) * [mozilla/neo](https://github.com/mozilla/neo) * [NYTimes/kyt](https://github.com/NYTimes/kyt) +* [zeit/next.js](https://github.com/zeit/next.js) Notable alternatives also include: From c55aa7ce250d9f13647a75c1d131b364516b7bb5 Mon Sep 17 00:00:00 2001 From: Fatih Date: Fri, 28 Oct 2016 15:41:51 +0300 Subject: [PATCH 016/143] Enable compression on webpack-dev-server (#966) (#968) --- packages/react-scripts/scripts/start.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 8723c28163..8a115dd8e2 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -195,6 +195,8 @@ function addMiddleware(devServer) { function runDevServer(host, port, protocol) { var devServer = new WebpackDevServer(compiler, { + // Enable gzip compression of generated files. + compress: true, // Silence WebpackDevServer's own logs since they're generally not useful. // It will still show compile warnings and errors with this setting. clientLogLevel: 'none', From 6126ac9a9bd3ec0a13280cdee4c01406117898f7 Mon Sep 17 00:00:00 2001 From: Swizec Teller Date: Fri, 28 Oct 2016 05:42:51 -0700 Subject: [PATCH 017/143] Gently nudge users towards https by default (#974) gh-pages supports https. It's important for prominent help files to encourage best practices. --- 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 ad3b27ce19..12b0e1fda5 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -886,7 +886,7 @@ This will let Create React App correctly infer the root path to use in the gener Open your `package.json` and add a `homepage` field: ```js - "homepage": "http://myusername.github.io/my-app", + "homepage": "https://myusername.github.io/my-app", ``` **The above step is important!**
@@ -894,7 +894,7 @@ Create React App uses the `homepage` field to determine the root URL in the buil Now, whenever you run `npm run build`, you will see a cheat sheet with instructions on how to deploy to GitHub pages. -To publish it at [http://myusername.github.io/my-app](http://myusername.github.io/my-app), run: +To publish it at [https://myusername.github.io/my-app](https://myusername.github.io/my-app), run: ```sh npm install --save-dev gh-pages From 930a7c7d64c36b2c421d235e88da4afb3a98aa99 Mon Sep 17 00:00:00 2001 From: Sandro Padin Date: Fri, 28 Oct 2016 05:45:50 -0700 Subject: [PATCH 018/143] Catch and noop call to open web browser. (#964) Running `create-react-app` in a Docker container causes an unhandled rejection error in nodejs > 6.5 because the `opn` module tries to open a web browser in a system that doesn't have one. I figured this error could be safely ignored. --- packages/react-dev-utils/openBrowser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/openBrowser.js b/packages/react-dev-utils/openBrowser.js index 76b33a5924..bee85a7d29 100644 --- a/packages/react-dev-utils/openBrowser.js +++ b/packages/react-dev-utils/openBrowser.js @@ -28,7 +28,7 @@ function openBrowser(url) { // Fallback to opn // (It will always open new tab) try { - opn(url); + opn(url).catch(() => {}); // Prevent `unhandledRejection` error. return true; } catch (err) { return false; From cb63c092eb388ff89b797c84455cafd956fb490b Mon Sep 17 00:00:00 2001 From: Patrick Mackinder Date: Fri, 28 Oct 2016 13:47:08 +0100 Subject: [PATCH 019/143] Add collectCoverageFrom option to collect coverage on files without any tests. (#961) --- packages/react-scripts/utils/createJestConfig.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react-scripts/utils/createJestConfig.js b/packages/react-scripts/utils/createJestConfig.js index 39c864ab8f..17d414fc59 100644 --- a/packages/react-scripts/utils/createJestConfig.js +++ b/packages/react-scripts/utils/createJestConfig.js @@ -18,6 +18,7 @@ module.exports = (resolve, rootDir, isEjecting) => { const setupTestsFile = pathExists.sync(paths.testsSetup) ? '/src/setupTests.js' : undefined; const config = { + collectCoverageFrom: ['src/**/*.{js,jsx}'], moduleFileExtensions: ['jsx', 'js', 'json'], moduleNameMapper: { '^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'), From 8ff22be29336c3b943b4a3b8a1e895bc9316c50b Mon Sep 17 00:00:00 2001 From: David Ernst Date: Fri, 28 Oct 2016 05:51:06 -0700 Subject: [PATCH 020/143] Always build before deploying to gh-pages (#959) * Always build before deploying to gh-pages * Add line to gh-pages deploy docs about CNAME file * Remove spaces in npm run command for Windows * Grammar nit * Minor tweaks --- packages/react-scripts/template/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 12b0e1fda5..598ee43e5b 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -892,7 +892,7 @@ Open your `package.json` and add a `homepage` field: **The above step is important!**
Create React App uses the `homepage` field to determine the root URL in the built HTML file. -Now, whenever you run `npm run build`, you will see a cheat sheet with instructions on how to deploy to GitHub pages. +Now, whenever you run `npm run build`, you will see a cheat sheet with instructions on how to deploy to GitHub Pages. To publish it at [https://myusername.github.io/my-app](https://myusername.github.io/my-app), run: @@ -906,16 +906,20 @@ Add the following script in your `package.json`: // ... "scripts": { // ... - "deploy": "gh-pages -d build" + "deploy": "npm run build&&gh-pages -d build" } ``` +(Note: the lack of whitespace is intentional.) + Then run: ```sh npm run deploy ``` +You can configure a custom domain with GitHub Pages by adding a `CNAME` file to the `public/` folder. + Note that 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. * 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). From b7498e027980d0a552460353ecdc5f433770720d Mon Sep 17 00:00:00 2001 From: Vadzim Date: Fri, 28 Oct 2016 15:51:56 +0300 Subject: [PATCH 021/143] Fixes https://github.com/facebookincubator/create-react-app/issues/952 (#953) --- packages/eslint-config-react-app/index.js | 2 +- packages/react-scripts/utils/createJestConfig.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/eslint-config-react-app/index.js b/packages/eslint-config-react-app/index.js index f2f79a2dcc..6df5bfdd93 100644 --- a/packages/eslint-config-react-app/index.js +++ b/packages/eslint-config-react-app/index.js @@ -44,7 +44,7 @@ module.exports = { settings: { 'import/ignore': [ 'node_modules', - '\\.(json|css|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$', + '\\.(json|css|ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$', ], 'import/extensions': ['.js'], 'import/resolver': { diff --git a/packages/react-scripts/utils/createJestConfig.js b/packages/react-scripts/utils/createJestConfig.js index 17d414fc59..df0238f258 100644 --- a/packages/react-scripts/utils/createJestConfig.js +++ b/packages/react-scripts/utils/createJestConfig.js @@ -21,7 +21,7 @@ module.exports = (resolve, rootDir, isEjecting) => { collectCoverageFrom: ['src/**/*.{js,jsx}'], moduleFileExtensions: ['jsx', 'js', 'json'], moduleNameMapper: { - '^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'), + '^.+\\.(ico|jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': resolve('config/jest/FileStub.js'), '^.+\\.css$': resolve('config/jest/CSSStub.js') }, setupFiles: [resolve('config/polyfills.js')], From 0c0d144ceb698d9ab90d1233cf269bb17c020957 Mon Sep 17 00:00:00 2001 From: Alice Rose Date: Fri, 28 Oct 2016 14:54:56 +0200 Subject: [PATCH 022/143] Check for presence of folders before continuing eject. Closes #939. (#951) --- packages/react-scripts/scripts/eject.js | 38 ++++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index d14aec6abe..dbd4d64e4d 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -30,6 +30,25 @@ prompt( var ownPath = path.join(__dirname, '..'); var appPath = path.join(ownPath, '..', '..'); + + function verifyAbsent(file) { + if (fs.existsSync(path.join(appPath, file))) { + console.error( + '`' + file + '` already exists in your app folder. We cannot ' + + 'continue as you would lose all the changes in that file or directory. ' + + 'Please move or delete it (maybe make a copy for backup) and run this ' + + 'command again.' + ); + process.exit(1); + } + } + + var folders = [ + 'config', + path.join('config', 'jest'), + 'scripts' + ]; + var files = [ path.join('config', 'env.js'), path.join('config', 'paths.js'), @@ -44,22 +63,13 @@ prompt( ]; // Ensure that the app folder is clean and we won't override any files - files.forEach(function(file) { - if (fs.existsSync(path.join(appPath, file))) { - console.error( - '`' + file + '` already exists in your app folder. We cannot ' + - 'continue as you would lose all the changes in that file or directory. ' + - 'Please delete it (maybe make a copy for backup) and run this ' + - 'command again.' - ); - process.exit(1); - } - }); + folders.forEach(verifyAbsent); + files.forEach(verifyAbsent); // Copy the files over - fs.mkdirSync(path.join(appPath, 'config')); - fs.mkdirSync(path.join(appPath, 'config', 'jest')); - fs.mkdirSync(path.join(appPath, 'scripts')); + folders.forEach(function(folder) { + fs.mkdirSync(path.join(appPath, folder)) + }); console.log(); console.log(cyan('Copying files into ' + appPath)); From bfe079e6612a411dcbe7442edb87b510255ca683 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Sat, 29 Oct 2016 21:00:16 +0200 Subject: [PATCH 023/143] Remove custom babel-loader cache dir config (#983) Upgrade `babel-loader` and remove the cache directory configuration that was added in #620. `babel-loader` now uses the `./node_modules/.cache/babel-loader` directory by default, so the custom config is no longer needed. --- packages/react-scripts/config/webpack.config.dev.js | 10 +++------- packages/react-scripts/package.json | 3 +-- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index d875c63e8d..c2b544cca5 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -12,7 +12,6 @@ var path = require('path'); var autoprefixer = require('autoprefixer'); var webpack = require('webpack'); -var findCacheDir = require('find-cache-dir'); var HtmlWebpackPlugin = require('html-webpack-plugin'); var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin'); var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin'); @@ -122,12 +121,9 @@ module.exports = { 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/react-scripts/ - // directory for faster rebuilds. We use findCacheDir() because of: - // https://github.com/facebookincubator/create-react-app/issues/483 - cacheDirectory: findCacheDir({ - name: 'react-scripts' - }) + // It enables caching results in ./node_modules/.cache/babel-loader/ + // directory for faster rebuilds. + cacheDirectory: true } }, // "postcss" loader applies autoprefixer to our CSS. diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 58bb4ab1d0..b4cad96397 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -27,7 +27,7 @@ "babel-core": "6.17.0", "babel-eslint": "7.0.0", "babel-jest": "16.0.0", - "babel-loader": "6.2.5", + "babel-loader": "6.2.7", "babel-preset-react-app": "^1.0.0", "case-sensitive-paths-webpack-plugin": "1.1.4", "chalk": "1.1.3", @@ -46,7 +46,6 @@ "extract-text-webpack-plugin": "1.0.1", "file-loader": "0.9.0", "filesize": "3.3.0", - "find-cache-dir": "0.1.1", "fs-extra": "0.30.0", "gzip-size": "3.0.0", "html-webpack-plugin": "2.24.0", From a9550b37cc40e4378f06a814dda1333ff4b26045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20L=C3=B6ve?= Date: Mon, 31 Oct 2016 12:45:44 +0100 Subject: [PATCH 024/143] Allow webpack 2 as peerDependency in react-dev-utils (#963) * Allow webpack 2 as peerDependency * Remove webpack as peer dependency --- packages/react-dev-utils/package.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 14c860999a..1fe5c556c7 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -29,8 +29,5 @@ "opn": "4.0.2", "sockjs-client": "1.0.3", "strip-ansi": "3.0.1" - }, - "peerDependencies": { - "webpack": "^1.13.2" } } From fe68994163f9b97e4b20b53cf0b0bc1005bd233b Mon Sep 17 00:00:00 2001 From: Kyle Mathews Date: Mon, 31 Oct 2016 14:33:03 -0700 Subject: [PATCH 025/143] Add Gatsby to alternatives (#995) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c9bde213f2..8fda7d76af 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,7 @@ Some of the more popular and actively maintained ones are: * [mozilla/neo](https://github.com/mozilla/neo) * [NYTimes/kyt](https://github.com/NYTimes/kyt) * [zeit/next.js](https://github.com/zeit/next.js) +* [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby) Notable alternatives also include: From 6f007669ec1fc445f810dd909440641684488d8e Mon Sep 17 00:00:00 2001 From: Leo Wong Date: Tue, 1 Nov 2016 21:56:29 +0800 Subject: [PATCH 026/143] Remove redundant `function` from export statement (#996) --- 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 598ee43e5b..75c8c67487 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -321,7 +321,7 @@ function Header() { return Logo; } -export default function Header; +export default Header; ``` This ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths. From 4274624951421e364c452555b5f6def2c36475cd Mon Sep 17 00:00:00 2001 From: Vesa Laakso Date: Thu, 17 Nov 2016 14:48:22 +0200 Subject: [PATCH 027/143] Update babel-present-env and use node: 'current' as target (#1051) * Update babel-preset-env to 0.0.8 Changes between 0.0.6 and 0.0.8 should be backwards compatible: https://github.com/babel/babel-preset-env/blob/master/CHANGELOG.md * Use `node: 'current'` as target for babel-preset-env This replaces the hand-rolled node version setup with a new feature that was introduced in babel-preset-env@v0.0.7 https://github.com/babel/babel-preset-env/blob/v0.0.7/CHANGELOG.md --- packages/babel-preset-react-app/index.js | 2 +- packages/babel-preset-react-app/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index d6e9c4519d..7af3641424 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -68,7 +68,7 @@ if (env === 'test') { // ES features necessary for user's Node version [require('babel-preset-env').default, { targets: { - node: parseFloat(process.versions.node), + node: 'current', }, }], // JSX, Flow diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index bba2df1e0b..6ddae417bc 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -20,7 +20,7 @@ "babel-plugin-transform-react-jsx-source": "6.9.0", "babel-plugin-transform-regenerator": "6.16.1", "babel-plugin-transform-runtime": "6.15.0", - "babel-preset-env": "0.0.6", + "babel-preset-env": "0.0.8", "babel-preset-latest": "6.16.0", "babel-preset-react": "6.16.0", "babel-runtime": "6.11.6" From a7121e28a1db08c9d366fd0b04100285dfb33498 Mon Sep 17 00:00:00 2001 From: Sathish Date: Thu, 17 Nov 2016 18:24:12 +0530 Subject: [PATCH 028/143] Clears the usage of react-jsx-source & react-jsx-self (#992) Explain the usage of react-jsx-source & react-jsx-self --- packages/babel-preset-react-app/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 7af3641424..2aa1641ce3 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -54,6 +54,12 @@ if (env !== 'development' && env !== 'test' && env !== 'production') { } if (env === 'development' || env === 'test') { + // The following two plugins are currently necessary to make React warnings + // include more valuable information. They are included here because they are + // currently not enabled in babel-preset-react. See the below threads for more info: + // https://github.com/babel/babel/issues/4702 + // https://github.com/babel/babel/pull/3540#issuecomment-228673661 + // https://github.com/facebookincubator/create-react-app/issues/989 plugins.push.apply(plugins, [ // Adds component stack to warning messages require.resolve('babel-plugin-transform-react-jsx-source'), @@ -99,4 +105,3 @@ if (env === 'test') { // ]); } } - From 07e1e53415836601080980f3880b97ab554ee8ef Mon Sep 17 00:00:00 2001 From: Vesa Laakso Date: Thu, 17 Nov 2016 18:14:36 +0200 Subject: [PATCH 029/143] Remove unnecessary transform plugins for object spread to work (#1052) * Update `babel-plugin-transform-object-rest-spread` to v6.19.0 The `babel-plugin-transform-object-rest-spread` v6.19.0 update will allow us to remove the `babel-plugin-transform-es2015-destructuring` and `babel-plugin-transform-es2015-parameters` as the object rest spread transform will now work standalone and not require additional tranforms * Remove unnecessary babel transform plugins from babel-preset-react-app The `babel-plugin-transform-object-rest-spread` v6.19.0 update makes these plugins unnecessary, as v6.19.0 can be used stand-alone --- packages/babel-preset-react-app/index.js | 10 +--------- packages/babel-preset-react-app/package.json | 4 +--- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/packages/babel-preset-react-app/index.js b/packages/babel-preset-react-app/index.js index 2aa1641ce3..a2639c6d4c 100644 --- a/packages/babel-preset-react-app/index.js +++ b/packages/babel-preset-react-app/index.js @@ -27,15 +27,7 @@ const plugins = [ regenerator: true, // Resolve the Babel runtime relative to the config. moduleName: path.dirname(require.resolve('babel-runtime/package')) - }], - // The following two plugins are currently necessary to get - // babel-preset-env to work with rest/spread. More info here: - // https://github.com/babel/babel-preset-env#caveats - // https://github.com/babel/babel/issues/4074 - // const { a, ...z } = obj; - require.resolve('babel-plugin-transform-es2015-destructuring'), - // const fn = ({ a, ...otherProps }) => otherProps; - require.resolve('babel-plugin-transform-es2015-parameters') + }] ]; // This is similar to how `env` works in Babel: diff --git a/packages/babel-preset-react-app/package.json b/packages/babel-preset-react-app/package.json index 6ddae417bc..13f00ed227 100644 --- a/packages/babel-preset-react-app/package.json +++ b/packages/babel-preset-react-app/package.json @@ -12,9 +12,7 @@ ], "dependencies": { "babel-plugin-transform-class-properties": "6.16.0", - "babel-plugin-transform-es2015-destructuring": "6.16.0", - "babel-plugin-transform-es2015-parameters": "6.17.0", - "babel-plugin-transform-object-rest-spread": "6.16.0", + "babel-plugin-transform-object-rest-spread": "6.19.0", "babel-plugin-transform-react-constant-elements": "6.9.1", "babel-plugin-transform-react-jsx-self": "6.11.0", "babel-plugin-transform-react-jsx-source": "6.9.0", From bb396df2a169fb282ad0fccf421011722197e5d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20L=C3=B6ve?= Date: Thu, 17 Nov 2016 20:37:20 +0100 Subject: [PATCH 030/143] Fix chrome tab reuse (#1035) * Correctly checks site url to tab url in reuse check * Bring chrome to foreground focused after tab reuse --- packages/react-dev-utils/openChrome.applescript | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-dev-utils/openChrome.applescript b/packages/react-dev-utils/openChrome.applescript index 4dfec4a265..b36b70f6cf 100644 --- a/packages/react-dev-utils/openChrome.applescript +++ b/packages/react-dev-utils/openChrome.applescript @@ -23,7 +23,7 @@ on run argv set theTabIndex to 0 repeat with theTab in every tab of theWindow set theTabIndex to theTabIndex + 1 - if theTab's URL is theURL then + if theTab's URL as string contains theURL then set found to true exit repeat end if @@ -38,6 +38,7 @@ on run argv tell theTab to reload set index of theWindow to 1 set theWindow's active tab index to theTabIndex + tell theWindow to activate else tell window 1 activate From 23fde9487880758244d3a522595dd852b1750583 Mon Sep 17 00:00:00 2001 From: Ville Immonen Date: Thu, 17 Nov 2016 22:55:00 +0200 Subject: [PATCH 031/143] Support Yarn (#898) In the `create-react-app` command, try to install packages using Yarn. If Yarn is not installed, use npm instead. In `react-scripts`, detect if the project is using Yarn by checking if a `yarn.lock` file exists. If the project is using Yarn, display all the instructions with Yarn commands and use Yarn to install packages in `init` and `eject` scripts. --- .travis.yml | 3 ++ packages/create-react-app/index.js | 52 +++++++++++++++++++------ packages/react-scripts/config/paths.js | 3 ++ packages/react-scripts/scripts/build.js | 17 ++++++-- packages/react-scripts/scripts/eject.js | 14 +++++-- packages/react-scripts/scripts/init.js | 45 +++++++++++++-------- packages/react-scripts/scripts/start.js | 6 ++- tasks/e2e.sh | 6 +++ 8 files changed, 110 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index 75383b8780..ec44c3294d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,3 +9,6 @@ cache: - packages/create-react-app/node_modules - packages/react-scripts/node_modules script: tasks/e2e.sh +env: + - USE_YARN=no + - USE_YARN=yes diff --git a/packages/create-react-app/index.js b/packages/create-react-app/index.js index d6478a1354..23d8b5e8de 100644 --- a/packages/create-react-app/index.js +++ b/packages/create-react-app/index.js @@ -101,26 +101,54 @@ function createApp(name, verbose, version) { process.chdir(root); console.log('Installing packages. This might take a couple minutes.'); - console.log('Installing react-scripts from npm...'); + console.log('Installing react-scripts...'); console.log(); run(root, appName, version, verbose, originalDirectory); } -function run(root, appName, version, verbose, originalDirectory) { - var installPackage = getInstallPackage(version); - var packageName = getPackageName(installPackage); +function install(packageToInstall, verbose, callback) { var args = [ - 'install', - verbose && '--verbose', - '--save-dev', - '--save-exact', - installPackage, - ].filter(function(e) { return e; }); - var proc = spawn('npm', args, {stdio: 'inherit'}); + 'add', + '--dev', + '--exact', + packageToInstall, + ]; + var proc = spawn('yarn', args, {stdio: 'inherit'}); + + var yarnExists = true; + proc.on('error', function (err) { + if (err.code === 'ENOENT') { + yarnExists = false; + } + }); proc.on('close', function (code) { + if (yarnExists) { + callback(code, 'yarn', args); + return; + } + // No Yarn installed, continuing with npm. + args = [ + 'install', + verbose && '--verbose', + '--save-dev', + '--save-exact', + packageToInstall, + ].filter(function(e) { return e; }); + var npmProc = spawn('npm', args, {stdio: 'inherit'}); + npmProc.on('close', function (code) { + callback(code, 'npm', args); + }); + }); +} + +function run(root, appName, version, verbose, originalDirectory) { + var packageToInstall = getInstallPackage(version); + var packageName = getPackageName(packageToInstall); + + install(packageToInstall, verbose, function (code, command, args) { if (code !== 0) { - console.error('`npm ' + args.join(' ') + '` failed'); + console.error('`' + command + ' ' + args.join(' ') + '` failed'); return; } diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index 1c154c3616..89cd2059cd 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -43,6 +43,7 @@ module.exports = { appIndexJs: resolveApp('src/index.js'), appPackageJson: resolveApp('package.json'), appSrc: resolveApp('src'), + yarnLockFile: resolveApp('yarn.lock'), testsSetup: resolveApp('src/setupTests.js'), appNodeModules: resolveApp('node_modules'), ownNodeModules: resolveApp('node_modules'), @@ -62,6 +63,7 @@ module.exports = { appIndexJs: resolveApp('src/index.js'), appPackageJson: resolveApp('package.json'), appSrc: resolveApp('src'), + yarnLockFile: resolveApp('yarn.lock'), testsSetup: resolveApp('src/setupTests.js'), appNodeModules: resolveApp('node_modules'), // this is empty with npm3 but node resolution searches higher anyway: @@ -79,6 +81,7 @@ if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) appIndexJs: resolveOwn('../template/src/index.js'), appPackageJson: resolveOwn('../package.json'), appSrc: resolveOwn('../template/src'), + yarnLockFile: resolveOwn('../template/yarn.lock'), testsSetup: resolveOwn('../template/src/setupTests.js'), appNodeModules: resolveOwn('../node_modules'), ownNodeModules: resolveOwn('../node_modules'), diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index d0b92f6a73..8b1cd4cc48 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -21,6 +21,7 @@ require('dotenv').config({silent: true}); var chalk = require('chalk'); var fs = require('fs-extra'); var path = require('path'); +var pathExists = require('path-exists'); var filesize = require('filesize'); var gzipSize = require('gzip-size').sync; var rimrafSync = require('rimraf').sync; @@ -31,6 +32,8 @@ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); var recursive = require('recursive-readdir'); var stripAnsi = require('strip-ansi'); +var useYarn = pathExists.sync(paths.yarnLockFile); + // Warn and crash if required files are missing if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { process.exit(1); @@ -161,7 +164,11 @@ function build(previousSizeMap) { console.log('The ' + chalk.cyan('build') + ' folder is ready to be deployed.'); console.log('To publish it at ' + chalk.green(homepagePath) + ', run:'); console.log(); - console.log(' ' + chalk.cyan('npm') + ' install --save-dev gh-pages'); + if (useYarn) { + console.log(' ' + chalk.cyan('yarn') + ' add gh-pages'); + } else { + console.log(' ' + chalk.cyan('npm') + ' install --save-dev gh-pages'); + } console.log(); console.log('Add the following script in your ' + chalk.cyan('package.json') + '.'); console.log(); @@ -173,7 +180,7 @@ function build(previousSizeMap) { console.log(); console.log('Then run:'); console.log(); - console.log(' ' + chalk.cyan('npm') + ' run deploy'); + console.log(' ' + chalk.cyan(useYarn ? 'yarn' : 'npm') + ' run deploy'); console.log(); } else if (publicPath !== '/') { // "homepage": "http://mywebsite.com/project" @@ -200,7 +207,11 @@ function build(previousSizeMap) { console.log('The ' + chalk.cyan('build') + ' folder is ready to be deployed.'); console.log('You may also serve it locally with a static server:') console.log(); - console.log(' ' + chalk.cyan('npm') + ' install -g pushstate-server'); + if (useYarn) { + console.log(' ' + chalk.cyan('yarn') + ' global add pushstate-server'); + } else { + console.log(' ' + chalk.cyan('npm') + ' install -g pushstate-server'); + } console.log(' ' + chalk.cyan('pushstate-server') + ' build'); console.log(' ' + chalk.cyan(openCommand) + ' http://localhost:9000'); console.log(); diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index dbd4d64e4d..7d4996665e 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -10,6 +10,8 @@ var createJestConfig = require('../utils/createJestConfig'); var fs = require('fs'); var path = require('path'); +var pathExists = require('path-exists'); +var paths = require('../config/paths'); var prompt = require('react-dev-utils/prompt'); var rimrafSync = require('rimraf').sync; var spawnSync = require('cross-spawn').sync; @@ -143,9 +145,15 @@ prompt( ); console.log(); - console.log(cyan('Running npm install...')); - rimrafSync(ownPath); - spawnSync('npm', ['install'], {stdio: 'inherit'}); + if (pathExists.sync(paths.yarnLockFile)) { + console.log(cyan('Running yarn...')); + rimrafSync(ownPath); + spawnSync('yarn', [], {stdio: 'inherit'}); + } else { + console.log(cyan('Running npm install...')); + rimrafSync(ownPath); + spawnSync('npm', ['install'], {stdio: 'inherit'}); + } console.log(green('Ejected successfully!')); console.log(); diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index fa42f6dcee..c9a4ea14ac 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -17,6 +17,7 @@ module.exports = function(appPath, appName, verbose, originalDirectory) { var ownPackageName = require(path.join(__dirname, '..', 'package.json')).name; var ownPath = path.join(appPath, 'node_modules', ownPackageName); var appPackage = require(path.join(appPath, 'package.json')); + var useYarn = pathExists.sync(path.join(appPath, 'yarn.lock')); // Copy over some of the devDependencies appPackage.dependencies = appPackage.dependencies || {}; @@ -58,21 +59,31 @@ module.exports = function(appPath, appName, verbose, originalDirectory) { } }); - // Run another npm install for react and react-dom - console.log('Installing react and react-dom from npm...'); + // Run yarn or npm for react and react-dom + // TODO: having to do two npm/yarn installs is bad, can we avoid it? + var command; + var args; + + if (useYarn) { + command = 'yarn'; + args = ['add']; + } else { + command = 'npm'; + args = [ + 'install', + '--save', + verbose && '--verbose' + ].filter(function(e) { return e; }); + } + args.push('react', 'react-dom'); + + console.log('Installing react and react-dom using ' + command + '...'); console.log(); - // TODO: having to do two npm installs is bad, can we avoid it? - var args = [ - 'install', - 'react', - 'react-dom', - '--save', - verbose && '--verbose' - ].filter(function(e) { return e; }); - var proc = spawn('npm', args, {stdio: 'inherit'}); + + var proc = spawn(command, args, {stdio: 'inherit'}); proc.on('close', function (code) { if (code !== 0) { - console.error('`npm ' + args.join(' ') + '` failed'); + console.error('`' + command + ' ' + args.join(' ') + '` failed'); return; } @@ -91,23 +102,23 @@ module.exports = function(appPath, appName, verbose, originalDirectory) { console.log('Success! Created ' + appName + ' at ' + appPath); console.log('Inside that directory, you can run several commands:'); console.log(); - console.log(chalk.cyan(' npm start')); + console.log(chalk.cyan(' ' + command + ' start')); console.log(' Starts the development server.'); console.log(); - console.log(chalk.cyan(' npm run build')); + console.log(chalk.cyan(' ' + command + ' run build')); console.log(' Bundles the app into static files for production.'); console.log(); - console.log(chalk.cyan(' npm test')); + console.log(chalk.cyan(' ' + command + ' test')); console.log(' Starts the test runner.'); console.log(); - console.log(chalk.cyan(' npm run eject')); + console.log(chalk.cyan(' ' + command + ' run eject')); console.log(' Removes this tool and copies build dependencies, configuration files'); console.log(' and scripts into the app directory. If you do this, you can’t go back!'); console.log(); console.log('We suggest that you begin by typing:'); console.log(); console.log(chalk.cyan(' cd'), cdpath); - console.log(' ' + chalk.cyan('npm start')); + console.log(' ' + chalk.cyan(command + ' start')); if (readmeExists) { console.log(); console.log(chalk.yellow('You had a `README.md` file, we renamed it to `README.old.md`')); diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 8a115dd8e2..5e996c71dd 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -28,9 +28,13 @@ var checkRequiredFiles = require('react-dev-utils/checkRequiredFiles'); var formatWebpackMessages = require('react-dev-utils/formatWebpackMessages'); var openBrowser = require('react-dev-utils/openBrowser'); var prompt = require('react-dev-utils/prompt'); +var pathExists = require('path-exists'); var config = require('../config/webpack.config.dev'); var paths = require('../config/paths'); +var useYarn = pathExists.sync(paths.yarnLockFile); +var cli = useYarn ? 'yarn' : 'npm'; + // Warn and crash if required files are missing if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) { process.exit(1); @@ -85,7 +89,7 @@ function setupCompiler(host, port, protocol) { console.log(' ' + chalk.cyan(protocol + '://' + host + ':' + port + '/')); console.log(); console.log('Note that the development build is not optimized.'); - console.log('To create a production build, use ' + chalk.cyan('npm run build') + '.'); + console.log('To create a production build, use ' + chalk.cyan(cli + ' run build') + '.'); console.log(); } diff --git a/tasks/e2e.sh b/tasks/e2e.sh index 88e1fdf4e2..094fba9e22 100755 --- a/tasks/e2e.sh +++ b/tasks/e2e.sh @@ -53,6 +53,12 @@ set -x cd .. root_path=$PWD +if [ "$USE_YARN" = "yes" ] +then + # Install Yarn so that the test can use it to install packages. + npm install -g yarn +fi + npm install # Lint own code From 5cc7fa41045d0f6b7b14af39418595029d2d4067 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 20 Nov 2016 01:58:46 +0000 Subject: [PATCH 032/143] It's important after all --- packages/react-scripts/template/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 75c8c67487..66ceb5bedc 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -883,15 +883,19 @@ This will let Create React App correctly infer the root path to use in the gener >Note: this feature is available with `react-scripts@0.2.0` and higher. +**THE BELOW STEP IS IMPORTANT!**
+**If your skip it, your app will not deploy correctly.** + Open your `package.json` and add a `homepage` field: ```js "homepage": "https://myusername.github.io/my-app", ``` -**The above step is important!**
Create React App uses the `homepage` field to determine the root URL in the built HTML file. +**Have you added the `homepage` field? Then let's move on.** + Now, whenever you run `npm run build`, you will see a cheat sheet with instructions on how to deploy to GitHub Pages. To publish it at [https://myusername.github.io/my-app](https://myusername.github.io/my-app), run: @@ -918,6 +922,8 @@ Then run: npm run deploy ``` +**If you see 404 errors for JS and CSS, re-read the note at the beginning of this section saying "THE BELOW STEP IS IMPORTANT".** + You can configure a custom domain with GitHub Pages by adding a `CNAME` file to the `public/` folder. Note that 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: From bbcf13995f24cded037193d84960af2a1ac52462 Mon Sep 17 00:00:00 2001 From: Nazim Hajidin Date: Sun, 20 Nov 2016 08:30:12 -0500 Subject: [PATCH 033/143] Add missing --dev argument (#1058) --- 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 8b1cd4cc48..d40912f287 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -165,7 +165,7 @@ function build(previousSizeMap) { console.log('To publish it at ' + chalk.green(homepagePath) + ', run:'); console.log(); if (useYarn) { - console.log(' ' + chalk.cyan('yarn') + ' add gh-pages'); + console.log(' ' + chalk.cyan('yarn') + ' add --dev gh-pages'); } else { console.log(' ' + chalk.cyan('npm') + ' install --save-dev gh-pages'); } From 08eb9fdabe8eff38758952003ce62b8b05a0ccf4 Mon Sep 17 00:00:00 2001 From: Nazim Hajidin Date: Sun, 20 Nov 2016 08:35:35 -0500 Subject: [PATCH 034/143] Update css loader (#1057) * Update css-loader to 0.26.0 * Update the production webpack config --- packages/react-scripts/config/webpack.config.prod.js | 10 +--------- packages/react-scripts/package.json | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.prod.js b/packages/react-scripts/config/webpack.config.prod.js index e0141b851b..18da92caef 100644 --- a/packages/react-scripts/config/webpack.config.prod.js +++ b/packages/react-scripts/config/webpack.config.prod.js @@ -142,15 +142,7 @@ module.exports = { // in the main CSS file. { test: /\.css$/, - // "?-autoprefixer" disables autoprefixer in css-loader itself: - // https://github.com/webpack/css-loader/issues/281 - // We already have it thanks to postcss. We only pass this flag in - // production because "css" loader only enables autoprefixer-powered - // removal of unnecessary prefixes when Uglify plugin is enabled. - // Webpack 1.x uses Uglify plugin as a signal to minify *all* the assets - // including CSS. This is confusing and will be removed in Webpack 2: - // https://github.com/webpack/webpack/issues/283 - loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1&-autoprefixer!postcss') + loader: ExtractTextPlugin.extract('style', 'css?importLoaders=1!postcss') // Note: this won't work without `new ExtractTextPlugin()` in `plugins`. }, // JSON is not enabled by default in Webpack but both Node and Browserify diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index b4cad96397..3bad0b428f 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -33,7 +33,7 @@ "chalk": "1.1.3", "connect-history-api-fallback": "1.3.0", "cross-spawn": "4.0.2", - "css-loader": "0.25.0", + "css-loader": "0.26.0", "detect-port": "1.0.1", "dotenv": "2.0.0", "eslint": "3.8.1", From f7a3dfd58f95d62f1bcf062433f709f08d3ac556 Mon Sep 17 00:00:00 2001 From: Nazim Hajidin Date: Sun, 20 Nov 2016 09:23:11 -0500 Subject: [PATCH 035/143] Don't look for babelrc file during test (#1017) --- packages/react-scripts/config/jest/transform.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/react-scripts/config/jest/transform.js b/packages/react-scripts/config/jest/transform.js index 11a0149f97..145bd86cc9 100644 --- a/packages/react-scripts/config/jest/transform.js +++ b/packages/react-scripts/config/jest/transform.js @@ -9,5 +9,6 @@ const babelJest = require('babel-jest'); module.exports = babelJest.createTransformer({ - presets: [require.resolve('babel-preset-react-app')] + presets: [require.resolve('babel-preset-react-app')], + babelrc: false }); From e709eb96dae6132e43536ad4b6ba6dbcb8ffebe1 Mon Sep 17 00:00:00 2001 From: ekaradon Date: Sun, 20 Nov 2016 18:24:54 +0100 Subject: [PATCH 036/143] fix poor performance with firefox when using `eval` as `devtool` (#924) Enable sourcemaps in development --- packages/react-scripts/config/webpack.config.dev.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/react-scripts/config/webpack.config.dev.js b/packages/react-scripts/config/webpack.config.dev.js index c2b544cca5..fff8cd7053 100644 --- a/packages/react-scripts/config/webpack.config.dev.js +++ b/packages/react-scripts/config/webpack.config.dev.js @@ -33,11 +33,9 @@ var env = getClientEnvironment(publicUrl); // It is focused on developer experience and fast rebuilds. // The production configuration is different and lives in a separate file. module.exports = { - // This makes the bundle appear split into separate modules in the devtools. - // We don't use source maps here because they can be confusing: - // https://github.com/facebookincubator/create-react-app/issues/343#issuecomment-237241875 - // You may want 'cheap-module-source-map' instead if you prefer source maps. - devtool: 'eval', + // You may want 'eval' instead if you prefer to see the compiled output in DevTools. + // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343. + devtool: 'cheap-module-source-map', // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. // The first two entry points enable "hot" CSS and auto-refreshes for JS. From 0a91f63c5b50426467a97d8a5e84c7d19bc857a3 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 20 Nov 2016 18:13:09 +0000 Subject: [PATCH 037/143] Update GH deploy instructions to match User Guide --- 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 d40912f287..d03138b50f 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -175,7 +175,7 @@ function build(previousSizeMap) { console.log(' ' + chalk.dim('// ...')); console.log(' ' + chalk.yellow('"scripts"') + ': {'); console.log(' ' + chalk.dim('// ...')); - console.log(' ' + chalk.yellow('"deploy"') + ': ' + chalk.yellow('"gh-pages -d build"')); + console.log(' ' + chalk.yellow('"deploy"') + ': ' + chalk.yellow('"npm run build&&gh-pages -d build"')); console.log(' }'); console.log(); console.log('Then run:'); From bc8473b9b8ceee9e61ab6dd4e6e7619f087c5c15 Mon Sep 17 00:00:00 2001 From: Fabrizio Castellarin Date: Sun, 20 Nov 2016 19:34:18 +0100 Subject: [PATCH 038/143] Move the remove-on-eject-end tag at the end of the file (#978) --- packages/react-scripts/config/paths.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/config/paths.js b/packages/react-scripts/config/paths.js index 89cd2059cd..d15b16a054 100644 --- a/packages/react-scripts/config/paths.js +++ b/packages/react-scripts/config/paths.js @@ -70,7 +70,6 @@ module.exports = { ownNodeModules: resolveOwn('../node_modules'), nodePaths: nodePaths }; -// @remove-on-eject-end // config before publish: we're in ./packages/react-scripts/config/ if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) { @@ -88,3 +87,4 @@ if (__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1) nodePaths: nodePaths }; } +// @remove-on-eject-end From 8fbe8719a951f1131bd4c11815c07ea8db81559b Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Mon, 21 Nov 2016 00:45:59 +0530 Subject: [PATCH 039/143] Add Storybook to the user guide (#738) * Add Storybook to the user guide * Add the missing "Snapshot Testing" link. * Change the title to something nicer Old title was looks like a marketing pitch. Change it to something looks great. The new one is: Developing UI Components with React Storybook. * Mention React Storybook as a third party tool. * Nits * Minor changes --- packages/react-scripts/template/README.md | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 66ceb5bedc..7e6df217d7 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -42,6 +42,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Continuous Integration](#continuous-integration) - [Disabling jsdom](#disabling-jsdom) - [Experimental Snapshot Testing](#experimental-snapshot-testing) +- [Developing UI Components with React Storybook](#developing-ui-components-with-react-storybook) - [Deployment](#deployment) - [Building for Relative Paths](#building-for-relative-paths) - [GitHub Pages](#github-pages) @@ -866,6 +867,46 @@ Snapshot testing is a new feature of Jest that automatically generates text snap This feature is experimental and still [has major usage issues](https://github.com/facebookincubator/create-react-app/issues/372) so we only encourage you to use it if you like experimental technology. We intend to gradually improve it over time and eventually offer it as the default solution for testing React components, but this will take time. [Read more about snapshot testing.](http://facebook.github.io/jest/blog/2016/07/27/jest-14.html) +## Developing UI Components with React Storybook + +Usually, in an app, you have a lot of UI components, and each of them has many different states. +For an example, a simple button component could have following states: + +* With a text label. +* With an emoji. +* In the disabled mode. + +Usually, it’s hard to see these states without running a sample app or some examples. + +That’s where you could get some help from [React Storybook](https://github.com/kadirahq/react-storybook). **It is a third party tool that lets you develop components and see all their states in isolation from your app**. + +![React Storybook Demo](http://i.imgur.com/7CIAWpB.gif) + +You can also deploy your Storybook 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. + +**Here’s how to setup your app with Storybook:** + +First, install the following npm package globally: + +```sh +npm install -g getstorybook +``` + +Then, run the following command inside your app’s directory: + +```sh +getstorybook +``` + +After that, follow the instructions on the screen. + +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/kadirahq/react-storybook) +* [Documentation](https://getstorybook.io/docs) +* [Snapshot Testing](https://github.com/kadirahq/storyshots) with React Storybook + ## Deployment ## Building for Relative Paths From 1ba93d0c552570354d31d91734c39c5cef48e4ca Mon Sep 17 00:00:00 2001 From: Jurie Horneman Date: Sun, 20 Nov 2016 20:29:45 +0100 Subject: [PATCH 040/143] Added info on using global variables. (#976) * Added info on using global variables. See issue #972. * Fixed typo. * Moved new section. * Small tweaks * Syntax highlighting --- packages/react-scripts/template/README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 7e6df217d7..d5e7bedc38 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -20,6 +20,7 @@ You can find the most recent version of this guide [here](https://github.com/fac - [Post-Processing CSS](#post-processing-css) - [Adding Images and Fonts](#adding-images-and-fonts) - [Using the `public` Folder](#using-the-public-folder) +- [Using Global Variables Defined Elsewhere](#using-global-variables-defined-elsewhere) - [Adding Bootstrap](#adding-bootstrap) - [Adding Flow](#adding-flow) - [Adding Custom Environment Variables](#adding-custom-environment-variables) @@ -385,6 +386,22 @@ Keep in mind the downsides of this approach: However, it can be handy for referencing assets like [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest) from HTML, or including small scripts like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code. +Note that if you add a `