Skip to content

Commit adb3329

Browse files
committed
Merge remote-tracking branch 'upstream/canary' into bug/#28200
2 parents a5bdcf4 + 877f982 commit adb3329

File tree

235 files changed

+79460
-75443
lines changed

Some content is hidden

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

235 files changed

+79460
-75443
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ examples/with-typescript-eslint-jest/**
88
examples/with-kea/**
99
examples/with-custom-babel-config/**
1010
examples/with-flow/**
11+
examples/with-jest/**
1112
examples/with-mobx-state-tree/**
1213
examples/with-mobx/**
1314
packages/next/bundles/webpack/packages/*.runtime.js

.github/workflows/build_test_deploy.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ jobs:
8686
./packages/next/native/next-swc.linux-x64-gnu.node
8787
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
8888
- run: ./scripts/check-pre-compiled.sh
89-
env:
90-
NODE_OPTIONS: '--max_old_space_size=4096'
9189
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
9290

9391
testUnit:
@@ -106,7 +104,7 @@ jobs:
106104
path: ./*
107105
key: ${{ github.sha }}
108106

109-
- run: node run-tests.js --timings --type unit -g 1/1
107+
- run: node run-tests.js --type unit
110108
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
111109

112110
testIntegration:

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ stages:
111111
path: $(System.DefaultWorkingDirectory)
112112
displayName: Cache Build
113113
- script: |
114-
node run-tests.js -g 1/1 --timings --azure --type unit
114+
node run-tests.js --type unit
115115
displayName: 'Run tests'
116116
# TODO: investigate re-enabling when stability matches running in
117117
# tests in ubuntu environment

data.sqlite

Whitespace-only changes.

docs/advanced-features/i18n-routing.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,30 @@ Next.js doesn't know about variants of a page so it's up to you to add the `href
234234

235235
> Note that Internationalized Routing does not integrate with [`next export`](/docs/advanced-features/static-html-export.md) as `next export` does not leverage the Next.js routing layer. Hybrid Next.js applications that do not use `next export` are fully supported.
236236
237+
### Dynamic Routes and `getStaticProps` Pages
238+
239+
For pages using `getStaticProps` with [Dynamic Routes](/docs/routing/dynamic-routes.md), all locale variants of the page desired to be prerendered need to be returned from [`getStaticPaths`](/docs/basic-features/data-fetching.md#getstaticpaths-static-generation). Along with the `params` object returned for `paths`, you can also return a `locale` field specifying which locale you want to render. For example:
240+
241+
```js
242+
// pages/blog/[slug].js
243+
export const getStaticPaths = ({ locales }) => {
244+
return {
245+
paths: [
246+
// if no `locale` is provided only the defaultLocale will be generated
247+
{ params: { slug: 'post-1' }, locale: 'en-US' },
248+
{ params: { slug: 'post-1' }, locale: 'fr' },
249+
],
250+
fallback: true,
251+
}
252+
}
253+
```
254+
255+
For [Automatically Statically Optimized](/docs/advanced-features/automatic-static-optimization.md) and non-dynamic `getStaticProps` pages, **a version of the page will be generated for each locale**. This is important to consider because it can increase build times depending on how many locales are configured inside `getStaticProps`.
256+
257+
For example, if you have 50 locales configured with 10 non-dynamic pages using `getStaticProps`, this means `getStaticProps` will be called 500 times. 50 versions of the 10 pages will be generated during each build.
258+
259+
To decrease the build time of dynamic pages with `getStaticProps`, use a [`fallback` mode](https://nextjs.org/docs/basic-features/data-fetching#fallback-true). This allows you to return only the most popular paths and locales from `getStaticPaths` for prerendering during the build. Then, Next.js will build the remaining pages at runtime as they are requested.
260+
237261
### Automatically Statically Optimized Pages
238262

239263
For pages that are [automatically statically optimized](/docs/advanced-features/automatic-static-optimization.md), a version of the page will be generated for each locale.
@@ -265,24 +289,9 @@ export async function getStaticProps({ locale }) {
265289
}
266290
```
267291

268-
### Dynamic getStaticProps Pages
269-
270-
For dynamic `getStaticProps` pages, any locale variants of the page that is desired to be prerendered needs to be returned from [`getStaticPaths`](/docs/basic-features/data-fetching.md#getstaticpaths-static-generation). Along with the `params` object that can be returned for the `paths`, you can also return a `locale` field specifying which locale you want to render. For example:
271-
272-
```js
273-
// pages/blog/[slug].js
274-
export const getStaticPaths = ({ locales }) => {
275-
return {
276-
paths: [
277-
{ params: { slug: 'post-1' }, locale: 'en-US' },
278-
{ params: { slug: 'post-1' }, locale: 'fr' },
279-
],
280-
fallback: true,
281-
}
282-
}
283-
```
284-
285292
## Limits for the i18n config
286293

287294
- `locales`: 100 total locales
288295
- `domains`: 100 total locale domain items
296+
297+
> **Note:** These limits have been added initially to prevent potential [performance issues at build time](#dynamic-routes-and-getStaticProps-pages). We are continuing to evaluate if these limits are sufficient.

docs/api-reference/next/image.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -90,29 +90,26 @@ The `<Image />` component optionally accepts the following properties.
9090

9191
### layout
9292

93-
The layout behavior of the image as the viewport changes size. Defaults to
94-
`intrinsic`.
93+
The layout behavior of the image as the viewport changes size.
9594

96-
When `fixed`, the image dimensions will not change as the viewport changes (no
97-
responsiveness) similar to the native `img` element.
98-
99-
When `intrinsic`, the image will scale the dimensions down for smaller viewports
100-
but maintain the original dimensions for larger viewports.
101-
102-
When `responsive`, the image will scale the dimensions down for smaller
103-
viewports and scale up for larger viewports.
104-
Note: the responsive layout may not work correctly if the parent element uses a display value other than `block` such as `display: flex` or `display: grid`.
105-
106-
When `fill`, the image will stretch both width and height to the dimensions of
107-
the parent element, provided the parent element is relative. This is usually paired with the [`objectFit`](#objectFit) property.
108-
Ensure the parent element has `position: relative` in their stylesheet.
109-
110-
Try it out:
95+
| `layout` | Behavior | `srcSet` | `sizes` |
96+
| --------------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
97+
| `intrinsic` (default) | Scale *down* to fit width of container, up to image size | `1x``2x` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes)) | N/A |
98+
| `fixed` | Sized to `width` and `height` exactly | `1x``2x` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes)) | N/A |
99+
| `responsive` | Scale to fit width of container | `640w``750w`, ... `2048w``3840w` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes) and [deviceSizes](/docs/basic-features/image-optimization.md#device-sizes)) | `100vw` |
100+
| `fill` | Grow in X and Y axes to fill container | `640w``750w`, ... `2048w``3840w` (based on [imageSizes](/docs/basic-features/image-optimization.md#image-sizes) and [deviceSizes](/docs/basic-features/image-optimization.md#device-sizes)) | `100vw` |
111101

102+
- [Demo the `intrinsic` layout (default)](https://image-component.nextjs.gallery/layout-intrinsic)
103+
- When `intrinsic`, the image will scale the dimensions down for smaller viewports, but maintain the original dimensions for larger viewports.
112104
- [Demo the `fixed` layout](https://image-component.nextjs.gallery/layout-fixed)
113-
- [Demo the `intrinsic` layout](https://image-component.nextjs.gallery/layout-intrinsic)
105+
- When `fixed`, the image dimensions will not change as the viewport changes (no responsiveness) similar to the native `img` element.
114106
- [Demo the `responsive` layout](https://image-component.nextjs.gallery/layout-responsive)
107+
- When `responsive`, the image will scale the dimensions down for smaller viewports and scale up for larger viewports.
108+
- Ensure the parent element uses `display: block` in their stylesheet.
115109
- [Demo the `fill` layout](https://image-component.nextjs.gallery/layout-fill)
110+
- When `fill`, the image will stretch both width and height to the dimensions of the parent element, provided the parent element is relative.
111+
- This is usually paired with the [`objectFit`](#objectFit) property.
112+
- Ensure the parent element has `position: relative` in their stylesheet.
116113
- [Demo background image](https://image-component.nextjs.gallery/background)
117114

118115
### loader

docs/api-routes/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ For new projects, you can build your entire API with API Routes. If you have an
5555

5656
## Caveats
5757

58-
- API Routes [do not specify CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), meaning they are **same-origin only** by default. You can customize such behavior by wrapping the request handler with the [cors middleware](/docs/api-routes/api-middlewares.md#connectexpress-middleware-support).
58+
- API Routes [do not specify CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), meaning they are **same-origin only** by default. You can customize such behavior by wrapping the request handler with the [CORS middleware](/docs/api-routes/api-middlewares.md#connectexpress-middleware-support).
5959
- API Routes can't be used with [`next export`](/docs/advanced-features/static-html-export.md)
6060

6161
## Related

docs/basic-features/eslint.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Next.js provides an ESLint plugin, [`eslint-plugin-next`](https://www.npmjs.com/
9494
| ✔️ | [next/no-sync-scripts](https://nextjs.org/docs/messages/no-sync-scripts) | Forbid synchronous scripts |
9595
| ✔️ | [next/no-title-in-document-head](https://nextjs.org/docs/messages/no-title-in-document-head) | Disallow using &lt;title&gt; with Head from next/document |
9696
| ✔️ | [next/no-unwanted-polyfillio](https://nextjs.org/docs/messages/no-unwanted-polyfillio) | Prevent duplicate polyfills from Polyfill.io |
97+
| ✔️ | [next/inline-script-id](https://nextjs.org/docs/messages/inline-script-id) | Enforce id attribute on next/script components with inline content |
9798
| ✔️ | next/no-typos | Ensure no typos were made declaring [Next.js's data fetching function](https://nextjs.org/docs/basic-features/data-fetching) |
9899
| ✔️ | [next/next-script-for-ga](https://nextjs.org/docs/messages/next-script-for-ga) | Use the Script component to defer loading of the script until necessary. |
99100

@@ -138,6 +139,14 @@ Similarly, the `--dir` flag can be used for `next lint`:
138139
next lint --dir pages --dir utils
139140
```
140141

142+
## Caching
143+
144+
To improve performance, information of files processed by ESLint are cached by default. This is stored in `.next/cache` or in your defined [build directory](/docs/api-reference/next.config.js/setting-a-custom-build-directory). If you include any ESLint rules that depend on more than the contents of a single source file and need to disable the cache, use the `--no-cache` flag with `next lint`.
145+
146+
```bash
147+
next lint --no-cache
148+
```
149+
141150
## Disabling Rules
142151

143152
If you would like to modify or disable any rules provided by the supported plugins (`react`, `react-hooks`, `next`), you can directly change them using the `rules` property in your `.eslintrc`:

docs/basic-features/font-optimization.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function IndexPage() {
3535
<div>
3636
<Head>
3737
<link
38-
href="https://fonts.googleapis.com/css2?family=Inter"
38+
href="https://fonts.googleapis.com/css2?family=Inter&display=optional"
3939
rel="stylesheet"
4040
/>
4141
</Head>
@@ -58,7 +58,7 @@ class MyDocument extends Document {
5858
<Html>
5959
<Head>
6060
<link
61-
href="https://fonts.googleapis.com/css2?family=Inter"
61+
href="https://fonts.googleapis.com/css2?family=Inter&display=optional"
6262
rel="stylesheet"
6363
/>
6464
</Head>
@@ -76,6 +76,8 @@ export default MyDocument
7676
7777
Automatic Webfont Optimization currently supports Google Fonts and Typekit with support for other font providers coming soon. We're also planning to add control over [loading strategies](https://github.com/vercel/next.js/issues/21555) and `font-display` values.
7878
79+
See [Google Font Display](https://nextjs.org/docs/messages/google-font-display) for more information.
80+
7981
## Disabling Optimization
8082
8183
If you do not want Next.js to optimize your fonts, you can opt-out.

docs/basic-features/image-optimization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ If you need a different provider, you can use the [`loader`](/docs/api-reference
128128

129129
> The `next/image` component's default loader is not supported when using [`next export`](/docs/advanced-features/static-html-export.md). However, other loader options will work.
130130
131-
> The `next/image` component's default loader uses the ['squoosh'](https://www.npmjs.com/package/@squoosh/lib) library for image resizing and optimization. This library is quick to install and suitable for a dev server environment. For a production environment, it is strongly recommended that you install the optional [`sharp`](https://www.npmjs.com/package/sharp) library by running `yarn add sharp` in your project directory. If sharp is already installed but can't be resolved you can manually pass the path to it via the `NEXT_SHARP_PATH` environment variable e.g. `NEXT_SHARP_PATH=/tmp/node_modules/sharp`
131+
> The `next/image` component's default loader uses [`squoosh`](https://www.npmjs.com/package/@squoosh/lib) because it is quick to install and suitable for a development environment. When using `next start` in your production environment, it is strongly recommended that you install [`sharp`](https://www.npmjs.com/package/sharp) by running `yarn add sharp` in your project directory. This is not necessary for Vercel deployments, as `sharp` is installed automatically.
132132
133133
## Caching
134134

0 commit comments

Comments
 (0)