Skip to content

Commit

Permalink
Merge branch 'canary' into fix/app-doc-check
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed May 5, 2022
2 parents 396e859 + 08ffbc9 commit 701841d
Show file tree
Hide file tree
Showing 99 changed files with 1,067 additions and 679 deletions.
331 changes: 181 additions & 150 deletions .github/workflows/build_test_deploy.yml

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions .github/workflows/pull_request_stats.yml
Expand Up @@ -13,18 +13,18 @@ jobs:
- name: tune linux network
run: sudo ethtool -K eth0 tx off rx off

- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 25

- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
id: docs-change

- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
node-version: 14
node-version: 16
check-latest: true

- name: Install
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:

- name: Turbo Cache
id: turbo-cache
uses: actions/cache@v2
uses: actions/cache@v3
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
path: .turbo
Expand All @@ -68,7 +68,7 @@ jobs:
# "If there are multiple partial matches for a restore key, the action returns the most recently created cache."
# So we get latest cache
- name: Cache built files
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ./packages/next-target
key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }}
Expand All @@ -77,8 +77,8 @@ jobs:
# since the repo's dependencies aren't installed we need
# to install napi globally
- run: npm i -g @napi-rs/cli@1.2.1
- run: npm i -g turbo@1.0.28
- run: npm i -g @napi-rs/cli@2.7.0
- run: npm i -g turbo@1.2.6

- name: Build
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
Expand All @@ -90,7 +90,7 @@ jobs:
TURBO_PROJECT: nextjs

- name: Upload artifact
uses: actions/upload-artifact@v2.2.4
uses: actions/upload-artifact@v3
with:
name: next-swc-dev-binary
path: packages/next-swc/native/next-swc.linux-x64-gnu.node
Expand All @@ -106,14 +106,14 @@ jobs:
needs: build-native-dev
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 25

- run: echo ::set-output name=DOCS_CHANGE::$(node skip-docs-change.js echo 'not-docs-only-change')
id: docs-change

- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }}
with:
name: next-swc-dev-binary
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_react_experimental.yml
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- run: yarn install --frozen-lockfile --check-files
env:
Expand All @@ -19,7 +19,7 @@ jobs:

- run: node run-tests.js --timings --write-timings -g 1/1

- uses: actions/cache@v2
- uses: actions/cache@v3
id: cache-build
with:
path: ./*
Expand All @@ -38,7 +38,7 @@ jobs:
matrix:
group: [1, 2, 3, 4, 5, 6]
steps:
- uses: actions/cache@v2
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test_react_next.yml
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- run: yarn install --frozen-lockfile --check-files
env:
Expand All @@ -19,7 +19,7 @@ jobs:

- run: node run-tests.js --timings --write-timings -g 1/1

- uses: actions/cache@v2
- uses: actions/cache@v3
id: cache-build
with:
path: ./*
Expand All @@ -38,7 +38,7 @@ jobs:
matrix:
group: [1, 2, 3, 4, 5, 6]
steps:
- uses: actions/cache@v2
- uses: actions/cache@v3
id: restore-build
with:
path: ./*
Expand Down
2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-server-side-props.md
Expand Up @@ -31,7 +31,7 @@ You can import modules in top-level scope for use in `getServerSideProps`. Impor
The `context` parameter is an object containing the following keys:

- `params`: If this page uses a [dynamic route](/docs/routing/dynamic-routes.md), `params` contains the route parameters. If the page name is `[id].js` , then `params` will look like `{ id: ... }`.
- `req`: [The `HTTP` IncomingMessage object](https://nodejs.org/api/http.html#http_class_http_incomingmessage).
- `req`: [The `HTTP` IncomingMessage object](https://nodejs.org/api/http.html#http_class_http_incomingmessage), with an additional `cookies` prop, which is an object with string keys mapping to string values of cookies.
- `res`: [The `HTTP` response object](https://nodejs.org/api/http.html#http_class_http_serverresponse).
- `query`: An object representing the query string.
- `preview`: `preview` is `true` if the page is in the [Preview Mode](/docs/advanced-features/preview-mode.md) and `false` otherwise.
Expand Down
1 change: 1 addition & 0 deletions docs/api-reference/next.config.js/custom-webpack-config.md
Expand Up @@ -36,6 +36,7 @@ The second argument to the `webpack` function is an object with the following pr
- `buildId`: `String` - The build id, used as a unique identifier between builds
- `dev`: `Boolean` - Indicates if the compilation will be done in development
- `isServer`: `Boolean` - It's `true` for server-side compilation, and `false` for client-side compilation
- `nextRuntime`: `String` - The target runtime for server-side compilation; either `"edge"` or `"nodejs"`
- `defaultLoaders`: `Object` - Default loaders used internally by Next.js:
- `babel`: `Object` - Default `babel-loader` configuration

Expand Down
58 changes: 57 additions & 1 deletion docs/api-reference/next/image.md
Expand Up @@ -16,6 +16,7 @@ description: Enable Image Optimization with the built-in Image component.

| Version | Changes |
| --------- | ----------------------------------------------------------------------------------------------------- |
| `v12.1.7` | Experimental `remotePatterns` configuration added. |
| `v12.1.1` | `style` prop added. Experimental[\*](#experimental-raw-layout-mode) support for `layout="raw"` added. |
| `v12.1.0` | `dangerouslyAllowSVG` and `contentSecurityPolicy` configuration added. |
| `v12.0.9` | `lazyRoot` prop added. |
Expand Down Expand Up @@ -313,9 +314,64 @@ Other properties on the `<Image />` component will be passed to the underlying

## Configuration Options

### Remote Patterns

> Note: The `remotePatterns` configuration is currently **experimental** and subject to change. Please use [`domains`](#domains) for production use cases.
To protect your application from malicious users, configuration is required in order to use external images. This ensures that only external images from your account can be served from the Next.js Image Optimization API. These external images can be configured with the `remotePatterns` property in your `next.config.js` file, as shown below:

```js
module.exports = {
experimental: {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'example.com',
port: '',
pathname: '/account123/**',
},
],
},
},
}
```

> Note: The example above will ensure the `src` property of `next/image` must start with `https://example.com/account123/`. Any other protocol, hostname, port, or unmatched path will respond with 400 Bad Request.
Below is another example of the `remotePatterns` property in the `next.config.js` file:

```js
module.exports = {
experimental: {
images: {
remotePatterns: [
{
protocol: 'https',
hostname: '**.example.com',
},
],
},
},
}
```

> Note: The example above will ensure the `src` property of `next/image` must start with `https://img1.example.com` or `https://me.avatar.example.com` or any number of subdomains. Any other protocol or unmatched hostname will respond with 400 Bad Request.
Wildcard patterns can be used for both `pathname` and `hostname` and have the following syntax:

- `*` match a single path segment or subdomain
- `**` match any number of path segments at the end or subdomains at the beginning

The `**` syntax does not work in the middle of the pattern.

### Domains

To protect your application from malicious users, you must define a list of image provider domains that you want to be served from the Next.js Image Optimization API. This is configured in with the `domains` property in your `next.config.js` file, as shown below:
Similar to [`remotePatterns`](#remote-patterns), the `domains` configuration can be used to provide a list of allowed hostnames for external images.

However, the `domains` configuration does not support wildcard pattern matching and it cannot restrict protocol, port, or pathname.

Below is an example of the `domains` property in the `next.config.js` file:

```js
module.exports = {
Expand Down
14 changes: 4 additions & 10 deletions docs/basic-features/image-optimization.md
Expand Up @@ -66,7 +66,7 @@ function Home() {

### Remote Images

To use a remote image, the `src` property should be a URL string, which can be [relative](#loaders) or [absolute](#domains). Because Next.js does not have access to remote files during the build process, you'll need to provide the [`width`](/docs/api-reference/next/image.md#width), [`height`](/docs/api-reference/next/image.md#height) and optional [`blurDataURL`](/docs/api-reference/next/image.md#blurdataurl) props manually:
To use a remote image, the `src` property should be a URL string, which can be [relative](#loaders) or [absolute](/docs/api-reference/next/image.md#domains). Because Next.js does not have access to remote files during the build process, you'll need to provide the [`width`](/docs/api-reference/next/image.md#width), [`height`](/docs/api-reference/next/image.md#height) and optional [`blurDataURL`](/docs/api-reference/next/image.md#blurdataurl) props manually:

```jsx
import Image from 'next/image'
Expand All @@ -93,15 +93,9 @@ export default function Home() {

Sometimes you may want to access a remote image, but still use the built-in Next.js Image Optimization API. To do this, leave the `loader` at its default setting and enter an absolute URL for the Image `src`.

To protect your application from malicious users, you must define a list of remote domains that you intend to access this way. This is configured in your `next.config.js` file, as shown below:
To protect your application from malicious users, you must define a list of remote hostnames you intend to allow remote access.

```js
module.exports = {
images: {
domains: ['example.com', 'example2.com'],
},
}
```
> Learn more about [`domains`](/docs/api-reference/next/image.md#domains) configuration.
### Loaders

Expand Down Expand Up @@ -207,7 +201,7 @@ For examples of the Image component used with the various fill modes, see the [I

## Configuration

The `next/image` component and Next.js Image Optimization API can be configured in the [`next.config.js` file](/docs/api-reference/next.config.js/introduction.md). These configurations allow you to [enable remote domains](/docs/api-reference/next/image.md#domains), [define custom image breakpoints](/docs/api-reference/next/image.md#device-sizes), [change caching behavior](/docs/api-reference/next/image.md#caching-behavior) and more.
The `next/image` component and Next.js Image Optimization API can be configured in the [`next.config.js` file](/docs/api-reference/next.config.js/introduction.md). These configurations allow you to [enable remote images](/docs/api-reference/next/image.md#domains), [define custom image breakpoints](/docs/api-reference/next/image.md#device-sizes), [change caching behavior](/docs/api-reference/next/image.md#caching-behavior) and more.

[**Read the full image configuration documentation for more information.**](/docs/api-reference/next/image.md#configuration-options)

Expand Down
2 changes: 2 additions & 0 deletions errors/invalid-images-config.md
Expand Up @@ -17,6 +17,8 @@ module.exports = {
imageSizes: [16, 32, 48, 64, 96, 128, 256, 384],
// limit of 50 domains values
domains: [],
// limit of 50 objects
remotePatterns: [],
// path prefix for Image Optimization API, useful with `loader`
path: '/_next/image',
// loader can be 'default', 'imgix', 'cloudinary', 'akamai', or 'custom'
Expand Down
2 changes: 1 addition & 1 deletion errors/no-cache.md
Expand Up @@ -78,7 +78,7 @@ cache:
Using GitHub's [actions/cache](https://github.com/actions/cache), add the following step in your workflow file:

```yaml
uses: actions/cache@v2
uses: actions/cache@v3
with:
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node
path: |
Expand Down
1 change: 0 additions & 1 deletion examples/with-playwright/styles/Home.module.css
Expand Up @@ -5,7 +5,6 @@
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}

.main {
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -16,5 +16,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "12.1.7-canary.1"
"version": "12.1.7-canary.2"
}
20 changes: 0 additions & 20 deletions package.json
Expand Up @@ -181,25 +181,5 @@
},
"engines": {
"node": ">=12.22.0"
},
"turbo": {
"pipeline": {
"build-native": {
"dependsOn": [
"^build-native"
],
"outputs": [
"native/*.node"
]
},
"build-wasm": {
"dependsOn": [
"^build-wasm"
],
"outputs": [
"crates/wasm/pkg/*"
]
}
}
}
}
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"keywords": [
"react",
"next",
Expand Down
4 changes: 2 additions & 2 deletions packages/eslint-config-next/package.json
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"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": "12.1.7-canary.1",
"@next/eslint-plugin-next": "12.1.7-canary.2",
"@rushstack/eslint-patch": "^1.1.3",
"@typescript-eslint/parser": "^5.21.0",
"eslint-import-resolver-node": "^0.3.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "12.1.7-canary.1",
"version": "12.1.7-canary.2",
"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

0 comments on commit 701841d

Please sign in to comment.