Skip to content

Commit

Permalink
Merge branch 'canary' of github.com:vercel/next.js into update/accept
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/next/package.json
  • Loading branch information
timneutkens committed May 16, 2021
2 parents f9b22e0 + 68ecbdd commit b704d37
Show file tree
Hide file tree
Showing 479 changed files with 95,904 additions and 88,240 deletions.
5 changes: 4 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ node_modules
**/.next/**
**/_next/**
**/dist/**
e2e-tests/**
examples/with-eslint/**
examples/with-typescript-eslint-jest/**
examples/with-kea/**
packages/next/bundles/webpack/packages/*.runtime.js
Expand All @@ -15,6 +17,7 @@ packages/next-codemod/transforms/__tests__/**/*
packages/next-codemod/**/*.js
packages/next-codemod/**/*.d.ts
packages/next-env/**/*.d.ts
packages/create-next-app/templates/**
test/integration/async-modules/**
test/integration/eslint/**
test-timings.json
packages/next/lib/regexr/**/*
5 changes: 4 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"extends": ["plugin:jest/recommended"],
"rules": {
"jest/expect-expect": "off",
"jest/no-disabled-tests": "off"
"jest/no-disabled-tests": "off",
"jest/no-conditional-expect": "off",
"jest/valid-title": "off",
"jest/no-interpolation-in-snapshots": "off"
}
},
{ "files": ["**/__tests__/**"], "env": { "jest": true } },
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/1.bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Bug Report
description: Create a bug report for the Next.js core
title: 'Bug Report'
labels: 'template: bug'
body:
- type: markdown
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/2.example_bug_report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Example Bug Report
description: Create a bug report for the examples
title: 'Example Bug Report'
labels: 'type: example,template: bug'
body:
- type: markdown
Expand Down
1 change: 0 additions & 1 deletion .github/ISSUE_TEMPLATE/3.feature_request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Feature Request
description: Create a feature request for the Next.js core
title: 'Feature Request'
labels: 'template: story'
body:
- type: markdown
Expand Down
8 changes: 8 additions & 0 deletions .github/labeler.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@
"packages/react-dev-overlay/**",
"packages/react-refresh-utils/**",
"packages/next-codemod/**"
],
"type: chrome": [
{ "type": "user", "pattern": "spanicker" },
{ "type": "user", "pattern": "housseindjirdeh" },
{ "type": "user", "pattern": "devknoll" },
{ "type": "user", "pattern": "janicklas-ralph" },
{ "type": "user", "pattern": "atcastle" },
{ "type": "user", "pattern": "Joonpark13" }
]
}
}
2 changes: 1 addition & 1 deletion .github/workflows/test_react_experimental.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
# needs: build
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_PRIVATE_REACT_MODE: concurrent
HEADLESS: true
NEXT_PRIVATE_SKIP_SIZE_TESTS: true
NEXT_PRIVATE_REACT_ROOT: 1
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pr:
variables:
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn
NEXT_TELEMETRY_DISABLED: '1'
node_version: ^10.10.0
node_version: ^12.0.0

stages:
- stage: Build
Expand Down
Empty file added data.sqlite
Empty file.
2 changes: 1 addition & 1 deletion docs/api-reference/create-next-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ yarn create next-app

- **-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.
- **--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`
- **--use-npm** - Explicitly tell the CLI to bootstrap the app using npm. Yarn will be used by default if it's installed
- **--use-npm** - Explicitly tell the CLI to bootstrap the app using npm. To bootstrap using yarn we recommend to run `yarn create next-app`

### Why use Create Next App?

Expand Down
9 changes: 8 additions & 1 deletion docs/api-reference/next.config.js/basepath.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ description: Learn more about setting a base path in Next.js

# Base Path

> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<details>
<summary><b>Version History</b></summary>

| Version | Changes |
| -------- | ---------------- |
| `v9.5.0` | Base Path added. |

</details>

To deploy a Next.js application under a sub-path of a domain you can use the `basePath` config option.

Expand Down
1 change: 0 additions & 1 deletion docs/api-reference/next.config.js/custom-webpack-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Before continuing to add custom webpack configuration to your application make s

Some commonly asked for features are available as plugins:

- [@zeit/next-less](https://github.com/vercel/next-plugins/tree/master/packages/next-less)
- [@next/mdx](https://github.com/vercel/next.js/tree/canary/packages/next-mdx)
- [@next/bundle-analyzer](https://github.com/vercel/next.js/tree/canary/packages/next-bundle-analyzer)

Expand Down
14 changes: 10 additions & 4 deletions docs/api-reference/next.config.js/headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ description: Add custom HTTP headers to your Next.js app.

# Headers

> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<details open>
<summary><b>Examples</b></summary>
<ul>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/headers">Headers</a></li>
</ul>
</details>

<details>
<summary><b>Version History</b></summary>

| Version | Changes |
| --------- | -------------- |
| `v10.2.0` | `has` added. |
| `v9.5.0` | Headers added. |

</details>

Headers allow you to set custom HTTP headers for an incoming request path.

To set custom HTTP headers you can use the `headers` key in `next.config.js`:
Expand Down Expand Up @@ -173,8 +181,6 @@ module.exports = {

## Header, Cookie, and Query Matching

Note: this feature is still experimental and not covered by semver and is to be used at your own risk until it is made stable.

To only apply a header when either header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the header to be applied.

`has` items have the following fields:
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/next.config.js/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = (phase, { defaultConfig }) => {
}
```

The commented lines are the place where you can put the configs allowed by `next.config.js`, which are defined [here](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config-shared.ts#L33).
The commented lines are the place where you can put the configs allowed by `next.config.js`, which are defined [here](https://github.com/vercel/next.js/blob/canary/packages/next/next-server/server/config-shared.ts#L68).

However, none of the configs are required, and it's not necessary to understand what each config does. Instead, search for the features you need to enable or modify in this section and they will show you what to do.

Expand Down
22 changes: 14 additions & 8 deletions docs/api-reference/next.config.js/redirects.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,23 @@ description: Add redirects to your Next.js app.

# Redirects

> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<details open>
<summary><b>Examples</b></summary>
<ul>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/redirects">Redirects</a></li>
</ul>
</details>

<details>
<summary><b>Version History</b></summary>

| Version | Changes |
| --------- | ---------------- |
| `v10.2.0` | `has` added. |
| `v9.5.0` | Redirects added. |

</details>

Redirects allow you to redirect an incoming request path to a different destination path.

Redirects are only available on the Node.js environment and do not affect client-side routing.
Expand Down Expand Up @@ -117,8 +125,6 @@ module.exports = {

## Header, Cookie, and Query Matching

Note: this feature is still experimental and not covered by semver and is to be used at your own risk until it is made stable.

To only match a redirect when header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the redirect to be applied.

`has` items have the following fields:
Expand All @@ -134,7 +140,7 @@ module.exports = {
// if the header `x-redirect-me` is present,
// this redirect will be applied
{
source: '/:path*',
source: '/:path((?!another-page$).*)',
has: [
{
type: 'header',
Expand Down Expand Up @@ -164,12 +170,12 @@ module.exports = {
},
],
permanent: false,
destination: '/:path*/:page',
destination: '/another/:path*',
},
// if the header `x-authorized` is present and
// contains a matching value, this redirect will be applied
{
source: '/:path*',
source: '/',
has: [
{
type: 'header',
Expand All @@ -183,7 +189,7 @@ module.exports = {
// if the host is `example.com`,
// this redirect will be applied
{
source: '/:path*',
source: '/:path((?!another-page$).*)',,
has: [
{
type: 'host',
Expand Down
24 changes: 16 additions & 8 deletions docs/api-reference/next.config.js/rewrites.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@ description: Add rewrites to your Next.js app.

# Rewrites

> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<details open>
<summary><b>Examples</b></summary>
<ul>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/rewrites">Rewrites</a></li>
</ul>
</details>

<details>
<summary><b>Version History</b></summary>

| Version | Changes |
| --------- | --------------- |
| `v10.2.0` | `has` added. |
| `v9.5.0` | Rewrites added. |

</details>

Rewrites allow you to map an incoming request path to a different destination path.

Rewrites are only available on the Node.js environment and do not affect client-side routing.
Rewrites act as a URL proxy and mask the destination path, making it appear the user hasn't changed their location on the site. In contrast, [redirects](/docs/api-reference/next.config.js/redirects.md) will reroute to a new page a show the URL changes.

To use rewrites you can use the `rewrites` key in `next.config.js`:

Expand All @@ -32,6 +40,8 @@ module.exports = {
}
```

Rewrites are applied to client-side routing, a `<Link href="/about">` will have the rewrite applied in the above example.

`rewrites` is an async function that expects an array to be returned holding objects with `source` and `destination` properties:

- `source`: `String` - is the incoming request path pattern.
Expand All @@ -48,8 +58,8 @@ module.exports = {
return {
beforeFiles: [
// These rewrites are checked after headers/redirects
// and before pages/public files which allows overriding
// page files
// and before all files including _next/public files which
// allows overriding page files
{
source: '/some-page',
destination: '/somewhere-else',
Expand Down Expand Up @@ -197,8 +207,6 @@ module.exports = {

## Header, Cookie, and Query Matching

Note: this feature is still experimental and not covered by semver and is to be used at your own risk until it is made stable.

To only match a rewrite when header, cookie, or query values also match the `has` field can be used. Both the `source` and all `has` items must match for the rewrite to be applied.

`has` items have the following fields:
Expand Down Expand Up @@ -319,7 +327,7 @@ module.exports = {
}
```

See additional information on incremental adoption [in the docs here](https://nextjs.org/docs/migrating/incremental-adoption).
See additional information on incremental adoption [in the docs here](/docs/migrating/incremental-adoption.md).

### Rewrites with basePath support

Expand Down
9 changes: 8 additions & 1 deletion docs/api-reference/next.config.js/trailing-slash.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ description: Configure Next.js pages to resolve with or without a trailing slash

# Trailing Slash

> This feature was introduced in [Next.js 9.5](https://nextjs.org/blog/next-9-5) and up. If you’re using older versions of Next.js, please upgrade before trying it out.
<details>
<summary><b>Version History</b></summary>

| Version | Changes |
| -------- | --------------------- |
| `v9.5.0` | Trailing Slash added. |

</details>

By default Next.js will redirect urls with trailing slashes to their counterpart without a trailing slash. For example `/about/` will redirect to `/about`. You can configure this behavior to act the opposite way, where urls without trailing slashes are redirected to their counterparts with trailing slashes.

Expand Down
3 changes: 2 additions & 1 deletion docs/api-reference/next/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default ActiveLink

The following is the definition of the `router` object returned by both [`useRouter`](#useRouter) and [`withRouter`](#withRouter):

- `pathname`: `String` - Current route. That is the path of the page in `/pages`
- `pathname`: `String` - Current route. That is the path of the page in `/pages`, the configured `basePath` or `locale` is not included.
- `query`: `Object` - The query string parsed to an object. It will be an empty object during prerendering if the page doesn't have [data fetching requirements](/docs/basic-features/data-fetching.md). Defaults to `{}`
- `asPath`: `String` - The path (including the query) shown in the browser without the configured `basePath` or `locale`.
- `isFallback`: `boolean` - Whether the current page is in [fallback mode](/docs/basic-features/data-fetching.md#fallback-pages).
Expand Down Expand Up @@ -74,6 +74,7 @@ router.push(url, as, options)
- `options` - Optional object with the following configuration options:
- `scroll` - Optional boolean, controls scrolling to the top of the page after navigation. Defaults to `true`
- [`shallow`](/docs/routing/shallow-routing.md): Update the path of the current page without rerunning [`getStaticProps`](/docs/basic-features/data-fetching.md#getstaticprops-static-generation), [`getServerSideProps`](/docs/basic-features/data-fetching.md#getserversideprops-server-side-rendering) or [`getInitialProps`](/docs/api-reference/data-fetching/getInitialProps.md). Defaults to `false`
- `locale` - Optional string, indicates locale of the new page

> You don't need to use `router.push` for external URLs. [window.location](https://developer.mozilla.org/en-US/docs/Web/API/Window/location) is better suited for those cases.
Expand Down
2 changes: 1 addition & 1 deletion docs/api-routes/response-helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function handler(req, res) {
The included helpers are:

- `res.status(code)` - A function to set the status code. `code` must be a valid [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes)
- `res.json(json)` - Sends a JSON response. `json` must be a valid JSON object
- `res.json(body)` - Sends a JSON response. `body` must be a [serialiazable object](https://developer.mozilla.org/en-US/docs/Glossary/Serialization)
- `res.send(body)` - Sends the HTTP response. `body` can be a `string`, an `object` or a `Buffer`
- `res.redirect([status,] path)` - Redirects to a specified path or URL. `status` must be a valid [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes). If not specified, `status` defaults to "307" "Temporary redirect".

Expand Down
13 changes: 0 additions & 13 deletions docs/basic-features/built-in-css-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,6 @@ module.exports = {
}
```

## Less and Stylus Support

To support importing `.less` or `.styl` files you can use the following plugins:

- [@zeit/next-less](https://github.com/vercel/next-plugins/tree/master/packages/next-less)
- [@zeit/next-stylus](https://github.com/vercel/next-plugins/tree/master/packages/next-stylus)

If using the less plugin, don't forget to add a dependency on less as well, otherwise you'll see an error like:

```bash
Error: Cannot find module 'less'
```

## CSS-in-JS

<details>
Expand Down
Loading

0 comments on commit b704d37

Please sign in to comment.