Skip to content

Commit

Permalink
Merge branch 'canary' of github.com:vercel/next.js into add/remove-ta…
Browse files Browse the repository at this point in the history
…rget
  • Loading branch information
timneutkens committed Mar 18, 2022
2 parents 300b9ce + f2fee3d commit 1082c26
Show file tree
Hide file tree
Showing 263 changed files with 2,742 additions and 2,228 deletions.
52 changes: 34 additions & 18 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
components: rustfmt, clippy

- name: Cache cargo registry
Expand Down Expand Up @@ -208,12 +208,16 @@ jobs:
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14
node-version: ${{ matrix.node }}

- run: echo ${{needs.build.outputs.docsChange}}

Expand Down Expand Up @@ -258,12 +262,16 @@ jobs:
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14
node-version: ${{ matrix.node }}

- run: echo ${{needs.build.outputs.docsChange}}

Expand Down Expand Up @@ -308,12 +316,16 @@ jobs:
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14
node-version: ${{ matrix.node }}

- run: echo ${{needs.build.outputs.docsChange}}

Expand Down Expand Up @@ -348,12 +360,16 @@ jobs:
env:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
strategy:
fail-fast: false
matrix:
node: [16, 17]
steps:
- name: Setup node
uses: actions/setup-node@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
node-version: 14
node-version: ${{ matrix.node }}

- run: echo ${{needs.build.outputs.docsChange}}

Expand Down Expand Up @@ -732,7 +748,7 @@ jobs:
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23

- name: Cache cargo registry
uses: actions/cache@v2
Expand Down Expand Up @@ -811,7 +827,7 @@ jobs:
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
profile: minimal
- run: cd packages/next-swc && cargo test
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
Expand Down Expand Up @@ -889,8 +905,8 @@ jobs:
# Node.js in Baidu need to compatible with `GLIBC_2.12`
build: >-
set -e &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add x86_64-unknown-linux-gnu &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
Expand All @@ -900,8 +916,8 @@ jobs:
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine
build: >-
set -e &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add x86_64-unknown-linux-musl &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl &&
Expand All @@ -922,8 +938,8 @@ jobs:
docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig
build: >-
set -e &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add aarch64-unknown-linux-gnu &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 &&
Expand Down Expand Up @@ -963,8 +979,8 @@ jobs:
build: >-
set -e &&
npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 &&
rustup toolchain install nightly-2021-11-15 &&
rustup default nightly-2021-11-15 &&
rustup toolchain install nightly-2022-02-23 &&
rustup default nightly-2022-02-23 &&
rustup target add aarch64-unknown-linux-musl &&
turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-musl &&
llvm-strip -x packages/next-swc/native/next-swc.*.node
Expand Down Expand Up @@ -1030,7 +1046,7 @@ jobs:
with:
profile: minimal
override: true
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
target: ${{ matrix.settings.target }}

- name: Cache cargo registry
Expand Down Expand Up @@ -1092,7 +1108,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
override: true
target: wasm32-unknown-unknown

Expand Down Expand Up @@ -1148,7 +1164,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2021-11-15
toolchain: nightly-2022-02-23
override: true
target: wasm32-unknown-unknown

Expand Down
30 changes: 30 additions & 0 deletions docs/advanced-features/compiler.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,36 @@ First, update to the latest version of Next.js: `npm install next@latest`. Then,

## Experimental Features

### Emotion

We're working to port `@emotion/babel-plugin` to the Next.js Compiler.

First, update to the latest version of Next.js: `npm install next@latest`. Then, update your `next.config.js` file:

```js
// next.config.js

module.exports = {
experimental: {
emotion: boolean | {
// default is true. It will be disabled when build type is production.
sourceMap?: boolean,
// default is 'dev-only'.
autoLabel?: 'never' | 'dev-only' | 'always',
// default is '[local]'.
// Allowed values: `[local]` `[filename]` and `[dirname]`
// This option only works when autoLabel is set to 'dev-only' or 'always'.
// It allows you to define the format of the resulting label.
// The format is defined via string where variable parts are enclosed in square brackets [].
// For example labelFormat: "my-classname--[local]", where [local] will be replaced with the name of the variable the result is assigned to.
labelFormat?: string,
},
},
}
```

Only `importMap` in `@emotion/babel-plugin` is not supported for now.

### Minification

You can opt-in to using the Next.js compiler for minification. This is 7x faster than Terser.
Expand Down
2 changes: 2 additions & 0 deletions docs/advanced-features/custom-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ The `Component` prop is the active `page`, so whenever you navigate between rout

`pageProps` is an object with the initial props that were preloaded for your page by one of our [data fetching methods](/docs/basic-features/data-fetching/overview.md), otherwise it's an empty object.

The `App.getInitialProps` receives a single argument called `context.ctx`. It's an object with the same set of properties as the [`context` object](/docs/api-reference/data-fetching/get-initial-props#context-object) in `getInitialProps`.

### Caveats

- If your app is running and you added a custom `App`, you'll need to restart the development server. Only required if `pages/_app.js` didn't exist before.
Expand Down
16 changes: 12 additions & 4 deletions docs/api-reference/next/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,23 @@ When using an external URL, you must add it to

### width

The width of the image, in pixels. Must be an integer without a unit.
The `width` property can represent either the _rendered_ width or _original_ width in pixels, depending on the [`layout`](#layout) and [`sizes`](#sizes) properties.

Required, except for statically imported images, or those with [`layout="fill"`](#layout).
When using `layout="intrinsic"`, `layout="fixed"`, or `layout="raw"` without `sizes`, the `width` property represents the _rendered_ width in pixels, so it will affect how large the image appears.

When using `layout="responsive"`, `layout="fill"`, or `layout="raw"` with `sizes`, the `width` property represents the _original_ width in pixels, so it will only affect the aspect ratio.

The `width` property is required, except for [statically imported images](#local-images), or those with `layout="fill"`.

### height

The height of the image, in pixels. Must be an integer without a unit.
The `height` property can represent either the _rendered_ height or _original_ height in pixels, depending on the [`layout`](#layout) and [`sizes`](#sizes) properties.

When using `layout="intrinsic"`, `layout="fixed"`, or `layout="raw"` without `sizes`, the `height` property represents the _rendered_ height in pixels, so it will affect how large the image appears.

When using `layout="responsive"`, `layout="fill"`, or `layout="raw"` with `sizes`, the `height` property represents the _original_ height in pixels, so it will only affect the aspect ratio.

Required, except for statically imported images, or those with [`layout="fill"`](#layout).
The `height` property is required, except for [statically imported images](#local-images), or those with `layout="fill"`.

## Optional Props

Expand Down
2 changes: 1 addition & 1 deletion docs/basic-features/built-in-css-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ You can use component-level Sass via CSS Modules and the `.module.scss` or `.mod
Before you can use Next.js' built-in Sass support, be sure to install [`sass`](https://github.com/sass/sass):

```bash
npm install sass
npm install --save-dev sass
```

Sass support has the same benefits and restrictions as the built-in CSS support detailed above.
Expand Down
4 changes: 2 additions & 2 deletions docs/basic-features/image-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ One of the ways that images most commonly hurt performance is through _layout sh
Because `next/image` is designed to guarantee good performance results, it cannot be used in a way that will contribute to layout shift, and **must** be sized in one of three ways:

1. Automatically, using a [static import](#local-images)
2. Explicitly, by including a `height` **and** `width` property
3. Implicitly, by using `layout="fill"` which causes the image to expand to fill its parent element.
2. Explicitly, by including a [`width`](/docs/api-reference/next/image.md#width) and [`height`](/docs/api-reference/next/image.md#height) property
3. Implicitly, by using [`layout="fill"`](/docs/api-reference/next/image.md#layout) which causes the image to expand to fill its parent element.

> ### What if I don't know the size of my images?
>
Expand Down
7 changes: 6 additions & 1 deletion docs/going-to-production.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ export async function getServerSideProps({ req, res }) {
}
```

> **Note:** Your deployment provider must support edge caching for dynamic responses. If you are self-hosting, you will need to add this logic to the edge yourself using a key/value store. If you are using Vercel, [edge caching works without configuration](https://vercel.com/docs/edge-network/caching).
By default, `Cache-Control` headers will be set differently depending on how your page fetches data.

- If the page uses `getServerSideProps` or `getInitialProps`, it will use the default `Cache-Control` header set by `next start` in order to prevent accidental caching of responses that cannot be cached. If you want a different cache behavior while using `getServerSideProps`, use `res.setHeader('Cache-Control', 'value_you_prefer')` inside of the function as shown above.
- If the page is using `getStaticProps`, it will have a `Cache-Control` header of `s-maxage=REVALIDATE_SECONDS, stale-while-revalidate`, or if `revalidate` is _not_ used , `s-maxage=31536000, stale-while-revalidate` to cache for the maximum age possible.

> **Note:** Your deployment provider must support caching for dynamic responses. If you are self-hosting, you will need to add this logic yourself using a key/value store like Redis. If you are using Vercel, [Edge Caching works without configuration](https://vercel.com/docs/edge-network/caching).
## Reducing JavaScript Size

Expand Down
8 changes: 1 addition & 7 deletions examples/active-class-name/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@

ReactRouter has a convenience property on the `Link` element to allow an author to set the _active_ className on a link. This example replicates that functionality using Next's own `Link`.

## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/active-class-name)

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/active-class-name)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/active-class-name&project-name=active-class-name&repository-name=active-class-name)

Expand Down
8 changes: 1 addition & 7 deletions examples/analyze-bundles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@

This example shows how to analyze the output bundles using [@next/bundle-analyzer](https://github.com/vercel/next.js/tree/canary/packages/next-bundle-analyzer)

## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/analyze-bundles)

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/analyze-bundles)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/analyze-bundles&project-name=analyze-bundles&repository-name=analyze-bundles)

Expand Down
8 changes: 1 addition & 7 deletions examples/api-routes-apollo-server-and-client-auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

In this simple example, we integrate Apollo seamlessly with [Next.js data fetching methods](https://nextjs.org/docs/basic-features/data-fetching) to fetch queries in the server and hydrate them in the browser.

## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client-auth)

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client-auth)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client-auth&project-name=api-routes-apollo-server-and-client-auth&repository-name=api-routes-apollo-server-and-client-auth)

Expand Down
8 changes: 1 addition & 7 deletions examples/api-routes-apollo-server-and-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@

In this simple example, we integrate Apollo seamlessly with [Next.js data fetching methods](https://nextjs.org/docs/basic-features/data-fetching) to fetch queries in the server and hydrate them in the browser.

## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client)

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/api-routes-apollo-server-and-client&project-name=api-routes-apollo-server-and-client&repository-name=api-routes-apollo-server-and-client)

Expand Down
8 changes: 1 addition & 7 deletions examples/api-routes-apollo-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@

Next.js ships with two forms of pre-rendering: [Static Generation](https://nextjs.org/docs/basic-features/pages#static-generation-recommended) and [Server-side Rendering](https://nextjs.org/docs/basic-features/pages#server-side-rendering). This example shows how to perform Static Generation using a local [Apollo GraphQL](https://www.apollographql.com/docs/apollo-server/) schema within [getStaticProps](https://nextjs.org/docs/basic-features/data-fetching/get-static-props) and [getStaticPaths](https://nextjs.org/docs/basic-features/data-fetching/get-static-paths.md). The end result is a Next.js application that uses one Apollo GraphQL schema to generate static pages at build time and also serve a GraphQL [API Route](https://nextjs.org/docs/api-routes/introduction) at runtime.

## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-apollo-server)

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-apollo-server)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/api-routes-apollo-server&project-name=api-routes-apollo-server&repository-name=api-routes-apollo-server)

Expand Down
8 changes: 1 addition & 7 deletions examples/api-routes-cors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ Next.js ships with [API routes](https://nextjs.org/docs/api-routes/introduction)

This example shows how to create an `API` endpoint with [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) headers, using the [cors](https://github.com/expressjs/cors) package.

## Preview

Preview the example live on [StackBlitz](http://stackblitz.com/):

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-cors)

## Deploy your own

Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example):
Deploy the example using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-example) or preview live with [StackBlitz](https://stackblitz.com/github/vercel/next.js/tree/canary/examples/api-routes-cors)

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https://github.com/vercel/next.js/tree/canary/examples/api-routes-cors&project-name=api-routes-cors&repository-name=api-routes-cors)

Expand Down

0 comments on commit 1082c26

Please sign in to comment.