Skip to content

merging upstream master #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 79 commits into from
Apr 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
df03772
revert sass sourcemaps in development
Feb 20, 2019
43129f1
remove webpack-bundle-analyzer
Feb 21, 2019
e7a427a
remove webpack-bundle-analyzer
Feb 21, 2019
da2d047
Merge branch 'master' of https://github.com/bugzpodder/create-react-app
Feb 21, 2019
140e182
remove stats json
Feb 21, 2019
4a4d2ef
remove argv
Feb 21, 2019
3c9c21a
Upgrade dependencies (#6614)
ianschmitz Mar 12, 2019
dc133a3
Stage files for commit after ejecting (#5960)
clickclickonsal Mar 12, 2019
b60f56f
change named import into default import (#6625)
xiaoxiangmoe Mar 12, 2019
a500ede
Add note about npx caching (#6374)
TaylorBriggs Mar 13, 2019
88d6f02
Add empty mock for http2 (#5686)
kjin Mar 14, 2019
f4f20a2
Support browserslist in @babel/preset-env (#6608)
ianschmitz Mar 14, 2019
7ae3146
Support React Hooks (#5602) (#5997)
EivindArvesen Mar 15, 2019
eee8491
Add TypeScript linting support (#6513)
ianschmitz Mar 15, 2019
3be3576
Update to Jest 24 (#6278)
lorenzorapetti Mar 15, 2019
b0cbf2c
Prepare 3.0.0 alpha release
iansu Mar 15, 2019
6902736
Unpin eslint-config-react-hooks dependency (#6653)
iansu Mar 15, 2019
7864ba3
Add wait: false when opening app in browser (#5821)
Mar 15, 2019
5861d6e
Bump babel-eslint peerDependency in eslint-config-react-app (#6662)
dalcib Mar 16, 2019
8175f1e
Remove unused eslint comment (#6674)
mohitsinghs Mar 18, 2019
c5087e6
Remove shrink-to-fit=no from templates (#6669)
rifaidev Mar 18, 2019
4734d4e
Merge branch 'master' into master
Mar 19, 2019
b424737
Change app component declaration from arrow function to regular funct…
iansu Mar 19, 2019
a1f6397
Remove duplicate url key in Docusaurus siteConfig (#6690)
charpeni Mar 21, 2019
5c637a4
Add deployment instructions with AWS Amplify (#6208)
swaminator Mar 21, 2019
d3b19f9
Add clarifying documentation for how to add a sass stylesheet on Wind…
monish001 Mar 24, 2019
5acb286
Kill verdaccio in CI tasks cleanup (#6700)
santoshyadavdev Mar 26, 2019
fb6851d
Docs: Add clarifying note about naming variables (#6491)
stephengodderidge Mar 26, 2019
1a61db5
Remove project property from @typescript-eslint/parser options (#6701)
jackwilsdon Mar 29, 2019
9514cb8
Remove --coverage + --watch workaround (#4176)
stipsan Apr 2, 2019
d42f888
Document .graphql and .gql file loading with graphql.macro (#5481)
petetnt Apr 3, 2019
e630238
Add explanation for adding everything as dependencies to docs (#6082)
attaradev Apr 3, 2019
76fea02
Cleanup Jest config (#6654)
ianschmitz Apr 4, 2019
bf7d1c4
Add temporary workaround for Babel dependency issues in installs test…
iansu Apr 4, 2019
001c23e
Enable futureEmitAssets in webpack config (#6696)
iansu Apr 4, 2019
42640df
Only suggest that tsconfig.json is incorrect when SyntaxError is caug…
Andarist Apr 4, 2019
ac15fae
Fix unlogged yarn pnp message (#6759)
heyimalex Apr 4, 2019
3e336d9
fix: terser-webpack-plugin hanging on WSL (#6732)
endiliey Apr 5, 2019
b8a47d9
Replace deprecated SFC with FunctionComponent (#6746)
Apr 5, 2019
f1523a6
Add temporary workaround for Babel dependency issues in kitchensink-e…
iansu Apr 5, 2019
ffcd896
Update to workbox-webpack-plugin v4 (#6725)
r0ughnex Apr 5, 2019
550274e
Adds PostCSS Normalize (#5810)
mrchief Apr 5, 2019
c03d6b1
Update fork-ts-checker-webpack-plugin out of alpha (#6739)
pelotom Apr 6, 2019
91ddd61
Update dependency versions (#6767)
ianschmitz Apr 6, 2019
7114965
Update to core-js@3
ianschmitz Apr 6, 2019
278c62c
Revert "Update to core-js@3"
ianschmitz Apr 6, 2019
ebabd18
Change NODE_ENV and PUBLIC_URL to readonly (#6750)
xiaoxiangmoe Apr 7, 2019
a1d6aef
Add Render deployment section (#6695)
anurag Apr 8, 2019
a8a3ccf
Update link to React Testing Library docs (#6772)
fjoshuajr Apr 8, 2019
80b69ed
Warn when using react-scripts-ts (#6770)
ianschmitz Apr 9, 2019
dac046d
Fix code comment typo (#6775)
bestseob93 Apr 9, 2019
b676bf3
Remove unused babel-loader from babel-preset-react-app (#6780)
tlrobinson Apr 9, 2019
e59e092
Add SVG support dependency note (#6783)
pnarielwala Apr 10, 2019
431ccf9
Clarify production build output files documentation (#6786)
bakuzan Apr 13, 2019
7154487
Add link to TypeScript page in Getting Started (#6817)
ianschmitz Apr 14, 2019
9600b16
Fix minimum React version for SVG component support (#6820)
iansu Apr 14, 2019
b29a163
Copy fix (#6801)
panckreous Apr 14, 2019
bffc296
Update to core-js@3 (#6769)
ianschmitz Apr 14, 2019
fdbb550
InlineChunkHtmlPlugin works with empty publicPath (#6735)
ItalyPaleAle Apr 16, 2019
50c1884
Fix react-scripts peer dependencies link local issue (#6579) (#6580)
transitive-bullshit Apr 16, 2019
9048dd6
Move list of files under `files` key in asset manifest (#6821)
iansu Apr 16, 2019
207d931
Update testMatch to also be compatible with Jest 24 (#6313)
ngbrown Apr 16, 2019
ced3fd4
Add directory details to packages/* package.json (#6826)
feelepxyz Apr 16, 2019
e7a2d61
Set baseUrl from jsconfig.json/tsconfig.json (#6656)
robertvansteen Apr 16, 2019
2add128
Prepare 3.0.0 alpha release
iansu Apr 16, 2019
657ae2f
Upgrade to Lerna v3 (#6829)
iansu Apr 17, 2019
4b5b76b
Prepare 3.0.0 alpha release
iansu Apr 17, 2019
f5b0aac
Relax ESLint version range (#6840)
ianschmitz Apr 18, 2019
022b984
Change Create React App version in `react-scripts` eject warning (#6845)
lffg Apr 19, 2019
200b98b
Remove no-watch flag in favor of watchAll=false (#6848)
Apr 19, 2019
2303b49
Add baseUrl documentation (#6847)
ianschmitz Apr 19, 2019
e11ebfa
Update fsevents dependency version (#6843)
FrancoisRmn Apr 21, 2019
fa005d8
Update stale.yml
iansu Apr 21, 2019
6cddf9c
Prepare 3.0.0 release
iansu Apr 22, 2019
265c159
Publish
iansu Apr 22, 2019
c38aecf
Fix typo in README.md (#6879)
david-cho-lerat-HL2 Apr 24, 2019
0022607
Fix no-useless-constructor rule in TypeScript (#6862)
ianschmitz Apr 24, 2019
73d5579
Remove body padding reset from templates (#6300)
Hurtak Apr 24, 2019
126bded
Fix typo in deployment docs (#6881)
david-cho-lerat-HL2 Apr 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ exemptLabels:
- "issue: bug"
- "issue: needs investigation"
- "issue: proposal"
- "tag: bug fix"
- "tag: breaking change"
- "tag: bug fix"
- "tag: documentation"
- "tag: enhancement"
- "tag: internal"
- "tag: new feature"
- "tag: underlying tools"

# Set to true to ignore issues in a project (defaults to false)
exemptProjects: true
Expand Down
1,390 changes: 1,390 additions & 0 deletions CHANGELOG-2.x.md

Large diffs are not rendered by default.

1,509 changes: 193 additions & 1,316 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ By default git would use `CRLF` line endings which would cause the scripts to fa
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.
10. 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 -- --canary=next --exact --cd-version patch --npm-tag=next` instead of `npm run publish`.
Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- prepatch --canary --preid next --dist-tag next --npm-client npm --force-publish` instead of `npm run publish`.

---

Expand Down
6 changes: 6 additions & 0 deletions docusaurus/docs/adding-a-sass-stylesheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ If you set `SASS_PATH=node_modules:src`, this will allow you to do imports like
@import 'nprogress/nprogress'; // importing a css file from the nprogress node module
```

> **Note:** For windows operating system, use below syntax
>
> ```
> SASS_PATH=./node_modules;./src
> ```

> **Tip:** You can opt into using this feature with [CSS modules](adding-a-css-modules-stylesheet.md) too!

> **Note:** If you're using Flow, override the [module.file_ext](https://flow.org/en/docs/config/options/#toc-module-file-ext-string) setting in your `.flowconfig` so it'll recognize `.sass` or `.scss` files. You will also need to include the `module.file_ext` default settings for `.js`, `.jsx`, `.mjs` and `.json` files.
Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/adding-bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: adding-bootstrap
title: Adding Bootstrap
---

While you don’t have to use any specific library to integrate Bootstrap with React apps, it's often easier than trying to wrap the Bootstrap jQuery plugins. [React Bootstrap](https://react-bootstrap.netlify.com/) is the most popular option, that strives for complete parity with bootstrap. [reactstrap](https://reactstrap.github.io/) is also a good choice for projects looking for smaller builds at the expense of some features.
While you don’t have to use any specific library to integrate Bootstrap with React apps, it's often easier than trying to wrap the Bootstrap jQuery plugins. [React Bootstrap](https://react-bootstrap.netlify.com/) is the most popular option that strives for complete parity with Bootstrap. [reactstrap](https://reactstrap.github.io/) is also a good choice for projects looking for smaller builds at the expense of some features.

Each project's respective documentation site has detailed instructions for installing and using them. Both depend on the Bootstrap css file so install that as well:

Expand Down
71 changes: 71 additions & 0 deletions docusaurus/docs/adding-css-reset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
id: adding-css-reset
title: Adding a CSS Reset
sidebar_label: Adding CSS Reset
---

This project setup uses [PostCSS Normalize] for adding a [CSS Reset].

To start using it, add `@import-normalize;` anywhere in your CSS file(s). You only need to include it once and duplicate imports are automatically removed. Since you only need to include it once, a good place to add it is `index.css` or `App.css`.

## `index.css`

```css
@import-normalize; /* bring in normalize.css styles */

/* rest of app styles */
```

You can control which parts of [normalize.css] to use via your project's [browserslist].

Results when [browserslist] is `last 3 versions`:

```css
/**
* Add the correct display in IE 9-.
*/

audio,
video {
display: inline-block;
}

/**
* Remove the border on images inside links in IE 10-.
*/

img {
border-style: none;
}
```

Results when [browserslist] is `last 2 versions`:

```css
/**
* Remove the border on images inside links in IE 10-.
*/

img {
border-style: none;
}
```

## Browser support

Browser support is dictated by what normalize.css [supports]. As of this writing, it includes:

- Chrome (last 3)
- Edge (last 3)
- Firefox (last 3)
- Firefox ESR
- Opera (last 3)
- Safari (last 3)
- iOS Safari (last 2)
- Internet Explorer 9+

[browserslist]: http://browserl.ist/
[css reset]: https://cssreset.com/what-is-a-css-reset/
[normalize.css]: https://github.com/csstools/normalize.css
[supports]: https://github.com/csstools/normalize.css#browser-support
[postcss normalize]: https://github.com/csstools/postcss-normalize
2 changes: 1 addition & 1 deletion docusaurus/docs/adding-images-fonts-and-files.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ An alternative way of handling static assets is described in the next section.

## Adding SVGs

> Note: this feature is available with `react-scripts@2.0.0` and higher.
> Note: this feature is available with `react-scripts@2.0.0` and higher, and `react@16.3.0` and higher.

One way to add SVG files was described in the section above. You can also import SVGs directly as React components. You can use either of the two approaches. In your code it would look like this:

Expand Down
3 changes: 3 additions & 0 deletions docusaurus/docs/adding-typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ Type errors will show up in the same console as the build one.

To learn more about TypeScript, check out [its documentation](https://www.typescriptlang.org/).

> **Note:** If your project is not created with TypeScript enabled, npx may be using a cached version of `create-react-app`.
> Remove previously installed versions with `npm uninstall -g create-react-app` (see [#6119](https://github.com/facebook/create-react-app/issues/6119#issuecomment-451614035)).

> **Note:** You are not required to make a [`tsconfig.json` file](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html), one will be made for you.
> You are allowed to edit the generated TypeScript configuration.

Expand Down
4 changes: 3 additions & 1 deletion docusaurus/docs/advanced-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ id: advanced-configuration
title: Advanced Configuration
---

You can adjust various development and production settings by setting environment variables in your shell or with [.env](adding-custom-environment-variables.md#adding-development-environment-variables-in-env).
You can adjust various development and production settings by setting environment variables in your shell or with [.env](adding-custom-environment-variables.md#adding-development-environment-variables-in-env).

> Note: You do not need to declare `REACT_APP_` before the below variables as you would with custom environment variables.

| Variable | Development | Production | Usage |
| :------------------- | :---------: | :--------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
6 changes: 5 additions & 1 deletion docusaurus/docs/available-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ Your app is ready to be deployed! See the section about [deployment](deployment.

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc.) into your project as dependencies in `package.json`. Technically, the distinction between dependencies and development dependencies is pretty arbitrary for front-end apps that produce static bundles.

In addition, it used to cause problems with some hosting platforms that didn't install development dependencies (and thus weren't able to build the project on the server or test it right before deployment). You are free to rearrange your dependencies in `package.json` as you see fit.

All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
2 changes: 1 addition & 1 deletion docusaurus/docs/debugging-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Use the following [`launch.json`](https://code.visualstudio.com/docs/editor/debu
"test",
"--runInBand",
"--no-cache",
"--no-watch"
"--watchAll=false"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
Expand Down
23 changes: 21 additions & 2 deletions docusaurus/docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ service worker navigation routing can be configured or disabled by
[`eject`ing](available-scripts.md#npm-run-eject) and then modifying the
[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string)
and [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp)
options of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js).
options of the `SWPrecachePlugin` [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:

Expand Down Expand Up @@ -160,6 +160,17 @@ You can specify other environments in the same way.

Variables in `.env.production` will be used as fallback because `NODE_ENV` will always be set to `production` for a build.

## [AWS Amplify](http://console.amplify.aws)

The AWS Amplify Console provides continuous deployment and hosting for modern web apps (single page apps and static site generators) with serverless backends. The Amplify Console offers globally available CDNs, easy custom domain setup, feature branch deployments, and password protection.

1. Login to the Amplify Console [here](https://console.aws.amazon.com/amplify/home).
1. Connect your Create React App repo and pick a branch. If you're looking for a Create React App+Amplify starter, try the [create-react-app-auth-amplify starter](https://github.com/swaminator/create-react-app-auth-amplify) that demonstrates setting up auth in 10 minutes with Create React App.
1. The Amplify Console automatically detects the build settings. Choose Next.
1. Choose _Save and deploy_.

If the build succeeds, the app is deployed and hosted on a global CDN with an amplifyapp.com domain. You can now continuously deploy changes to your frontend or backend. Continuous deployment allows developers to deploy updates to their frontend and backend on every code commit to their Git repository.

## [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.
Expand Down Expand Up @@ -443,10 +454,18 @@ To deploy your built project directly with Now CLI in your terminal, without any

3. Run `now --name your-project-name` from within the build directory. You will be given a **now.sh** URL as a response as your build is deployed, similar to the following: https://my-cra-project-4rx7b16z3.now.sh/

Click or paste the deployment URL into your browser when the build is complete and you will see your deployed app.
Click or paste the deployment URL into your browser when the build is complete and you will see your deployed app.

For more information on deploying React applications with Now, including automatically building your application fresh in the cloud, setting up routes to rewrite all paths to the index.html file, and setting up caching headers for speed, see [the ZEIT Guide for Deploying a React app with Create React App](https://zeit.co/guides/deploying-react-with-now-cra/).

## [Render](https://render.com)

Render offers free [static site](https://render.com/docs/static-sites) hosting with fully managed SSL, a global CDN and continuous auto deploys from GitHub.

Deploy your app in just a few minutes by following the [Create React App deployment guide](https://render.com/docs/deploy-create-react-app).

Use invite code `cra` to sign up or use [this link](https://render.com/i/cra).

## [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.
Expand Down
6 changes: 5 additions & 1 deletion docusaurus/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Just create a project, and you’re good to go.

## Creating an App

**You’ll need to have Node >= 6 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
**You’ll need to have Node >= 8.10 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.

To create a new app, you may choose one of the following methods:

Expand Down Expand Up @@ -62,6 +62,10 @@ yarn create react-app my-app

_`yarn create` is available in Yarn 0.25+_

### Creating a TypeScript app

Follow our [Adding TypeScript](adding-typescript.md) documentation to create a TypeScript app.

## Output

Running any of these commands will create a directory called `my-app` inside the current folder. Inside that directory, it will generate the initial project structure and install the transitive dependencies:
Expand Down
25 changes: 25 additions & 0 deletions docusaurus/docs/importing-a-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,28 @@ Learn more about ES6 modules:
- [When to use the curly braces?](https://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281)
- [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html)
- [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules)

## Absolute Imports

You can configure your application to support importing modules using absolute paths. This can be done by configuring a `jsconfig.json` or `tsconfig.json` file in the root of your project. If you're using TypeScript in your project, you will already have a `tsconfig.json` file.

Below is an example `jsconfig.json` file for a JavaScript project. You can create the file if it doesn't already exist:

```json
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
```

If you're using TypeScript, you can configure the `baseUrl` setting inside the `compilerOptions` of your project's `tsconfig.json` file.

Now that you've configured your project to support absolute imports, if you want to import a module located at `src/components/Button.js`, you can import the module like so:

```js
import Button from 'components/Button';
```

For more information on these configuration files, see the [jsconfig.json reference](https://code.visualstudio.com/docs/languages/jsconfig) and [tsconfig.json reference](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) documentation.
71 changes: 71 additions & 0 deletions docusaurus/docs/loading-graphql-files.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
id: loading-graphql-files
title: Loading .graphql Files
sidebar_label: Loading .graphql Files
---

To load `.gql` and `.graphql` files, first install the [`graphql.macro`](https://www.npmjs.com/package/graphql.macro) package by running:

```sh
npm install --save graphql.macro
```

Alternatively you may use `yarn`:

```sh
yarn add graphql.macro
```

Then, whenever you want to load `.gql` or `.graphql` files, import the `loader` from the macro package:

```js
import { loader } from 'graphql.macro';

const query = loader('./foo.graphql');
```

And your results get automatically inlined! This means that if the file above, `foo.graphql`, contains the following:

```graphql
gql`
query {
hello {
world
}
}
`;
```

The previous example turns into:

```javascript
const query = {
'kind': 'Document',
'definitions': [{
...
}],
'loc': {
...
'source': {
'body': '\\\\n query {\\\\n hello {\\\\n world\\\\n }\\\\n }\\\\n',
'name': 'GraphQL request',
...
}
}
};
```

You can also use the `gql` template tag the same way you would use the non-macro version from `graphql-tag` package with the added benefit of inlined parsing results.

```js
import { gql } from 'graphql.macro';

const query = gql`
query User {
user(id: 5) {
lastName
...UserEntry1
}
}
`;
```
6 changes: 3 additions & 3 deletions docusaurus/docs/production-build.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ title: Creating a Production Build

`npm run build` creates a `build` directory with a production build of your app. Inside the `build/static` directory will be your JavaScript and CSS files. Each filename inside of `build/static` will contain a unique hash of the file contents. This hash in the file name enables [long term caching techniques](#static-file-caching).

When running a production build of freshly created Create React App application, there are 3 `.js` files (called _chunks_) that are generated and placed in the `build/static/js` directory:
When running a production build of freshly created Create React App application, there are a number of `.js` files (called _chunks_) that are generated and placed in the `build/static/js` directory:

`main.[hash].chunk.js`

- This is your _application_ code. `App.js`, etc.

`1.[hash].chunk.js`
`[number].[hash].chunk.js`

- This is your _vendor_ code, which includes modules you've imported from within `node_modules`. One of the potential advantages with splitting your _vendor_ and _application_ code is to enable [long term caching techniques](#static-file-caching) to improve application loading performance. Since _vendor_ code tends to change less often than the actual _application_ code, the browser will be able to cache them separately, and won't re-download them each time the app code changes.
- These files can either be _vendor_ code, or [code splitting chunks](code-splitting.md). _Vendor_ code includes modules that you've imported from within `node_modules`. One of the potential advantages with splitting your _vendor_ and _application_ code is to enable [long term caching techniques](#static-file-caching) to improve application loading performance. Since _vendor_ code tends to change less often than the actual _application_ code, the browser will be able to cache them separately, and won't re-download them each time the app code changes.

`runtime~main.[hash].js`

Expand Down
Loading