Skip to content

Commit 69b146e

Browse files
authored
Merge branch 'canary' into patch-3
2 parents f00eee8 + fad07cc commit 69b146e

File tree

206 files changed

+3820
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

206 files changed

+3820
-415
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ packages/next-codemod/transforms/__testfixtures__/**/*
1313
packages/next-codemod/transforms/__tests__/**/*
1414
packages/next-codemod/**/*.js
1515
packages/next-codemod/**/*.d.ts
16+
packages/next-env/**/*.d.ts
17+
test/integration/async-modules/**

.github/actions/next-stats-action/src/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const path = require('path')
2+
const fs = require('fs-extra')
13
const exec = require('./util/exec')
24
const logger = require('./util/logger')
35
const runConfigs = require('./run')
@@ -25,6 +27,13 @@ if (!allowedActions.has(actionInfo.actionName) && !actionInfo.isRelease) {
2527

2628
;(async () => {
2729
try {
30+
if (await fs.pathExists(path.join(__dirname, '../SKIP_NEXT_STATS.txt'))) {
31+
console.log(
32+
'SKIP_NEXT_STATS.txt file present, exiting stats generation..'
33+
)
34+
process.exit(0)
35+
}
36+
2837
const { stdout: gitName } = await exec(
2938
'git config user.name && git config user.email'
3039
)

.github/actions/next-stats-action/src/prepare/action-info.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ module.exports = function actionInfo() {
5656
isLocal: LOCAL_STATS,
5757
commitId: null,
5858
issueId: ISSUE_ID,
59-
isRelease: releaseTypes.has(GITHUB_ACTION),
59+
isRelease:
60+
GITHUB_REPOSITORY === 'vercel/next.js' &&
61+
(GITHUB_REF || '').includes('canary'),
6062
}
6163

6264
// get comment

.github/workflows/build_test_deploy.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ jobs:
107107
steps:
108108
- uses: actions/checkout@v2
109109
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
110-
- run: cat package.json | jq '.resolutions.webpack = "^5.0.0-beta.30"' > package.json.tmp && mv package.json.tmp package.json
111-
- run: cat package.json | jq '.resolutions.react = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp package.json
112-
- run: cat package.json | jq '.resolutions."react-dom" = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp package.json
110+
- run: cat packages/next/package.json | jq '.resolutions.webpack = "^5.0.0-beta.30"' > package.json.tmp && mv package.json.tmp packages/next/package.json
111+
- run: cat packages/next/package.json | jq '.resolutions.react = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp packages/next/package.json
112+
- run: cat packages/next/package.json | jq '.resolutions."react-dom" = "^17.0.0-rc.1"' > package.json.tmp && mv package.json.tmp packages/next/package.json
113113
- run: yarn install --check-files
114114
- run: node run-tests.js test/integration/production/test/index.test.js
115115
- run: node run-tests.js test/integration/basic/test/index.test.js
116+
- run: node run-tests.js test/integration/async-modules/test/index.test.js
117+
- run: node run-tests.js test/integration/font-optimization/test/index.test.js
116118
- run: node run-tests.js test/acceptance/*
117119

118120
testFirefox:
@@ -184,3 +186,18 @@ jobs:
184186
key: ${{ github.sha }}
185187

186188
- run: ./publish-release.sh
189+
190+
prStats:
191+
name: Release Stats
192+
runs-on: ubuntu-latest
193+
needs: [publishRelease]
194+
steps:
195+
- uses: actions/cache@v2
196+
id: restore-build
197+
with:
198+
path: ./*
199+
key: ${{ github.sha }}
200+
- run: ./release-stats.sh
201+
- uses: ./.github/actions/next-stats-action
202+
env:
203+
PR_STATS_COMMENT_TOKEN: ${{ secrets.PR_STATS_COMMENT_TOKEN }}

.github/workflows/release_stats.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ packages/next-codemod/transforms/__testfixtures__/**/*
1313
packages/next-codemod/transforms/__tests__/**/*
1414
packages/next-codemod/**/*.js
1515
packages/next-codemod/**/*.d.ts
16+
packages/next-env/**/*.d.ts

docs/advanced-features/codemods.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export default withRouter(
132132
)
133133
```
134134

135-
This is just one case. All the cases that are transformed (and tested) can be found in the [`__testfixtures__` directory](./transforms/__testfixtures__/url-to-withrouter).
135+
This is just one case. All the cases that are transformed (and tested) can be found in the [`__testfixtures__` directory](https://github.com/vercel/next.js/tree/canary/packages/next-codemod/transforms/__testfixtures__/url-to-withrouter).
136136

137137
#### Usage
138138

docs/advanced-features/custom-app.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ The `Component` prop is the active `page`, so whenever you navigate between rout
4444

4545
- If your app is running and you just added a custom `App`, you'll need to restart the development server. Only required if `pages/_app.js` didn't exist before.
4646
- Adding a custom `getInitialProps` in your `App` will disable [Automatic Static Optimization](/docs/advanced-features/automatic-static-optimization.md) in pages without [Static Generation](/docs/basic-features/data-fetching.md#getstaticprops-static-generation).
47+
- `App` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching.md) like [`getStaticProps`](/docs/basic-features/data-fetching.md#getstaticprops-static-generation) or [`getServerSideProps`](/docs/basic-features/data-fetching.md#getserversideprops-server-side-rendering).
4748

4849
### TypeScript
4950

docs/advanced-features/custom-document.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,10 @@ The `ctx` object is equivalent to the one received in [`getInitialProps`](/docs/
5151

5252
## Caveats
5353

54-
- `Document` is only rendered in the server, event handlers like `onClick` won't work
55-
- React components outside of `<Main />` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), take a look at the [`App`](/docs/advanced-features/custom-app.md) component instead
56-
- `Document`'s `getInitialProps` function is not called during client-side transitions, nor when a page is [statically optimized](/docs/advanced-features/automatic-static-optimization.md)
54+
- `Document` is only rendered in the server, event handlers like `onClick` won't work.
55+
- React components outside of `<Main />` will not be initialized by the browser. Do _not_ add application logic here or custom CSS (like `styled-jsx`). If you need shared components in all your pages (like a menu or a toolbar), take a look at the [`App`](/docs/advanced-features/custom-app.md) component instead.
56+
- `Document`'s `getInitialProps` function is not called during client-side transitions, nor when a page is [statically optimized](/docs/advanced-features/automatic-static-optimization.md).
57+
- `Document` currently does not support Next.js [Data Fetching methods](/docs/basic-features/data-fetching.md) like [`getStaticProps`](/docs/basic-features/data-fetching.md#getstaticprops-static-generation) or [`getServerSideProps`](/docs/basic-features/data-fetching.md#getserversideprops-server-side-rendering).
5758

5859
## Customizing `renderPage`
5960

docs/advanced-features/preview-mode.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ First, create a **preview API route**. It can have any name - e.g. `pages/api/pr
3939
In this API route, you need to call `setPreviewData` on the response object. The argument for `setPreviewData` should be an object, and this can be used by `getStaticProps` (more on this later). For now, we’ll use `{}`.
4040

4141
```js
42-
export default (req, res) => {
42+
export default function handler(req, res) {
4343
// ...
4444
res.setPreviewData({})
4545
// ...
@@ -54,7 +54,7 @@ You can test this manually by creating an API route like below and accessing it
5454
// A simple example for testing it manually from your browser.
5555
// If this is located at pages/api/preview.js, then
5656
// open /api/preview from your browser.
57-
export default (req, res) => {
57+
export default function handler(req, res) {
5858
res.setPreviewData({})
5959
res.end('Preview mode enabled')
6060
}
@@ -175,7 +175,7 @@ By default, no expiration date is set for the preview mode cookies, so the previ
175175
To clear the preview cookies manually, you can create an API route which calls `clearPreviewData` and then access this API route.
176176

177177
```js
178-
export default (req, res) => {
178+
export default function handler(req, res) {
179179
// Clears the preview mode cookies.
180180
// This function accepts no arguments.
181181
res.clearPreviewData()

docs/api-reference/create-next-app.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ yarn create next-app
1818

1919
- **-e, --example [name]|[github-url]** - An example to bootstrap the app with. You can use an example name from the [Next.js repo](https://github.com/vercel/next.js/tree/master/examples) or a GitHub URL. The URL can use any branch and/or subdirectory.
2020
- **--example-path [path-to-example]** - In a rare case, your GitHub URL might contain a branch name with a slash (e.g. bug/fix-1) and the path to the example (e.g. foo/bar). In this case, you must specify the path to the example separately: `--example-path foo/bar`
21+
- **--use-npm** - Explicitly tell the CLI to bootstrap the app using npm. Yarn will be used by default if it's installed
2122

2223
### Why use Create Next App?
2324

docs/api-reference/next.config.js/environment-variables.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ description: Learn to add and access environment variables in your Next.js appli
1010
<summary><b>Examples</b></summary>
1111
<ul>
1212
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/with-env-from-next-config-js">With env</a></li>
13-
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/with-now-env">With Now env</a></li>
1413
</ul>
1514
</details>
1615

docs/api-reference/next.config.js/exportPathMap.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ description: Customize the pages that will be exported as HTML files when using
1313
</ul>
1414
</details>
1515

16+
`exportPathMap` allows you to specify a mapping of request paths to page destinations, to be used during export.
17+
1618
Let's start with an example, to create a custom `exportPathMap` for an app with the following pages:
1719

1820
- `pages/index.js`

docs/api-reference/next.config.js/rewrites.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Rewrites allow you to map an incoming request path to a different destination pa
1717

1818
Rewrites are only available on the Node.js environment and do not affect client-side routing.
1919

20+
Rewrites are not able to override public files or routes in the pages directory as these have higher priority than rewrites. For example, if you have `pages/index.js` you are not able to rewrite `/` to another location unless you rename the `pages/index.js` file.
21+
2022
To use rewrites you can use the `rewrites` key in `next.config.js`:
2123

2224
```js

docs/api-reference/next/link.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export default Home
145145

146146
## With URL Object
147147

148-
`Link` can also receive an URL object and it will automatically format it to create the URL string. Here's how to do it:
148+
`Link` can also receive a URL object and it will automatically format it to create the URL string. Here's how to do it:
149149

150150
```jsx
151151
import Link from 'next/link'

docs/api-reference/next/router.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export default function Page() {
120120

121121
#### With URL object
122122

123-
You can use an URL object in the same way you can use it for [`next/link`](/docs/api-reference/next/link.md#with-url-object). Works for both the `url` and `as` parameters:
123+
You can use a URL object in the same way you can use it for [`next/link`](/docs/api-reference/next/link.md#with-url-object). Works for both the `url` and `as` parameters:
124124

125125
```jsx
126126
import { useRouter } from 'next/router'

docs/api-routes/dynamic-api-routes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ API routes support [dynamic routes](/docs/routing/dynamic-routes.md), and follow
1616
For example, the API route `pages/api/post/[pid].js` has the following code:
1717

1818
```js
19-
export default (req, res) => {
19+
export default function handler(req, res) {
2020
const {
2121
query: { pid },
2222
} = req
@@ -68,7 +68,7 @@ And in the case of `/api/post/a/b`, and any other matching path, new parameters
6868
An API route for `pages/api/post/[...slug].js` could look like this:
6969

7070
```js
71-
export default (req, res) => {
71+
export default function handler(req, res) {
7272
const {
7373
query: { slug },
7474
} = req

docs/api-routes/introduction.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Any file inside the folder `pages/api` is mapped to `/api/*` and will be treated
2222
For example, the following API route `pages/api/user.js` handles a `json` response:
2323

2424
```js
25-
export default (req, res) => {
25+
export default function handler(req, res) {
2626
res.statusCode = 200
2727
res.setHeader('Content-Type', 'application/json')
2828
res.end(JSON.stringify({ name: 'John Doe' }))
@@ -37,7 +37,7 @@ For an API route to work, you need to export as default a function (a.k.a **requ
3737
To handle different HTTP methods in an API route, you can use `req.method` in your request handler, like so:
3838

3939
```js
40-
export default (req, res) => {
40+
export default function handler(req, res) {
4141
if (req.method === 'POST') {
4242
// Process a POST request
4343
} else {

docs/api-routes/response-helpers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ description: API Routes include a set of Express.js-like methods for the respons
1515
The response (`res`) includes a set of Express.js-like methods to improve the developer experience and increase the speed of creating new API endpoints, take a look at the following example:
1616

1717
```js
18-
export default (req, res) => {
18+
export default function handler(req, res) {
1919
res.status(200).json({ name: 'Next.js' })
2020
}
2121
```

docs/basic-features/built-in-css-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ In production, all CSS files will be automatically concatenated into a single mi
5252

5353
### Import styles from `node_modules`
5454

55-
Importing a CSS file from `node_modules` is permitted in anywhere your application.
55+
Since Next.js **9.5.4**, importing a CSS file from `node_modules` is permitted anywhere in your application.
5656

5757
For global stylesheets, like `bootstrap` or `nprogress`, you should import the file inside `pages/_app.js`.
5858
For example:

docs/basic-features/fast-refresh.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ local state being reset on every edit to a file:
7575
- The file you're editing might have _other_ exports in addition to a React
7676
component.
7777
- Sometimes, a file would export the result of calling higher-order component
78-
like `higherOrderComponent(WrappedComponent)`. If the returned component is a
78+
like `HOC(WrappedComponent)`. If the returned component is a
7979
class, state will be reset.
8080

8181
As more of your codebase moves to function components and Hooks, you can expect

docs/basic-features/static-file-serving.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function MyImage() {
1616
export default MyImage
1717
```
1818

19-
This folder is also useful for `robots.txt`, Google Site Verification, and any other static files (including `.html`)!
19+
This folder is also useful for `robots.txt`, `favicon.ico`, Google Site Verification, and any other static files (including `.html`)!
2020

2121
> **Note**: Don't name the `public` directory anything else. The name cannot be changed and is the only directory used to serve static assets.
2222

docs/basic-features/typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ You're now ready to start converting files from `.js` to `.tsx` and leveraging t
4141

4242
> A file named `next-env.d.ts` will be created in the root of your project. This file ensures Next.js types are picked up by the TypeScript compiler. **You cannot remove it**, however, you can edit it (but you don't need to).
4343
44-
> Next.js `strict` mode is turned off by default. When you feel comfortable with TypeScript, it's recommended to turn it on in your `tsconfig.json`.
44+
> TypeScript `strict` mode is turned off by default. When you feel comfortable with TypeScript, it's recommended to turn it on in your `tsconfig.json`.
4545
4646
By default, Next.js will do type checking as part of `next build`. We recommend using code editor type checking during development.
4747

docs/manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@
187187
"title": "Upgrade Guide",
188188
"path": "/docs/upgrading.md"
189189
},
190+
{
191+
"title": "Migrating to Next.js",
192+
"routes": [
193+
{
194+
"title": "Migrating from Gatsby",
195+
"path": "/docs/migrating/from-gatsby.md"
196+
}
197+
]
198+
},
190199
{ "title": "FAQ", "path": "/docs/faq.md" }
191200
]
192201
},

0 commit comments

Comments
 (0)