Skip to content

Commit

Permalink
Merge branch 'canary' into feat-next-binding
Browse files Browse the repository at this point in the history
  • Loading branch information
padmaia committed Dec 14, 2022
2 parents a03ad94 + d5fd2d7 commit cd9f9e9
Show file tree
Hide file tree
Showing 30 changed files with 196 additions and 373 deletions.
2 changes: 1 addition & 1 deletion docs/advanced-features/customizing-postcss-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ To customize browserslist, create a `browserslist` key in your `package.json` li

```json
{
"browserslist": [">0.3%", "not ie 11", "not dead", "not op_mini all"]
"browserslist": [">0.3%", "not dead", "not op_mini all"]
}
```

Expand Down
22 changes: 20 additions & 2 deletions docs/api-reference/next.config.js/headers.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ module.exports = {
- `basePath`: `false` or `undefined` - if false the basePath won't be included when matching, can be used for external rewrites only.
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
- `missing` is an array of [missing objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.

Headers are checked before the filesystem which includes pages and `/public` files.

Expand Down Expand Up @@ -185,9 +186,9 @@ module.exports = {

## Header, Cookie, and Query Matching

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.
To only apply a header when header, cookie, or query values also match the `has` field or don't match the `missing` field can be used. Both the `source` and all `has` items must match and all `missing` items must not match for the header to be applied.

`has` items have the following fields:
`has` and `missing` items can have the following fields:

- `type`: `String` - must be either `header`, `cookie`, `host`, or `query`.
- `key`: `String` - the key from the selected type to match against.
Expand All @@ -214,6 +215,23 @@ module.exports = {
},
],
},
// if the header `x-no-header` is not present,
// the `x-another-header` header will be applied
{
source: '/:path*',
missing: [
{
type: 'header',
key: 'x-no-header',
},
],
headers: [
{
key: 'x-another-header',
value: 'hello',
},
],
},
// if the source, query, and cookie are matched,
// the `x-authorized` header will be applied
{
Expand Down
18 changes: 16 additions & 2 deletions docs/api-reference/next.config.js/redirects.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = {
- `basePath`: `false` or `undefined` - if false the `basePath` won't be included when matching, can be used for external redirects only.
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
- `missing` is an array of [missing objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.

Redirects are checked before the filesystem which includes pages and `/public` files.

Expand Down Expand Up @@ -140,9 +141,9 @@ module.exports = {

## Header, Cookie, and Query Matching

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.
To only match a redirect when header, cookie, or query values also match the `has` field or don't match the `missing` field can be used. Both the `source` and all `has` items must match and all `missing` items must not match for the redirect to be applied.

`has` items have the following fields:
`has` and `missing` items can have the following fields:

- `type`: `String` - must be either `header`, `cookie`, `host`, or `query`.
- `key`: `String` - the key from the selected type to match against.
Expand All @@ -165,6 +166,19 @@ module.exports = {
permanent: false,
destination: '/another-page',
},
// if the header `x-dont-redirect` is present,
// this redirect will be applied
{
source: '/:path((?!another-page$).*)',
missing: [
{
type: 'header',
key: 'x-do-not-redirect',
},
],
permanent: false,
destination: '/another-page',
},
// if the source, query, and cookie are matched,
// this redirect will be applied
{
Expand Down
26 changes: 20 additions & 6 deletions docs/api-reference/next.config.js/rewrites.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ description: Add rewrites to your Next.js app.
<details>
<summary><b>Version History</b></summary>

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

</details>

Expand Down Expand Up @@ -49,6 +50,7 @@ Rewrites are applied to client-side routing, a `<Link href="/about">` will have
- `basePath`: `false` or `undefined` - if false the basePath won't be included when matching, can be used for external rewrites only.
- `locale`: `false` or `undefined` - whether the locale should not be included when matching.
- `has` is an array of [has objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.
- `missing` is an array of [missing objects](#header-cookie-and-query-matching) with the `type`, `key` and `value` properties.

When the `rewrites` function returns an array, rewrites are applied after checking the filesystem (pages and `/public` files) and before dynamic routes. When the `rewrites` function returns an object of arrays with a specific shape, this behavior can be changed and more finely controlled, as of `v10.1` of Next.js:

Expand Down Expand Up @@ -219,9 +221,9 @@ module.exports = {

## Header, Cookie, and Query Matching

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.
To only match a rewrite when header, cookie, or query values also match the `has` field or don't match the `missing` field can be used. Both the `source` and all `has` items must match and all `missing` items must not match for the rewrite to be applied.

`has` items have the following fields:
`has` and `missing` items can have the following fields:

- `type`: `String` - must be either `header`, `cookie`, `host`, or `query`.
- `key`: `String` - the key from the selected type to match against.
Expand All @@ -243,6 +245,18 @@ module.exports = {
],
destination: '/another-page',
},
// if the header `x-rewrite-me` is not present,
// this rewrite will be applied
{
source: '/:path*',
missing: [
{
type: 'header',
key: 'x-rewrite-me',
},
],
destination: '/another-page',
},
// if the source, query, and cookie are matched,
// this rewrite will be applied
{
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/next/legacy/image.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ description: Backwards compatible Image Optimization with the Legacy Image compo

</details>

Starting with Next.js 13, the `next/image` component was rewritten to improves both the performance and developer experience. In order to provide a backwards compatible upgrade solution, the old `next/image` was renamed to `next/legacy/image`.
Starting with Next.js 13, the `next/image` component was rewritten to improve both the performance and developer experience. In order to provide a backwards compatible upgrade solution, the old `next/image` was renamed to `next/legacy/image`.

## Comparison

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "13.0.7-canary.5"
"version": "13.0.7-canary.6"
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
Expand All @@ -9,7 +9,7 @@
"directory": "packages/eslint-config-next"
},
"dependencies": {
"@next/eslint-plugin-next": "13.0.7-canary.5",
"@next/eslint-plugin-next": "13.0.7-canary.6",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.42.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"description": "ESLint plugin for NextJS.",
"main": "dist/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/font/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/font",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"repository": {
"url": "vercel/next.js",
"directory": "packages/font"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"main": "index.js",
"types": "index.d.ts",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-swc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/swc",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"private": true,
"scripts": {
"build-native": "napi build --platform -p next-swc-napi --cargo-name next_swc_napi --features plugin --js false native",
Expand Down
14 changes: 8 additions & 6 deletions packages/next/client/components/layout-router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import type {
} from '../../server/app-render'
import type { ErrorComponent } from './error-boundary'
import type { FocusAndScrollRef } from './reducer'
import type { ChildProp } from '../../server/app-render'

import React, { useContext, useEffect, use } from 'react'
import { findDOMNode as ReactDOMfindDOMNode } from 'react-dom'
import type { ChildProp } from '../../server/app-render'
import ReactDOM from 'react-dom'
import {
CacheStates,
LayoutRouterContext,
Expand Down Expand Up @@ -80,8 +80,10 @@ function walkAddRefetch(
* Wraps ReactDOM.findDOMNode with additional logic to hide React Strict Mode warning
*/
function findDOMNode(
instance: Parameters<typeof ReactDOMfindDOMNode>[0]
): ReturnType<typeof ReactDOMfindDOMNode> {
instance: Parameters<typeof ReactDOM.findDOMNode>[0]
): ReturnType<typeof ReactDOM.findDOMNode> {
// Tree-shake for server bundle
if (typeof window === undefined) return null
// Only apply strict mode warning when not in production
if (process.env.NODE_ENV !== 'production') {
const originalConsoleError = console.error
Expand All @@ -92,12 +94,12 @@ function findDOMNode(
originalConsoleError(...messages)
}
}
return ReactDOMfindDOMNode(instance)
return ReactDOM.findDOMNode(instance)
} finally {
console.error = originalConsoleError!
}
}
return ReactDOMfindDOMNode(instance)
return ReactDOM.findDOMNode(instance)
}

/**
Expand Down
18 changes: 9 additions & 9 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "13.0.7-canary.5",
"version": "13.0.7-canary.6",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -71,11 +71,12 @@
"taskr": {
"requires": [
"./taskfile-ncc.js",
"./taskfile-swc.js"
"./taskfile-swc.js",
"./taskfile-watch.js"
]
},
"dependencies": {
"@next/env": "13.0.7-canary.5",
"@next/env": "13.0.7-canary.6",
"@swc/helpers": "0.4.14",
"caniuse-lite": "^1.0.30001406",
"postcss": "8.4.14",
Expand Down Expand Up @@ -125,15 +126,14 @@
"@hapi/accept": "5.0.2",
"@napi-rs/cli": "2.12.0",
"@napi-rs/triples": "1.1.0",
"@next/polyfill-module": "13.0.7-canary.5",
"@next/polyfill-nomodule": "13.0.7-canary.5",
"@next/react-dev-overlay": "13.0.7-canary.5",
"@next/react-refresh-utils": "13.0.7-canary.5",
"@next/swc": "13.0.7-canary.5",
"@next/polyfill-module": "13.0.7-canary.6",
"@next/polyfill-nomodule": "13.0.7-canary.6",
"@next/react-dev-overlay": "13.0.7-canary.6",
"@next/react-refresh-utils": "13.0.7-canary.6",
"@next/swc": "13.0.7-canary.6",
"@segment/ajv-human-errors": "2.1.2",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
"@types/amphtml-validator": "1.0.0",
"@types/babel__code-frame": "7.0.2",
"@types/babel__core": "7.1.12",
Expand Down
1 change: 0 additions & 1 deletion packages/next/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ const configSchema = {
type: 'string',
},
port: {
minLength: 1,
type: 'string',
},
protocol: {
Expand Down
8 changes: 7 additions & 1 deletion packages/next/server/post-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ class FontOptimizerMiddleware implements PostProcessMiddleware {
result = result.replace('</head>', `${fallBackLinkTag}</head>`)
} else {
const nonceStr = nonce ? ` nonce="${nonce}"` : ''
let dataAttr = ''

if (fontContent.includes('ascent-override')) {
dataAttr = ' data-size-adjust="true"'
}

result = result.replace(
'</head>',
`<style data-href="${url}"${nonceStr}>${fontContent}</style></head>`
`<style data-href="${url}"${nonceStr}${dataAttr}>${fontContent}</style></head>`
)

// Remove inert font tag
Expand Down

0 comments on commit cd9f9e9

Please sign in to comment.