Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] canary from vercel:canary #561

Merged
merged 49 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
844776e
Support named exports for server references (#46558)
shuding Mar 1, 2023
fcfab17
Fix(typedRoutes): fixed StaticRoutes and DynamicRoutes being empty ca…
DuCanhGH Mar 1, 2023
1717fd2
Fix IntelliSense for generateMetadata (#46624)
shuding Mar 1, 2023
16a0e5a
chore: improve repo templates (#46629)
balazsorban44 Mar 1, 2023
68a1d54
Update app-static test page (#46645
ijjk Mar 1, 2023
5c18e9a
Update vendored React packages to next-41110021f (#46636)
acdlite Mar 1, 2023
dd2a1c6
Add request callback in Flight client (#46650)
shuding Mar 1, 2023
5cc9010
fix: distDir in verifyTypeScriptSetup for nextLint (#46630)
teobler Mar 1, 2023
9720ba5
chore(docs): add snippets for common image loaders (#46647)
styfle Mar 1, 2023
5e112c0
Updates `next/image` eslint message to denote that costs may be incur…
manovotny Mar 1, 2023
c627912
Ensure default config passes schema checks (#46656)
ijjk Mar 1, 2023
63d81de
test: add preconnect tests and move error tests (#46652)
huozhi Mar 1, 2023
7bf5dcb
Refactor and add more tests to next/font/local (#46627)
hanneslund Mar 1, 2023
2e23cd7
Add script to automate updating vendored React version (#46663)
acdlite Mar 2, 2023
8545d66
Use separate workers for webpackBuildWorker (#46666)
ijjk Mar 2, 2023
262501e
v13.2.4-canary.0
ijjk Mar 2, 2023
d2cbf8c
Fix the doc on how to use the turbo loader in option-less format (#46…
smorimoto Mar 2, 2023
a20ce54
Add @types/mdx to app-dir-mdx example (#46523)
Dannymx Mar 2, 2023
6499b7b
Fix custom server error handling in the docs (#46671)
Janpot Mar 2, 2023
ed51bd8
Fix static to dynamic on revalidate (#46668)
ijjk Mar 2, 2023
d9e01ad
Fix the Next.js router in Turbopack when there are no middlewares (#4…
alexkirsz Mar 2, 2023
7323d5c
docs: clarified the wording (#46691)
Mar 2, 2023
9c32adc
Update script.md (#46680)
Humboorgir Mar 2, 2023
111ef39
build(cargo): update turbopack (#46685)
alexkirsz Mar 2, 2023
e7ee310
Add build worker exit tracking and enable tests (#46698)
ijjk Mar 2, 2023
3229ed7
Support `force-static` on App Routes (#46693)
wyattjoh Mar 2, 2023
8416b70
Add viewport field userScalable (#46696)
huozhi Mar 2, 2023
1356088
Update static build workers (#46705)
ijjk Mar 2, 2023
ad6961d
Refactor build context for better plugin state sharing (#46706)
shuding Mar 2, 2023
2a737e7
Refactor next/font/google and add additional comments (#46692)
hanneslund Mar 2, 2023
4e54429
Support multi title for alternates (#46700)
huozhi Mar 2, 2023
ed6cd41
Ensure test-unit includes package unit tests (#46707)
ijjk Mar 2, 2023
f7bfaff
v13.2.4-canary.1
ijjk Mar 3, 2023
9acbf6e
Disallow wildcard export in server entries (#46710)
shuding Mar 3, 2023
ff2159d
Add test for router.refresh preserving unaffected segments (#46687)
timneutkens Mar 3, 2023
dda9be0
Failing test for SWC `shakeExports` and JSX (#35735)
Mar 3, 2023
45492ea
Fix originalRequest not available for edge requests (#46741)
wyattjoh Mar 3, 2023
bca8014
Fix require cache conflict between app and pages (#46736)
huozhi Mar 3, 2023
61eee15
Fix Web app manifests docs (#46617)
HaNdTriX Mar 3, 2023
35d8e83
Ensure app chunk URLs are encoded properly (#46749
ijjk Mar 3, 2023
33827ed
Update client router filter to separate redirects handling (#46752)
ijjk Mar 4, 2023
ef685e8
Adjust API route loader (#46726
shuding Mar 4, 2023
25efdfa
Add support for `output: export` config (#46744)
styfle Mar 4, 2023
8303c56
Pass through original matcher source in manifest (#46753)
ijjk Mar 4, 2023
f2989f7
v13.2.4-canary.2
ijjk Mar 4, 2023
5aa9bc8
Use browser navigation when RSC payload fails to fetch (#46674)
timneutkens Mar 4, 2023
9a768d5
test: refactor metadata tests to test multi matches easier (#46746)
huozhi Mar 4, 2023
6357de0
Use set to track CSS imports (#46772)
shuding Mar 4, 2023
3e9a99c
Fix middleware notFound: true handling (#46759)
ijjk Mar 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/DISCUSSION_TEMPLATE/help.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
body:
- type: textarea
attributes:
label: Summary
description: What do you need help with?
validations:
required: true
- type: textarea
attributes:
label: Additional information
description: Any code snippets, error messages, or dependency details that may be related? (`next info`)
render: js
validations:
required: false
- type: input
attributes:
label: Example
description: A link to a minimal reproduction is helpful for collaborative debugging!
validations:
required: false
33 changes: 33 additions & 0 deletions .github/DISCUSSION_TEMPLATE/ideas.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
body:
- type: textarea
attributes:
label: Goals
description: Short list of what the feature request aims to address?
value: |
1.
2.
3.
validations:
required: true
- type: textarea
attributes:
label: Non-Goals
description: Short list of what the feature request _does not_ aim to address?
value: |
1.
2.
3.
validations:
required: false
- type: textarea
attributes:
label: Background
description: Discuss prior art, why do you think this feature is needed? Are there current alternatives?
validations:
required: true
- type: textarea
attributes:
label: Proposal
description: How should this feature be implemented? Are you interested in contributing?
validations:
required: true
9 changes: 5 additions & 4 deletions .github/ISSUE_TEMPLATE/1.bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ labels: ['template: bug']
body:
- type: markdown
attributes:
value: 'NOTE: [examples](https://github.com/vercel/next.js/tree/canary/examples) related issue should be reported using [this](https://github.com/vercel/next.js/issues/new?assignees=&labels=type%3A+example%2Ctemplate%3A+bug&template=2.example_bug_report.yml) issue template instead.'
- type: markdown
attributes:
value: If you leave out sections there is a high likelihood it will be moved to the GitHub Discussions ["Help" section](https://github.com/vercel/next.js/discussions/categories/help).
value: |
*Note:* If you leave out sections, the issue might be moved to the ["Help" section](https://github.com/vercel/next.js/discussions/categories/help).
[examples](https://github.com/vercel/next.js/tree/canary/examples) related issue should be reported using [this](https://github.com/vercel/next.js/issues/new?assignees=&labels=type%3A+example%2Ctemplate%3A+bug&template=2.example_bug_report.yml) issue template instead.
Feature requests should be opened as [discussions](https://github.com/vercel/next.js/discussions/new?category=ideas). [Read more](https://github.com/vercel/next.js/blob/canary/contributing/core/adding-features.md).
- type: checkboxes
attributes:
label: Verify canary release
Expand All @@ -19,6 +19,7 @@ body:
attributes:
label: Provide environment information
description: Please run `next info` in the root directory of your project and paste the results. You might need to use `npx --no-install next info` if next is not in the current PATH.
render: bash
validations:
required: true
- type: dropdown
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/2.example_bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ labels: ['area: examples']
body:
- type: markdown
attributes:
value: Thanks for taking the time to file a bug report for [one of the examples](https://github.com/vercel/next.js/tree/canary/examples)! Please fill out this form as completely as possible.
- type: markdown
attributes:
value: If you leave out sections there is a high likelihood it will be moved to the GitHub Discussions ["Help" section](https://github.com/vercel/next.js/discussions/categories/help).
value: |
*Note:* If you leave out sections, the issue might be moved to the ["Help" section](https://github.com/vercel/next.js/discussions/categories/help).
Thanks for taking the time to file a bug report for [one of the examples](https://github.com/vercel/next.js/tree/canary/examples)! Please fill out this form as completely as possible.
- type: checkboxes
attributes:
label: Verify canary release
Expand All @@ -19,6 +18,7 @@ body:
attributes:
label: Provide environment information
description: Please run `next info` in the root directory of your project and paste the results. You might need to use `npx --no-install next info` if next is not in the current PATH.
render: bash
validations:
required: true
- type: input
Expand Down
28 changes: 0 additions & 28 deletions .github/ISSUE_TEMPLATE/3.feature_request.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ contact_links:
- name: Ask a question
url: https://github.com/vercel/next.js/discussions
about: Ask questions and discuss with other community members
- name: Feature request
url: https://github.com/vercel/next.js/discussions/new?category=ideas
about: Feature requests should be opened as discussions
1 change: 1 addition & 0 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ To contribute to [our examples](./examples), please see
- [Building](./contributing/core/building.md)
- [Testing](./contributing/core/testing.md)
- [Adding Error Links](./contributing/core/adding-error-links.md)
- [Adding a new feature](./contributing/core/adding-features.md)
- [Developing Using Local App](./contributing/core/developing-using-local-app.md)
<!-- - [Using the VS Code Debugger](./contributing/core/vscode-debugger.md) -->
17 changes: 17 additions & 0 deletions contributing/core/adding-features.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Adding a new feature

Anyone can propose a change to Next.js. However, adding new features often requires community discussions before proceeding with the implementation.

Therefore, before opening a PR, you should use the [Feature Request discussion template](https://github.com/vercel/next.js/discussions/new?category=ideas) and collect feedback.

## Why use a discussion?

The discussion's goal is to achieve the following:

1. **Verify the validity of the feature request**: The community can upvote discussions. Highly upvoted feature requests are more likely to be considered.
2. **Understanding the consequences**: Any feature added to Next.js is likely to be around for a while and _has to be maintained_. This means that a new feature has to cover many use cases, needs to consider how it affects the ecosystem, and so on.
3. **Looking at and understanding historical reasons for the current behavior or lack of the feature**: There might be a reason why a feature does not exist, or why the current implementation is in a certain way. There must be solid reasoning to change this, as the feature needs to be maintained even after it is added. (See 2.). Next.js has a strong policy on not breaking features, so any new feature has to be added in a way that makes it possible to incrementally adopt it.

## Examples

The Next.js team uses RFCs (Request For Comment), which you can find in [this discussion category](https://github.com/vercel/next.js/discussions/categories/rfc). Reading through these, you can get a better understanding of what is expected to be included in a good feature request.
3 changes: 2 additions & 1 deletion contributing/repository/triaging.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

Repository maintainers triage every issue and PR opened in the repository.

> Note: Feature requests should be opened as discussions, filling out [this template](https://github.com/vercel/next.js/discussions/new?category=ideas).
Issues are opened with one of these labels:

- `template: story` - a feature request, converted to an [💡 Ideas discussion](https://github.com/vercel/next.js/discussions/categories/ideas)
- `template: bug` - unverified issue with Next.js itself, or one of the examples in the [`examples`](https://github.com/vercel/next.js/tree/canary/examples) folder
- `template: documentation` - feedback for improvement or an unverified issue with the Next.js documentation

Expand Down
10 changes: 7 additions & 3 deletions docs/advanced-features/custom-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ app.prepare().then(() => {
res.statusCode = 500
res.end('internal server error')
}
}).listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://${hostname}:${port}`)
})
.once('error', (err) => {
console.error(err)
process.exit(1)
})
.listen(port, () => {
console.log(`> Ready on http://${hostname}:${port}`)
})
})
```

Expand Down
18 changes: 16 additions & 2 deletions docs/advanced-features/static-html-export.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,20 @@ If you're looking to build a hybrid site where only _some_ pages are prerendered

## `next export`

Update your build script in `package.json` to use `next export`:
Update your `next.config.js` file to include `output: "export"` like the following:

```js
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
output: 'export',
}

module.exports = nextConfig
```

Update your scripts in `package.json` file to include `next export` like the following:

```json
"scripts": {
Expand Down Expand Up @@ -59,7 +72,8 @@ Features that require a Node.js server, or dynamic logic that cannot be computed
- [Headers](/docs/api-reference/next.config.js/headers.md)
- [Middleware](/docs/middleware.md)
- [Incremental Static Regeneration](/docs/basic-features/data-fetching/incremental-static-regeneration.md)
- [`fallback: true`](/docs/api-reference/data-fetching/get-static-paths.md#fallback-true)
- [`getStaticPaths` with `fallback: true`](/docs/api-reference/data-fetching/get-static-paths.md#fallback-true)
- [`getStaticPaths` with `fallback: 'blocking'`](/docs/api-reference/data-fetching/get-static-paths.md#fallback-blocking)
- [`getServerSideProps`](/docs/basic-features/data-fetching/get-server-side-props.md)

### `getInitialProps`
Expand Down
158 changes: 158 additions & 0 deletions docs/api-reference/next.config.js/custom-image-loader-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
---
description: Custom configuration for the next/image loader
---

# Custom Image Loader Configuration

If you want to use a cloud provider to optimize images instead of using the Next.js built-in Image Optimization API, you can configure `next.config.js` with the following:

```js
module.exports = {
images: {
loader: 'custom',
loaderFile: './my/image/loader.js',
},
}
```

This `loaderFile` must point to a file relative to the root of your Next.js application. The file must export a default function that returns a string, for example:

```js
export default function myImageLoader({ src, width, quality }) {
return `https://example.com/${src}?w=${width}&q=${quality || 75}`
}
```

Alternatively, you can use the [`loader` prop](/docs/api-reference/next/image.md#loader) to pass the function to each instance of `next/image`.

## Example Loader Configuration

- [Akamai](#akamai)
- [Cloudinary](#cloudinary)
- [Cloudflare](#cloudflare)
- [Contentful](#contentful)
- [Fastly](#fastly)
- [Gumlet](#gumlet)
- [ImageEngine](#imageengine)
- [Imgix](#imgix)
- [Thumbor](#thumbor)

### Akamai

```js
// Docs: https://techdocs.akamai.com/ivm/reference/test-images-on-demand
export default function akamaiLoader({ src, width, quality }) {
return `https://example.com/${src}?imwidth=${width}`
}
```

### Cloudinary

```js
// Demo: https://res.cloudinary.com/demo/image/upload/w_300,c_limit,q_auto/turtles.jpg
export default function cloudinaryLoader({ src, width, quality }) {
const params = ['f_auto', 'c_limit', `w_${width}`, `q_${quality || 'auto'}`]
return `https://example.com/${params.join(',')}${src}`
}
```

### Cloudflare

```js
// Docs: https://developers.cloudflare.com/images/url-format
export default function cloudflareLoader({ src, width, quality }) {
const params = [`width=${width}`, `quality=${quality || 75}`, 'format=auto']
return `https://example.com/cdn-cgi/image/${params.join(',')}/${src}`
}
```

### Contentful

```js
// Docs: https://www.contentful.com/developers/docs/references/images-api/
export default function contentfulLoader({ src, quality, width }) {
const url = new URL(`https://example.com${src}`)
url.searchParams.set('fm', 'webp')
url.searchParams.set('w', width.toString())
url.searchParams.set('q', quality.toString() || '75')
return url.href
}
```

## Fastly

```js
// Docs: https://developer.fastly.com/reference/io/
export default function fastlyLoader({ src, width, quality }) {
const url = new URL(`https://example.com${src}`)
url.searchParams.set('auto', 'webp')
url.searchParams.set('width', width.toString())
url.searchParams.set('quality', quality.toString() || '75')
return url.href
}
```

## Gumlet

```js
// Docs: https://docs.gumlet.com/reference/image-transform-size
export default function gumletLoader({ src, width, quality }) {
const url = new URL(`https://example.com${src}`)
url.searchParams.set('format', 'auto')
url.searchParams.set('w', width.toString())
url.searchParams.set('q', quality.toString() || '75')
return url.href
}
```

### ImageEngine

```js
// Docs: https://support.imageengine.io/hc/en-us/articles/360058880672-Directives
export default function imageengineLoader({ src, width, quality }) {
const compression = 100 - (quality || 50)
const params = [`w_${width}`, `cmpr_${compression}`)]
return `https://example.com${src}?imgeng=/${params.join('/')`
}
```

### Imgix

```js
// Demo: https://static.imgix.net/daisy.png?format=auto&fit=max&w=300
export default function imgixLoader({ src, width, quality }) {
const url = new URL(`https://example.com${src}`)
const params = url.searchParams
params.set('auto', params.getAll('auto').join(',') || 'format')
params.set('fit', params.get('fit') || 'max')
params.set('w', params.get('w') || width.toString())
params.set('q', quality.toString() || '50')
return url.href
}
```

### Thumbor

```js
// Docs: https://thumbor.readthedocs.io/en/latest/
export default function thumborLoader({ src, width, quality }) {
const params = [`${width}x0`, `filters:quality(${quality || 75})`]
return `https://example.com${params.join('/')}${src}`
}
```

## Related

<div class="card">
<a href="/docs/basic-features/image-optimization.md">
<b>Image Optimization</b>
<small>Learn how to optimize images with the Image component.</small>
</a>
</div>

<div class="card">
<a href="/docs/api-reference/next.config.js/introduction.md">
<b>Introduction to next.config.js:</b>
<small>Learn more about the configuration file used by Next.js.</small>
</a>
</div>
2 changes: 1 addition & 1 deletion docs/api-reference/next.config.js/turbopack.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = {
},
],
// Option-less format
'.mdx': '@mdx-js/loader',
'.mdx': ['@mdx-js/loader'],
},
},
},
Expand Down
Loading