Commit graph

9365 commits

Author SHA1 Message Date
Wyatt Johnson
efe00e941b
Enable Pages Route Module Rendering for Edge (#51894)
This adapts the new route module rendering to support edge as well.

- Added a new `routeModule` export to the Edge SSR Loader
- Updated some tests to validate page state

Fixes NEXT-1327
2023-06-30 18:42:58 +00:00
Shu Ding
636c776179
Fix font missing during server HMR (#52033)
During development, for fonts created via `next/font` the file path is already containing the hash so we can always have them cached. This fixes the problem of fonts causing FOUC in HMR.

Since I can't find an easy way to test it reliably, I recorded two screenshots using the same steps as reproduced in #50879:

https://github.com/vercel/next.js/assets/3676859/5cb6a64c-cb4a-4ed4-808f-d7b2d0d6c0a3

With the fix:

https://github.com/vercel/next.js/assets/3676859/154b2332-a94b-4392-8132-4be609670745


fix #50879
fix NEXT-1334
2023-06-30 17:11:37 +00:00
Steven
97461f0bba
fix(create-next-app): consolidate messages to "Would you like to use" (#52011)
This PR ensure that `create-next-app` questions are all formatted the
same way:

```
Would you like to use <feature>?
```

fix NEXT-1333
2023-06-30 18:11:23 +02:00
Tobias Koppers
d443778163
Refactor ContentSources to RouteTree (#51660)
### What?

This fixes a performance problem when many pages are involved.

fixes WEB-1067

see also https://github.com/vercel/turbo/pull/5360

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5416 
* https://github.com/vercel/turbo/pull/5360
2023-06-30 16:03:24 +00:00
Jiachi Liu
4bfc1eaf54
Revert "Optimize inlined Flight data array format" (#52039)
Reverts vercel/next.js#52028

revert temporarily and will re-land in next round release
2023-06-30 16:12:31 +02:00
Shu Ding
0123a9d5c9
Optimize inlined Flight data array format (#52028)
When looking at [some sites](https://rsc-llm-on-the-edge.vercel.app/) with a large amount of chunks streamed, I noticed that the inlined Flight data array can be optimized quite a lot. Currently we do:

```js
self.__next_f.push([1,"d5:[\"4\",[\"$\",\"$a\",null,..."])
```

1. The `self.` isn't needed (except for the initial bootstrap tag) as React itself has `<script>$RC("B:f","S:f")</script>` too.
2. After the bootstrap script tag, all items are an array with `[1, flight_data]` and `flight_data` is always a string. We can just push only these strings.
3. We use `JSON.stringify(flight_payload)` to inline the payload where the payload itself is a string with a lot of double quotes (`"`), this results in a huge amount of backslashes (`\`). Here we can instead replace it to use a pair of single quotes on the outside and un-escape the double quotes inside.

Here's a side-by-side comparison of a small page:

<img width="1710" alt="CleanShot 2023-06-30 at 11 41 02@2x" src="https://github.com/vercel/next.js/assets/3676859/398356ec-91d5-435c-892d-16fb996029e8">

For a real production page I saw the HTML payload reduced by 11,031 bytes, a 3% improvement.

Note that all the tests are not considering gzip here, so the actual traffic impact will be smaller.
2023-06-30 13:27:38 +00:00
vercel-release-bot
0dd225b128 v13.4.8-canary.13 2023-06-30 12:25:06 +00:00
Shu Ding
61ac92995a
Refactor some loaders to be synchronous (#51997)
This PR changes some Webpack loaders to be synchronous as they don't have async code inside. Some of them will scale quiet a lot such as `next-flight-client-module-loader` and we don't want to waste some extra ticks there, as well as got potentially queued after some other events like file I/O.
2023-06-30 12:19:58 +00:00
Jiachi Liu
54a963b666
Update displayed error message for rsc case (#52004)
We show the "Application error: a client-side exception has occurred (see the browser console for more information)" error incorrectly when a server-side error occurs (a digest is present) when we should be showing an error saying it is in fact a server side error and should check the logs there. This change will make the error message more accurate for users to look up

Fixes NEXT-1263
2023-06-30 11:31:19 +00:00
Shu Ding
0fb5fa550c
Avoid disposing middleware and instrumentation hook during development (#52022)
Unlike other routes, these two entries are needed for every request so there is no reason to have them disposed. This avoids wasting extra dev server resource to get them re-compiled.
2023-06-30 09:15:11 +00:00
Shu Ding
80e05a881c
Increase time and size windows for cached on-demand entries (#52019)
Increase `maxInactiveAge` to be `60` seconds and `pagesBufferLength` to be `5`. This change makes it infrequent to have expired entry compilations from recent accessed routes when running the dev server.
2023-06-30 08:35:36 +00:00
vercel-release-bot
27953213f8 v13.4.8-canary.12 2023-06-29 23:30:23 +00:00
Justin Ridgewell
aec3c58d1c
Update edge-runtime to latest (#51944)
### What?

The updates `edge-runtime` to the latest version

### Why?

https://github.com/vercel/edge-runtime/pull/428 fixes `consumeUint8ArrayReadableStream` so that when we break iteration early (due to client disconnect), we cleanup the inner stream. That will fire the stream's `cancel` handler, and allow devs to disconnect from an AI service fetch.

### How?

`edge-runtime` maintain a `try {} finally {}` over the inner stream's iteration. When we early break, JS will call `it.return()`, and that will resume `consumeUint8ArrayReadableStream` with an abrupt completion (essentially, the `yield` turns into a `return`). We'll be able to trigger the `finally {}` block with that, and we call `inner.cancel()` to cleanup.

Fixes https://github.com/vercel-labs/ai/issues/90
2023-06-29 23:15:20 +00:00
Jiachi Liu
dfe08aed33
Fix NextRequest constructor parameters (#52001)
FIx the type change introduced in #51727
2023-06-29 22:50:53 +00:00
Jiachi Liu
2f42cf557e
Filter invalid image descriptor from metadata images (#51992)
Filter out the invalid images in metadata og/twitter `images` filter to avoid crash when falsy image slides in.
Add filtering for now as the erroring doesn't show the proper trace pointing to where it's original introduced, might introduce other validation in the future.
2023-06-29 22:17:25 +00:00
Delba de Oliveira
18406adf9c
Make sure DevEx can approve docs PRs / Remove Spaces (#51996) 2023-06-29 17:10:53 +00:00
vercel-release-bot
152cfed6e8 v13.4.8-canary.11 2023-06-29 15:40:12 +00:00
vercel-release-bot
9ff526056b v13.4.8-canary.10 2023-06-29 13:55:17 +00:00
Tim Neutkens
ed280d2c46
Add shared input filesystem (#51879)
## What?

Currently we use 3 separate webpack compilers:

- server
- client
- edge

All of these were creating their own input filesystem (which is used to
read file, stat, etc.). Changing them to share a single inputFileSystem
allows the `cachedFileSystem` to be reused better, as `stat` and
`readFile` can be cached across the 3 compilers.

For the page on vercel.com we've been testing this shaves off 300-400ms
on a cold compile (no cache, deleted `.next`).

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-06-29 15:49:05 +02:00
Jimmy Lai
8703c55f9f
export config into functions config manifest (#51700)
remaining:
- add tests

caveat: this only works at the route level, we won't inherit from the layout or anything. I think that's fine




Co-authored-by: Florentin / 珞辰 <8146736+ecklf@users.noreply.github.com>
2023-06-29 13:42:25 +00:00
Leah
484bdebc24
Update turbopack and swc_core to v0.78.24 (#51943)
Reverts #51940

### What?

Update SWC crates and turbopack

### Turbopack Updates

* https://github.com/vercel/turbo/pull/5366 <!-- Justin Ridgewell - Fix
bug with `imports` field from a nested directory -->
* https://github.com/vercel/turbo/pull/5361 <!-- Tobias Koppers - update
for next.js changes to env vars -->
* https://github.com/vercel/turbo/pull/5311 <!-- OJ Kwon -
test(filetrace): skip failing tests -->
* https://github.com/vercel/turbo/pull/5402 <!-- Leah - reduce indent in
`analyze_ecmascript_module` by splitting the function up -->
* https://github.com/vercel/turbo/pull/5412 <!-- Leah - Update
`swc_core` to `v0.78.24` -->

Closes WEB-1174

Turbopack counterpart: https://github.com/vercel/turbo/pull/5412

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-29 15:11:57 +02:00
Tim Neutkens
3773c5be8c
Ensure metadata test is not affected by other tests (#51973)
Turn out the `should error when id is missing in generateSitemaps` test
was passing because of this test passing: `should error when id is
missing in generateImageMetadata`

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-06-29 15:10:19 +02:00
Ngô Đức Anh
c897933b6e
fix(typedRoutes): added missing anchor props to LinkRestProps (#51977)
### What?
This PR fixes `next/link`'s `<Link />` missing many `<a />` props when
`experimental.typedRoutes` is enabled.

### How?
It does that by changing `AnchorHTMLAttributes<HTMLAnchorElement>` in
LinkRestProps to
`DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement>`, which contains all `<a />` props.

Fixes #51907

---------

Co-authored-by: Shu Ding <g@shud.in>
2023-06-29 14:24:44 +02:00
vercel-release-bot
68075376f0 v13.4.8-canary.9 2023-06-29 11:27:00 +00:00
Shu Ding
922a45839a
Optimize next-app-loader file resolution (#51924)
This PR changes `fs.stat` calls (to check if a file exists or not) to be
aggregated as `fs.readdir` calls and cached during the entire loader
pass. This is because we have a huge amount of file to check, but they
are always in a small amount of directories.

For example, a route that's 5-directory deep (`/a/b/c/d/page.js`) can
have up to 4,000 special segments and metadata files to check. However
they're always under these 5 directories. So instead of 4,000 `fs.stat`
calls let's just do 5 `fs.readdir` calls.

Didn't measure it carefully but a quick local test shows a 20~30%
improvement.

<details>
<summary>Another idea for future improvements</summary>
Currently, we create a MissingModuleDependency for any combination of
possible metadata filename. But in reality, we only need to track them
incrementally by index. For example if `icon1.js` is missing, it's kinda
waste to still track `icon2.js`~`icon9.js` because `icon1.js` will be
added first. This change should at least reduce the number of file
watchers by 80% and the initial compilation time by 0.5~1s, depending on
the actual route.
</details>

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-06-29 13:21:32 +02:00
Tim Neutkens
b236670f97
Fix entrypoints.get and entrypoints.stream from turbopack (#50733)
## What?

Both `entrypoints.get` and `entrypoints.stream` threw an error because it was using the wrong tasks implementation. @sokra helped fix it.
2023-06-29 09:40:02 +00:00
Olivier Tassinari
60d27380f7
fix modularizeImports with @mui/material (#51953)
Fixes #51872. We were exploring in
https://github.com/mui/material-ui/pull/35457 the option to move the
`modularizeImports` config to our Next.js examples to fix
https://github.com/mui/material-ui/issues/35450 however, we never got to
complete the work.

We are not yet in a position where we can apply modularizeImports to
`@mui/material`. We still have folders to create to make it work.

Maybe we should close https://github.com/mui/material-ui/pull/35457?

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-28 20:26:04 -07:00
Jiachi Liu
f4b947fb56
Fix eslint async client component (#51952)
Fixes #51917 

It's throwing error in arrow function, should also be covered in the
lint rule
fix NEXT-1326
2023-06-28 20:03:32 -07:00
Steven
946c9c5c46
Add unstable_getImgProps export from next/image (#51205)
### Description 

This PR refactors the Image component so that the core logic can be consolidated into a single function.

This allows usage outside of `<Image>`, such as:

1. Working with [`background-image`](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) or [`image-set`](https://developer.mozilla.org/en-US/docs/Web/CSS/image/image-set)
2. Working with canvas [`context.drawImage()`](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images) or simply `new Image()`
3. Working with [`<picture>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture) media queries to implement Art Direction or Light/Dark Mode images

### Example

```tsx
import { unstable_getImgProps as getImgProps } from 'next/image'

export default function Page() {
  const common = { alt: 'Hero', width: 800, height: 400 }
  const { props: { srcSet: dark } } = getImgProps({ ...common, src: '/dark.png' })
  const { props: { srcSet: light, ...rest } } = getImgProps({ ...common, src: '/light.png' })

  return (<picture>
  <source media="(prefers-color-scheme: dark)" srcSet={dark} />
  <source media="(prefers-color-scheme: light)" srcSet={light} />
  <img {...rest} />
</picture>)
}
```

### Related

fix NEXT-257

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-06-29 01:35:08 +00:00
Mrxbox98
bd1fc78bd8
Add cpu-features to server external packages (#51946)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
### What?
Adds [cpu-features](https://www.npmjs.com/package/cpu-features) to
external server packages.

### Why?
To prevent developers from having to add ``cpu-features`` to their next
config.
2023-06-28 17:52:04 -07:00
Jiachi Liu
3fb41561c4
Support react profiling option for app dir client components (#51947)
`reactProductionProfiling` was a next config working for pages before mainly for profiling react, this PR also enables it for pages.

### Chanegs

* Add react profiling entry and related alias
* Fix `reactProductionProfiling` is missing in next config type and schema

Closes #51131
2023-06-29 00:00:11 +00:00
Josh Goldberg ✨
0bd9b4bbdf
fix(next): improve error for using <Html> outside of document (#45056)
## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added -> this is a pretty niche edge case, do
you want me to?
- [x] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

Fixes #45024

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-28 15:40:35 -07:00
Jacob Fletcher
d206c68ad7
adds payload to server-external-packages.json (#51933)
### What?
Adds `payload` to the external package list

### Why?

To prevent developers using
[Payload](https://github.com/payloadcms/payload) modules within Next.js
from having to add this in their next config.
2023-06-28 13:03:08 -07:00
Justin Ridgewell
525ecf4158
Ensure edge runtime Pages API/App Route handlers AbortSignal aborts on client disconnect (#51727)
### What?

This ensures the `request.signal` `AbortSignal` that every Pages API and App Route handler receives aborts when the client disconnects.

### Why?

Now that we [support cancelling](https://github.com/vercel/next.js/pull/51594) responses mid-stream, it's important that we can communicate that abort to developer code. Eg, for AI endpoints that have an streaming `fetch` connection to the some 3p AI service, it's important that they're able to abort that stream when the client's browser disconnects.

### How?

Just need to listen for `error` events on Node's `IncomingMessage` request object, and forward that to an `AbortController`. After that, propagate the signal through the server to web-style handlers.
2023-06-28 16:50:45 +00:00
Leah
f2dc6c87e9
error recovery during turbopack hydration (#51882)
### What?

Makes sure the next.js hydration code can run and that we can open the error overlay when there's an error in the entry page

Fixes WEB-1168
2023-06-28 14:50:04 +00:00
Leah
f1a4f7ad7d
fix turbopack mdx import map (#51881)
I accidentally broke this with #49818
2023-06-28 14:19:33 +00:00
Sukka
e7a692537c
Reduce the client bundle size of App Router (#51806)
After migrating a Next.js app from Pages Router to App Router and using as many RSC as possible, I notice that the client js bundle size actually increases by 5%. It turns out that Next.js has introduced a lot of code to the client bundle.

<img width="1354" alt="image" src="https://github.com/vercel/next.js/assets/40715044/c7216fee-818b-4593-917e-bf0d2a00967a">

The PR is an attempt to reduce the client bundle size.
2023-06-28 13:32:10 +00:00
vercel-release-bot
e33b87d894 v13.4.8-canary.8 2023-06-28 09:04:46 +00:00
Shu Ding
ba252d8765
Simplify module context invalidation (#51905)
It _might_ be an overhead to send over a large amount of data over
`postMessage` just for diff. HMR and module compilation is way less
frequent than evaluation in the sandbox, so maybe we should always
invalidate the cache eagerly without any comparison and defer the
workload to `evaluateInContext`.

Some observations:

<img width="662"
src="https://github.com/vercel/next.js/assets/3676859/12136002-8857-4e10-ba9a-bf420d098dc8">

<img width="662" alt="CleanShot 2023-06-28 at 08 26 23@2x"
src="https://github.com/vercel/next.js/assets/3676859/db054948-a0ea-4d98-bf4f-aa125e0eb1b5">

![CleanShot 2023-06-28 at 08 02
24@2x](https://github.com/vercel/next.js/assets/3676859/b674beb1-d53c-4a1d-a9bf-ca3672e089c8)
2023-06-28 11:00:39 +02:00
Jimmy Lai
5b883bb5d1
performance: enable minification for the server bundles (#51831)
This PR makes the server code be minified.

## Why

This will improve performance of the server code because of the lesser
size, lesser time to parse and lesser code via tree sharking.

Cons: this should lead to increased build times, so a
`disableServerMinification` config was added


<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

link NEXT-1319
2023-06-28 09:08:17 +02:00
Shu Ding
702d3d291c
Add retries and clear message to font fetching (#51890)
Improve the problems mentioned in #45080.

- Adding error retries (3 attempts) to font fetching. When you have a slow network, it might take >3s to load.
- Improve the error message to tell you that you might have unstable network connection.
- Do not cause build error (caused by missing `AbortController`) in Node 14 (even if we don't support Node 14, better to pass the build instead of hard error).
2023-06-27 23:57:06 +00:00
vercel-release-bot
2c856cb256 v13.4.8-canary.7 2023-06-27 23:04:22 +00:00
Max Leiter
25629bb880
node-polyfill-web-streams: require from stream/web instead of stream (#51906)
Follow-up to #51901
2023-06-27 15:09:45 -07:00
Max Leiter
a3d3016de8
next/node-polyfill-web-streams: fix web stream polyfill for Node v16 (#51901)
### What?
Slack thread:
https://vercel.slack.com/archives/C050WU03V3N/p1687889719318819

In Node 16, the ReadableStream is not on the global but instead under
the `stream` package. We should polyfill the global with that
implementation, if available

### Why?
Fixes passing ReadableStream from the Node.js runtime to the vercel/ai
SDK.
2023-06-27 12:46:23 -07:00
OJ Kwon
73c905dc53
feat(next-dev): add a new experimental flag (#51895)
### What?

WEB-1239. This is mainly for the code paths to not to cause regressions to existing turbopack.
2023-06-27 18:34:04 +00:00
Jiachi Liu
a04a34d3b7
Support relative url for openGraph.url and itunes.appArgument (#51877)
To enable the ability of leveraging current `pathname` and configured `metadataBase` for other canonical like urls, we support those urls with auto resolving with `pathename` and `metadataBase` like canonical url, then you could just configure relative paths like below

```js
openGraph: {
    url: './abc', // will be resolved based on pathname and metadata base
},
itunes: {
   appId: 'my-app-id'
   appArgument: './native-app'
}
```


Fixes #51829
Closes NEXT-1302
2023-06-27 17:01:49 +00:00
Jiachi Liu
a54d08bd50
Fix windows fill metadata dynamic path (#51885)
Fixes #51583
Fixes NEXT-1315
2023-06-27 16:16:24 +00:00
Leah
252c5a6908
make stdout blocking on macos (#51883)
### What?

Node.js sets stdout to non-blocking by default, rust expects it to be blocking

so when logging a lot of data, it can happen that rust receives an error while writing causing it to panic, the error is just that the resource is temporarily unavailable, but rust doesn't handle this case

See https://github.com/napi-rs/napi-rs/issues/1630
2023-06-27 14:55:27 +00:00
Shu Ding
7dfa56c714
Fix missing request body in DELETE and OPTIONS Route Handlers (#51874)
It looks like the `content-length` header can't be ignored for the request forwarded to the render worker. See https://github.com/nodejs/node/issues/27880.

Closes #48096, closes #49310. Fix NEXT-1194
fix NEXT-1114
2023-06-27 11:44:01 +00:00
vercel-release-bot
363b2368b3 v13.4.8-canary.6 2023-06-27 11:04:35 +00:00
Tim Neutkens
1bc2a5009c
Fix white screen when navigating to pages in certain cases (#51866)
## What?

In the first implementation of App Router a year ago I added `return
null` for this case which is incorrect as we have to suspend rendering
when doing a navigation.
The logic in `app-router.tsx` already handles that automatically. The
logic in layout-router is no longer needed as the flightData will be
applied automatically in the reducer.

## How?

Removed the logic when the fetch returns a path to mpaNavigate to.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-06-27 12:31:40 +02:00
Shu Ding
69cbe4cbbf
Optimize client entry creation (#51849)
Removed an unnecessary dependency mapping from the plugin.

Here's a quick visualization of this change. We have to traversal the module graph twice. The first iteration goes through all server modules and creates the client entries. And the second iteration collects info from all client modules.

Before this PR, the second iteration starts from server entries so it traversals both layers. With this PR, the second iteration will start from client entries only:

<img width="870" alt="CleanShot 2023-06-27 at 10 01 08@2x" src="https://github.com/vercel/next.js/assets/3676859/f0b7a0c6-0ade-483a-8645-48e2a8a6c9d0">

This is a ~100ms improvement for HMR of complicate apps.
2023-06-27 09:13:30 +00:00
Zack Tanner
aec75c2f06
fix: build stats should properly report root page size in appDir (#51854)
### What?
`next build` is incorrectly reporting file size stats for the root path
when using the app dir

### Why?
In #50768, the denormalization logic was removed for appDir routes, but
`pagesManifest` has the root page keyed by `/` while the actual path
will be `/index`.

### How?
This re-adds a simpler denormalize function that just replaces `/index`
with `/`.

semi-related: #42819 

Fixes #51692

link NEXT-1306

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-06-26 18:57:50 -07:00
Jiachi Liu
d06bc5e286
perf: only require nextjs-require-cache-hot-reloader related API in dev mode (#51834)
`nextjs-require-cache-hot-reloader` is only required in dev mode for plugin, we can skip these require in production mode

![image](https://github.com/vercel/next.js/assets/4800338/889f98db-7029-4aea-9d12-0e03547be606)
2023-06-27 00:27:35 +00:00
Shu Ding
300507baf0
Enable compression for Webpack's cache during dev (#51851)
This is already the default for production build, but we are also enabling it for development. It has small perf impact as gzip takes time, but it significantly improves the disk usage and time for reading and writing to the filesystem. This is especially the case when working on a large codebase and we are transpiling and bundling more modules now.
2023-06-26 23:16:43 +00:00
Steven
8b60fbc718
fix: webpack target should match node engines (#51852)
The webpack `target` was outdated so I updated to match `engines`. See related https://github.com/vercel/next.js/pull/48941
2023-06-26 22:15:44 +00:00
Ty Hopp
65f94baa83
feat: Introduce eslint rule for async client components (#51547)
The [React Server Component RFC on promise support](https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises.md) indicates that [client components cannot be async functions](https://github.com/acdlite/rfcs/blob/first-class-promises/text/0000-first-class-support-for-promises.md#why-cant-client-components-be-async-functions).

This PR introduces an eslint rule to enforce this.

Fixes #50898
2023-06-26 21:10:24 +00:00
Shu Ding
f1240b8efd
Refactor next-font-manifest-plugin (#51835)
## Background

Currently we're track all imported CSS modules by an entry, in the
client manifest:

```js
// client manifest
{
  entryCSSFiles: {
    'app/entry_name': {
      modules: ['app/foo.css', ...]
    }
  }
}
```

And then, in the font manifest we track all emitted assets (fonts) by
each CSS module:

```js
// font manifest
{
  app: {
    'app/foo.css': [
      'static/font/abc.woff', ...
    ]
  }
}
```

These two fields are only used together by `get-preloadable-fonts.tsx`,
so it can know which font files need to be preloaded for this entry.

(Although previously we use `.modules` for something else, but it's gone
now)

## Changes

Since we only need the font assets per entry, it's unnecessary to track
these in the module level and then join them together. This PR removes
the `modules` field from the client manifest, and changes the font
manifest to directly keep the entry—font mapping.

This gets rid of one module traversal from the client manifest plugin.
2023-06-26 13:43:37 -07:00
vercel-release-bot
57ab2818b9 v13.4.8-canary.5 2023-06-26 16:18:48 +00:00
Jimmy Lai
6238f8a5c0
performance: don't compile on hover on dev (#51830)
An annoying issue that slows down compilation times in dev for Next is
that we might trigger compilation of a page via hover on app.

We do this because we want the same experience in production and dev and
the prefetching is important for instantaneous loading states.

The alternative in this PR is that we don't prefetch at all anymore in
dev but instead, when we handle navigation, we can force a prefetch
navigation.

The slight compromise with this approach is that you can't test
prefetching anymore in dev.


<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

link NEXT-1317
2023-06-26 18:12:59 +02:00
Shu Ding
4b1a0165d3
Simplify Flight manifest plugin (#51589)
Instead of traversing the entire client module graph twice (!), this PR
changes it to only traverse the client **entry** modules only. Because
of the way we create client entries, all client modules' _boundaries_
can be retrieved via all outgoing connections of all chunks' entry
modules, filtered by `next-flight-client-entry-loader`.

This brings down the time complexity from `2 * num_client_modules` to
`num_client_entry_modules`.

Closes #51240.

Additional notes from @timneutkens 

- Removed `module.unsafeCache` as it seemed to be leaking modules across
multiple compilations, this should help with memory usage
- Changed entry-loader to have consistent module import map (sort it) to
ensure cache key is consistent

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-06-26 18:11:08 +02:00
vercel-release-bot
c8f3897fe2 v13.4.8-canary.4 2023-06-26 15:27:18 +00:00
Shu Ding
5b9dd4c47e
Add WATCHPACK_WATCHER_LIMIT=20 (#51826)
Limit the number of Watchpack's watchers to 20 for the routing worker which runs Watchpack. By default this value is 2000 on macOS and 10000 on Windows, which can hold too much resource.
2023-06-26 14:17:44 +00:00
vercel-release-bot
913b365d85 v13.4.8-canary.3 2023-06-26 12:07:28 +00:00
Shu Ding
0dd0ef226c
Fix tree-shaking for metadata image functions on the Edge runtime (#51762)
This PR fixes tree-shaking for the metadata image generation module
(e.g. `opengraph-image.js` and other conventions) when the page has
`runtime = 'edge'`.

## Details

The first step of this fix is to change this from the loader:

```js
import * as exported from "./opengraph-image.js"
```

to be necessary fields only (so the `default` export can potentially be
removed):

```js
import { alt, size } from "./opengraph-image.js"
```

To know which fields are exported, we need to load the module first via
Webpack loader's `loadModule` API and check its
`HarmonyExportSpecifierDependency` dependencies.

This is the first step to make it tree-shakable. Since we have
`./opengraph-image.js` used in another entry, the actual image API route
`opengraph-image/route.js`:

```js
import * as image from "./opengraph-image.js"
```

Webpack still treats both as the same module and generates one chunk for
it. We want to "fork" it into two modules. The technique here is to add
a noop resource query and make it:

```js
import { alt, size } from "./opengraph-image.js?__next_metadata_image_meta__"
```

So it won't be shared in the chunk (as it's a different request), and
can be concatenated inline.

However that's not enough, the inlined result will still have all
imports from our `opengraph-image.js`, including `import { ImageResponse
} from 'next/server'`. Because we can't simply add `"sideEffects":
false` in Next.js' package.json, we need a way to mark this import as
side-effect free. I went through
https://github.com/webpack/webpack/blob/main/lib/optimize/SideEffectsFlagPlugin.js
and used the same method to mark that module with
`module.factoryMeta.sideEffectFree = true`.

With all these added, the page bundle will no longer contain the
`ImageResponse` instance.

## Result

The difference is quite amazing, for the new added test (an empty Edge
runtime page with an opengrah image file) here're the before/after
metrics for the `page.js` server bundle:

Edge bundle size: 892kB → 500kB.
Build time: 26.792s → 8.830s.
2023-06-26 13:44:29 +02:00
Cowboy Ho
70aad4a2b5
Fix NODE_OPTIONS='--inspect' not running expected (#51467)
## Fixing a bug

Fixes #50489
Fixes #48767
Fixes #45697

## What?
When running `NODE_OPTIONS='--inspect' next dev`
Then go to `http://localhost:3000/`
Will display error message `WebSockets request was expected` like the following screenshot
![image](https://github.com/vercel/next.js/assets/14261588/d2f3e520-7cce-40db-be69-99980804cc51)

Also the debug port for app and page still not follow by user input
When `NODE_OPTIONS='--inspect=8000' next dev` the app debug port still `54151`
![image](https://github.com/vercel/next.js/assets/14261588/e3d25c0e-9d00-4767-94d6-d954776912b2)


## Why?
#50248 added a function `getFreePort()` and it used on debug port and HTTP server port
So conflict happen between debug and HTTP port
Then show up error `WebSockets request was expected`

Here are some references about this error:
https://stackoverflow.com/questions/49766500/websockets-request-was-expected-error-when-using-inspect-brk-option


## How?
1. `getFreePort()` should only use on HTTP server
2. Added `getDebugPort()` for read the port from user input
3. Assign port to each worker
4. Add accurate info log for each debug port, e.g.: `proxy`,`router`,`app`,`page`

When `NODE_OPTIONS='--inspect' next dev` 
![image](https://github.com/vercel/next.js/assets/14261588/2260fdff-13fe-435a-9812-984315c0ea2e)

When `NODE_OPTIONS='--inspect=8000' next dev` 
![image](https://github.com/vercel/next.js/assets/14261588/de6e2f2d-9216-481f-b6db-7c5132e97b6f)

Also fix VSCode debugger
It is worth noting that
We can't hit the breakpoint on the first execution
because the file does not exist there yet or was not compiled
In most cases, the breakpoint can only be triggered normally during the second execution
![image](https://github.com/vercel/next.js/assets/14261588/dccded50-46c5-4b6d-beb7-ff0e5324327a)


Closes NEXT-1179
Closes NEXT-517



Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2023-06-25 22:31:09 +00:00
Shu Ding
cb7be1912f
Remove unncessary source matching from loader (#51775)
The same logic is handled by SWC already, and extracted here:

dd937bde09/packages/next/src/build/analysis/get-page-static-info.ts (L68)
2023-06-25 21:58:11 +00:00
Shu Ding
1ec61f76a0
Remove execSync (#51785)
Currently we have an `execSync` in the Telemetry class constructor which
runs at startup even if it might not be needed. This PR changes it to be
non-blocking and makes it lazily loaded.

Before:

<img width="907" alt="CleanShot 2023-06-25 at 16 33 57@2x"
src="https://github.com/vercel/next.js/assets/3676859/b3b1acb6-9968-4a00-9da9-b4b7fa859be3">

Note that all 3 processes (main, app renderer, pages renderer) all have
this.

After:

<img width="956" alt="CleanShot 2023-06-25 at 16 36 52@2x"
src="https://github.com/vercel/next.js/assets/3676859/7ef1973b-bdb2-485d-9336-6f67e13bccff">
2023-06-25 14:06:58 -07:00
Zack Tanner
1b804c0529
fix: interception rewrites should support catch-all segments (#51787)
### What?
Interception route rewrites are not properly parsing catch-all segments,
which leads to "missing parameter name" errors when passed to
`pathToRegexp`.

### Why?
The existing `toPathToRegexpPath` function ignores `...` and keeps it as
part of the regexp path. This means `pathToRegexp` will attempt to
handle `/foo/bar/:...baz` and `/foo/bar/:[...baz]` rather than
`/foo/bar/:baz*`

### How?
The regex used for matching the path was updated to support the dynamic
optional segment, and then we special case catch-all segments

Fixes #51784

---------
2023-06-25 14:02:10 -07:00
Shu Ding
869aeb40ce
Fix HMR for missing dependencies in next-app-loader (#51778)
As noted in the comments, it's necessary to always add optional dependencies as missing dependencies even if they exist because they might be deleted and re-added.

Closes #51763.
2023-06-25 19:26:09 +00:00
Shu Ding
70692d80b4
Rename serverActionsSizeLimit as serverActionsBodySizeLimit and add docs (#51755)
Close the circle after #51104. The name "size limit" can be confusing as it could also mean the size of the Server Action function itself, so this PR changes it to `serverActionsBodySizeLimit` and makes sure it's well documented.
2023-06-24 16:16:09 +00:00
Tobias Koppers
016e3e3c70
revalidate should be more than a boolean (#51627)
### What?

`export const revalidate = 0` should be parse as number
2023-06-24 07:38:39 +00:00
Islam Sharabash
96d540c768
Allow matching against user-agent in rewrites that match headers (#48271)
This adds support for matching against the user-agent header when doing rewrites client side.
Currently a rewrite like this will fail because the user-agent header is not provided, and so next.js tries to prevent infinite rewrites:
```
{
  source: '/:path*',
  destination: 'https://example.com/:path*',
  missing: [
    {
      type: 'header',
      key: 'User-Agent',
      value: '.*(?:Electron).*'
    },
  ],
}
```

Adding in the user-agent header allows this rewrite to pass.
2023-06-24 05:32:11 +00:00
JJ Kasper
2c5cf40377
Fix not-found handling in turbopack (#51735)
Adds the overlay changes from
https://github.com/vercel/next.js/pull/51637

Fixes:
https://github.com/vercel/next.js/actions/runs/5362063391/jobs/9728782834
2023-06-23 21:35:38 -07:00
vercel-release-bot
74a5d2068a v13.4.8-canary.2 2023-06-24 02:20:39 +00:00
Jiachi Liu
e19e9e3ca3
Add critical next config value to github info (#51715)
Adding `nextConfig.output` to next-info output so that we could determine if users're using standalone mode if the reproduction is not clear or missing sometimes

Example output

```
    Relevant Packages:
      next: 13.4.8-canary.1
      eslint-config-next: 13.4.8-canary.1
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3
    Next.js Config:
      output: standalone
```
2023-06-24 00:07:07 +00:00
Zack Tanner
c98d2b927d
fix: handle 404 errors in HotReload client (#51637)
### What?
In dev mode, routing to a 404 page will result in an infinite redirect
cycle. This PR is an attempt to bring back similar functionality
currently implemented in the [pages
router.](https://github.com/vercel/next.js/blob/canary/packages/next/src/client/dev/on-demand-entries-client.ts#L41-L59)

### Why?
When the `pong` event (emitted from `onHMR`) occurs on a page that
doesn't exist, it will result in frequent calls to
`router.fastRefresh()`. Because the server response is an error, it'll
trigger a mpa navigation
[here](61ab4aadec/packages/next/src/client/components/router-reducer/fetch-server-response.ts (L115-L117)),
which is treated as an external route
[here](61ab4aadec/packages/next/src/client/components/router-reducer/reducers/fast-refresh-reducer.ts (L45-L53))
(and thus the window is reloaded)

In the case where you're on the page and it goes away, since we don't
have access to `__NEXT_DATA__`, I opted to use the dispatcher which will
trigger the parent `NotFoundBoundary`. This part felt a little awkward
-- I'm open to suggestions on a better way to handle this.

Closes NEXT-1299
Fixes #50585

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-23 16:30:48 -07:00
최지원
a9870df101
feat: add body parser limit for server actions (#51104)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?
Add configuration options to modify the `bodyParser` size as it used to
be available in Page Router.
### Why?
Server Actions "Error: Body exceeded 1mb limit" cannot be resolved since
the body-parser limit size is hardcoded to `1mb`.
### How?

Closes NEXT-
Fixes #

-->

### What?

Add configuration options to modify the `bodyParser` size as it used to
be available in Page Router for APIs.

```js
export const config = {
  api: {
    responseLimit: false | '8mb' 
  },
}
```

Reference: [API Routes Response Size
Limit](https://nextjs.org/docs/messages/api-routes-response-size-limit)

### Why?

Server Actions "Error: Body exceeded 1mb limit" cannot be resolved since
the body-parser limit size is hardcoded to `1mb`.

```js
// /packages/next/src/server/app-render/action-handler.ts

// ...
const actionData = (await parseBody(req, '1mb')) || ''
// ...
```

Reference:
https://github.com/vercel/next.js/blob/canary/packages/next/src/server/app-render/action-handler.ts#L355
### How?

- Added option "serverActionsLimit" as `SizeLimit` type to
`config-shared.ts`
- Modified `action-handler.ts` to validate `serverActions` &
`serverActionsLimit` options in nextConfig
- Added conditional `serverActionsLimit` value and `1mb` if falsy

**Working on testing**

Fixes #49891 | #51097 | #51099

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Shu Ding <g@shud.in>
2023-06-23 16:24:18 -07:00
JJ Kasper
916e21f913
Update manual basePath with trailingSlash (#51726)
With the manualBasePath config we still need to normalize the trailing
slash per that config.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1687543336964799?thread_ts=1687487533.019499&cid=C03S8ED1DKM)
2023-06-23 15:36:16 -07:00
Shu Ding
ae4a723446
Correct Flight client's condition for SSR and createServerReference (#51723)
This PR addresses a problem where the `createServerReference` is using
the default condition of flight client (gets resolved to the Node
build), but we use the Edge build of flight client for SSR. This causes
2 flight clients to exist during SSR.
2023-06-23 23:57:50 +02:00
Adam Mcgrath
fda1ecc31e
Add url to patched fetch response (#51665)
### What?

Add `url` property to response returned from patched fetch

### Why?

So that libraries that rely on `response.url` work with the app directory and fetch cacheing

### How?

Using the same code as https://github.com/vercel/edge-runtime/blob/edge-runtime%402.4.3/packages/primitives/src/primitives/fetch.js#L164

fixes #51642 

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-06-23 21:53:17 +00:00
Wyatt Johnson
bc05ce921a
Move Pages render out of server (#51678)
This removes calls for rendering files in `pages/` via the server code and relies instead relies on the bundled `routeModule` to perform the rendering.

Future cases that try to call the legacy render will hit a new: 

```
Invariant: render should have used routeModule
```

Error. These cases should be reported.
2023-06-23 20:22:43 +00:00
Tim Neutkens
0a4b6ef810
Add default modularizeImports that breaks up lucide-react, mui/icons-material, lodash, react-bootstrap (#50900)
## What?

Adds a default modularizeImports that ensures `lucide-react`, `@mui/icons-material`, `lodash`, and `react-bootstrap` do not cause a massive amount of modules to be compiled in development.
For example `@mui/icons-material` re-exports 10600 (10K+) modules from a single file. Even though it does not affect production bundle size it does affect build time, especially in development, and even more so when your filesystem is slow (e.g. what we're seeing on Windows). 

Related issue: #48748 (not closing)




Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2023-06-23 19:53:58 +00:00
Leah
5d54eaaf18
type check tests (and convert next-test-utils.js to ts) (#51071)
Enables type checking for tests in CI and fixes a bunch of things related to that
2023-06-23 17:42:50 +00:00
JJ Kasper
d457e989ff
Revert "Update swc_core to v0.78.15" (#51716)
Reverts vercel/next.js#51269

This is breaking some builds it looks like

x-ref: https://github.com/vercel/next.js/actions/runs/5357843108/jobs/9719367732
x-ref: https://github.com/vercel/next.js/actions/runs/5357843108/jobs/9719368519
2023-06-23 17:12:47 +00:00
이현재
889e2203a5
Update page.tsx tw className (#49040)
I changed the tailwindcss code, which is written differently than the
other elements in `app/page.tsx`

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Co-authored-by: Shu Ding <g@shud.in>
2023-06-23 17:11:59 +02:00
Donny/강동윤
5f3d7c43ea
Update swc_core to v0.78.15 (#51269)
### What?

Update SWC crates to 8b765e6763

### Why?

There were many patches.

### How?

Closes WEB-1174

Turbopack counterpart: https://github.com/vercel/turbo/pull/5288
2023-06-23 11:40:11 +00:00
Tobias Koppers
5abeb99b49
add edge rendering for app dir for Turbopack (#51666)
relanding #50830 and #51631 

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5254 <!-- OJ Kwon - ci(workflow):
upload daily next.js test trace -->
* https://github.com/vercel/turbo/pull/5363 <!-- Tobias Koppers -
disable default features for turbopack-ecmascript-plugins -->
2023-06-23 07:08:17 +02:00
vercel-release-bot
d0a1e64962 v13.4.8-canary.1 2023-06-22 23:16:54 +00:00
Jiachi Liu
16eb80b0b0
Fix standalone rendering for unmatched _next routes (#51611)
Request data flow in the server

```
request ---> router worker (1) ---> ipc ---> render worker app (2)
                                                              |-----> render worker pages (3)
```

When it's hitting `_next/*` unmatched routes in standalone server, it will render 404, but when you hit `_next/*` it will render app not-found as the app router is always enabled, but router worker isn't set up with require-hook for proper built-in react version, then the app-render will fail with `./server.edge` exports not found error.

We detect if it's in the render worker, then do the app paths rendering instead of directly looking up for app paths in route worker. This could avoid unexpected accesses to the app-render

Fixes #51482 
Fixes #50232
Closes #51506
Reverts changes in #51172
fix NEXT-1260
2023-06-22 22:58:04 +00:00
Jiachi Liu
89f36a98bc
Hot reload when conflicted pages detected and when conflicts are resolved (#51516)
When conflicted pages occur between app and pages server used to throw error and you need to solve the conflicts and restart the server.

This PR capture the error during files aggregation, and send to client to display the error for files confliction. This will send all the conflicts to client and it will still error until you solve all of them. But since the server is not stuck by errors, client can recover once the error is solved.

Closes NEXT-1283
2023-06-22 22:32:14 +00:00
Jiachi Liu
db4b9858ca
Add esm entry for next/server and alias @vercel/og (#51651)
The next-metadata-route-loader emitted content with `"next/server"` is still using cjs version which is not get tree-shaked on edge runtime, This PR adds a new esm entry for it and mapped it that on edge runtime so unused exports can be tree-shaked. This case happened when users are using ImageResponse from `"@vercel/og"` instead of `"next/server"`.

2nd change is adding another alias to map `@vercel/og` package to vendored og package inside next.js, this way we could merge the two package instead of bundled both of them


Fixes: NEXT-1303

changed `require.reoslve("next/dist/xxx")` to `${NEXT_PROJECT_ROOT}/xxx}` to avoid to be traced by nft.
2023-06-22 21:34:12 +00:00
JJ Kasper
f749684921
Update cache handling in draft mode (#51663)
Similar to `getStaticProps` when draft mode is enabled we should bypass
the cache so fresh data is shown.

x-ref: [slack
thread](https://vercel.slack.com/archives/C052BQ8F9EJ/p1687440125828479?thread_ts=1684336597.437409&cid=C052BQ8F9EJ)
and
[tweet](https://twitter.com/tomus_sherman/status/1669023879656873988)

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-06-22 14:03:11 -07:00
vercel-release-bot
554e58c31a v13.4.8-canary.0 2023-06-22 18:19:20 +00:00
JJ Kasper
d0e7d04dc5
Revert "add edge rendering for app dir for Turbopack" (#51659)
Reverts vercel/next.js#51631

This breaks the windows builds

x-ref:
https://github.com/vercel/next.js/actions/runs/5344032749/jobs/9687974376
x-ref:
https://github.com/vercel/next.js/actions/runs/5344032749/jobs/9687973522
2023-06-22 08:49:50 -07:00
Wyatt Johnson
5871b0d6d7
Pages Error Route Module Rendering (#51374)
Continuing on changes to move the rendering logic into the bundles.

- Unifies edge render functions: `appRenderToHTML` and `pagesRenderToHTML` becomes `renderToHTML`
- When an error occurs, the error module's match is used so the module's internal render can be used (easing transition away from using the server's render method)
- Improved test resiliance
2023-06-22 15:13:13 +00:00
Tobias Koppers
99ec3057d7
add edge rendering for app dir for Turbopack (#51631)
## What

* reland #50830 
* remove Object.hasOwn
* fix CSS chunks in edge runtime

## Turbopack Changes

* https://github.com/vercel/turbo/pull/5253 <!-- OJ Kwon -
fix(turbopack): enable runtime flag -->
* https://github.com/vercel/turbo/pull/5295 <!-- Will Binns-Smith -
remove `__internal_nextjs_integration_test` compile-time feature -->
* https://github.com/vercel/turbo/pull/4362 <!-- Donny/강동윤 - Make build
faster -->
* https://github.com/vercel/turbo/pull/5352 <!-- Tobias Koppers - only
wait for JS chunks in none runtime backend -->
2023-06-22 11:43:59 +02:00
Zack Tanner
6f61fb4068
bugfix: route interception with dynamic paths (#51526)
### What?
Paths with interception markers adjacent to dynamic segments are not correctly parsed, which leads to the path match logic failing. 

### Why?
`getParametrizedRoutes` checks for brackets but isn't expecting to receive an interception marker. For example, a path of `/photos/(.)[author]/[id]` results in the following regex:
`/^\/photos\/\(\.\)\[author\]\/([^/]+?)(?:\/)?$/`

This will not match a path of `/photos/(.)zack/1` since it retained the `[author]` brackets.

`getSegmentParam` has a similar issue when getting values for path params, though we can just skip the interception markers and go straight to the params.

Closes NEXT-1166, NEXT-1013
Fixes #48143
Fixes #49614

link NEXT-1013
2023-06-22 09:43:24 +00:00
Alex Kirszenberg
c6313606c9
Next Build Turbo POC (2) (#51546)
Another attempt at getting https://github.com/vercel/next.js/pull/49942 in.

This time, the mold install step is gated to Linux.
2023-06-22 08:03:44 +00:00
Justin Ridgewell
b714ac55c1
Support response aborting (#51594)
### What?

This is an alternative to #51330, which only support aborting the response (doesn't support back-pressure). If the client cancels the request (HMR update, navigates to another page, etc), we'll be able to detect that and stop pulling data from the dev's `ReadableStream` response.

### Why?

We want to allow API routes to stream data coming from another server (eg, AI services). The responses from these other servers can be long running and expensive. In the case the browser aborts the connection, it's critical that we stop streaming data as soon as possible.

### How?

By checking whether `response.closed` is set during the `for await (…)` iteration, we're able to detect that the client has aborted the connection. Cleanup of the `ReadableStream` is handled implicitly by the async iterator when the loop ends.

The one catch is our use of http-proxy for worker processes. It does not properly detect a client disconnecting (but does handle back-pressure). In order to fix that, I've manually added event listeners to detect the disconnect and cancel the proxied req/res pair.

Re: [WEB-1185](https://linear.app/vercel/issue/WEB-1185) (we still need back-pressure)
Fixes https://github.com/vercel/next.js/issues/50364
Fixes https://github.com/vercel-labs/ai/issues/90
2023-06-22 00:43:31 +00:00
Yash Singh
f59710e907
feat: support for numeric separators in revalidate config (#51438)
### Fixing a bug

- [x] Related issues linked using `fixes #number`
- [x] Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- [ ] Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### What?

Currently, when the check on validating the type of `revalidate` is run,
we use the `Number` function to parse the value of `revalidate`, however
the `Number` function takes a
[`StringNumericLiteral`](https://tc39.es/ecma262/2023/#prod-StringNumericLiteral)
which doesn't allow the usage of the `_` separator to format your
numbers. This PR allows you to add numeric separators in the
`revalidate` export.

### Why?

When configuring the actual code, we should be allowed to use numeric
separators as it is a syntax that is supported by most runtimes.

### How?

A simple `replaceAll` call that removes all `_`s between digits.

Closes NEXT-1122
Fixes #49485

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-21 17:22:29 -07:00
Andrey Krasovsky
2cae83d0f2
fix(typo): rename var name in comment (#51531)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-21 16:01:46 -07:00
Wyatt Johnson
77ef61ea35
Route Module Updates (#51433)
Small QOL improvements to `RenderResult` and `RouteModule` setup. This
also adds a test to verify that headers aren't sent on responses that
have already been sent.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-21 15:30:24 -07:00
Jiachi Liu
f2263f0a6c
Auto fill title/images/description from openGraph for twitter if missing (#51453)
Follow up: #50854 
x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1687016097811079)

---------
2023-06-21 15:19:22 -07:00
vercel-release-bot
4e5fef4f36 v13.4.7 2023-06-21 21:12:57 +00:00
vercel-release-bot
6dd06dbe4d v13.4.7-canary.4 2023-06-21 20:38:43 +00:00
Shu Ding
a0cc4aa65e
Revert "Fix standalone not found" (#51506)
Reverts vercel/next.js#51172

Fixes #51482.
2023-06-21 13:15:05 -07:00
vercel-release-bot
c30f21fa77 v13.4.7-canary.3 2023-06-21 18:59:34 +00:00
JJ Kasper
9d043f6e35
Ensure upgrade request has request meta (#51590)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1686906407341689)
2023-06-21 11:52:12 -07:00
Tobias Koppers
343438ff3b
Revert "add edge rendering for app dir for Turbopack" (#51617)
Reverts vercel/next.js#50830
2023-06-21 10:34:55 -07:00
Tobias Koppers
36a7aff6d6
use env var to switch next.js to turbopack mode (#51353)
### What?

this forces all tests to use turbopack independent of the way they invoke next dev

### Why?

some tests were not running turbopack

fixes WEB-1187
2023-06-21 13:52:14 +00:00
Jimmy Lai
bc9ed9de98
router: support layout/special files as direct children of parallel routes (#51604)
follow up on #51413 where I kinda forgot to support parsing layout files in sub routes in a parallel segment.

This should fix it by making sure that we check at all level of the app loader tree and by creating an implicit inner `children` for all parallel slot



link NEXT-1301
2023-06-21 11:16:21 +00:00
JJ Kasper
f6998e30a8
Update id env prefix (#51588)
Removes `__` prefix and ensures it's available on client/server as
expected.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04TNLL0LSK/p1687197571572119)
2023-06-20 16:41:28 -07:00
Joshua Baker
2d2180f43d
Moved new line to warnOnce call (#51552)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What/Why

The `console.log` call was running per request and polluting logs.

### Locally

```
$ next start
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- info Loaded env from /next/.env.local

- warn metadata.metadataBase is not set for resolving social open graph or twitter images, fallbacks to "http://localhost:3000". See https://nextjs.org/docs/app/api-reference/functions/generate-metadata#metadatabase














^C
```

### Vercel

<img width="352" alt="Screenshot 2023-06-20 at 12 08 56@2x"
src="https://github.com/vercel/next.js/assets/160484/dee72cd3-aa4e-46d8-886f-9476b9345498">

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-20 16:13:45 -07:00
vercel-release-bot
3d23faa6cd v13.4.7-canary.2 2023-06-20 22:12:57 +00:00
Shu Ding
3847592e44
Add docs links to RSC errors (#51557)
When working with React Server Components, it's essential to have a
clear understanding of how they function and how to troubleshoot any
errors that may arise. This PR adds links to our documentation whenever
an error related to React Server Components occurs.
2023-06-20 23:40:15 +02:00
Zack Tanner
b32c1ea12d
fix typo in x-next-revalidate-tag-token header (#51432)
### What?
While looking into some things related to the FileSystemCache, I came
across this typo introduced in #49227. Not sure how it's currently
manifesting but figured it'd be worth correcting
2023-06-20 08:30:22 -07:00
Jiachi Liu
fc172eeac1
Fix font styles on react dev overlay (#51518)
Fixes font styles change introduced in #49782

### Visuall Diff - After vs Before

<img src="https://github.com/vercel/next.js/assets/4800338/92f6af3a-9728-4dc5-b3d0-b21eefd16164" width="400">
<img src="https://github.com/vercel/next.js/assets/4800338/df88c9dd-b710-4a0a-a1aa-131adb55efa6"  width="400">
2023-06-20 11:36:29 +00:00
JJ Kasper
41ce805de5
Revert "Next Build Turbo POC (#49942)" (#51538)
This reverts commit 7d0bdab83e.

This is failing all builds blocking releases so this reverts it for now
to allow further investigation async.
2023-06-19 21:54:04 -07:00
Shu Ding
30bb252434
Fix shared action module in two layers (#51510)
Currently an "action module" (files with `"use server"` on top) can be
imported by both the server and client layers. In that case, we can't
fork that action module into two modules (one on the server layer, one
on the action layer), but only create it once on the server layer.

This ensures that the action module instance doesn't get forked.

Closes #50801.
fix NEXT-1265
2023-06-19 21:45:51 +02:00
Tobias Koppers
5e51c08f83
add edge rendering for app dir for Turbopack (#50830)
### What?

* allow to use `runtime = "edge"` for app dir in turbopack
* move common imports from next-app-loader to
`packages/next/src/server/app-render/entry-base.ts`
* move common turbopack code to communicate between JS and Rust into
separate files

### Why?

A lot test cases depend on edge rendering

### How?

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
2023-06-19 19:28:41 +02:00
Alex Kirszenberg
7d0bdab83e
Next Build Turbo POC (#49942)
This contains the original POC for `next build --turbo`. The implementation is _just enough_ to get pages building, and doesn't support the app router yet.

I'll write more details here on the implementation and what the next steps are next week.

Necessary changes on the Turbo side: https://github.com/vercel/turbo/pull/4998
2023-06-19 14:36:05 +00:00
Jimmy Lai
5b7b91f3c5
router: add layout and other file supports to parallel routes (#51413)
This PR fixes a bug in which the layout files were not picked up if they were direct children of a parallel route slot.

Note: there's a bunch of other files that I've used for debugging that are not used for the test but I'm leaving them for future me.




link NEXT-969
2023-06-19 12:35:41 +00:00
Jiachi Liu
bd466842a0
Fix pnpm lock (#51503)
Reverting unexpected pnpm-lock changes from a3ef99acd9
2023-06-19 11:48:41 +00:00
vercel-release-bot
a3ef99acd9 v13.4.7-canary.1 2023-06-16 13:57:51 +00:00
Shu Ding
46981388aa
Fix bundling of Server Actions (#51367)
There're 3 layers in the RSC module graph: server → client → action. "Action" means that a Client Component re-enters the server layer by importing a file with `"use server"`, and it should behave the same as the server layer but you can't enter the client layer again (hence we have a 3rd layer name).

Since the action layer has the same behavior and module resolution rules, it should be bundled just like the server layer.

Closes #50658. Originally the issue was that `auth/next` isn't being bundled on the action layer, and it has the async local storage imported. Because of that, that storage comes from node_modules instead of the server bundle.
fix NEXT-1290
2023-06-16 13:47:48 +00:00
JJ Kasper
1528a49bf1
Revert "Route Module Updates Redux" (#51409)
This appears to still be hitting the previous issue mentioned in
https://github.com/vercel/next.js/pull/51322

Reverts vercel/next.js#51373
2023-06-16 05:44:03 -07:00
vercel-release-bot
cbb69b2cfc v13.4.7-canary.0 2023-06-16 01:02:52 +00:00
JJ Kasper
da98193602
Lock down server IPC address (#51378)
This attempts to avoid IPv6 and IPv4 resolve issues across network
setups by locking down our internal IPC requests to just one address for
consistency. This way there aren't issues when `localhost` resolves to
one or the other in different cases.

x-ref: https://github.com/vercel/next.js/issues/49677
2023-06-15 17:58:10 -07:00
Wyatt Johnson
ab3f707eff
Route Module Updates Redux (#51373)
Small QOL improvements to `RenderResult` and `RouteModule` setup.
2023-06-15 22:45:49 +00:00
vercel-release-bot
ce4aa787e8 v13.4.6 2023-06-15 21:21:35 +00:00
vercel-release-bot
019ed1c39b v13.4.6-canary.8 2023-06-15 20:08:03 +00:00
Shu Ding
7d7d5a762d
Fix shared layer bundling in Edge Runtime (#51348)
Our shared layer matcher doesn't contain `next/dist/esm`, which breaks Server Actions when there're cookie/header accesses.

Closes #50099. Fix NEXT-1229
2023-06-15 13:03:51 +00:00
Tobias Koppers
a806f1ad84
Update turbopack (#51336)
### What?

update Turbopack and sync dependencies with turbo

### Turbopack changes

* https://github.com/vercel/turbo/pull/5303
2023-06-15 09:39:17 +00:00
vercel-release-bot
c59c39a431 v13.4.6-canary.7 2023-06-15 03:58:41 +00:00
JJ Kasper
bdcca0ccff
Fix CSS deploy id case (#51325)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04MEB9L9RQ/p1686787663510239?thread_ts=1686770561.895939&cid=C04MEB9L9RQ)
2023-06-14 20:28:18 -07:00
mknichel
1660fdfcbb
Update Next.js code owners (#51319)
This PR updates `.vercel.approvers` files to fix some validation errors
and to more closely match desired behavior for assigning and notifying
members of the team for reviews that was discussed on an internal Slack
thread.

- Owners files for `.cargo/` and `.config/` are moved to their
respective directories instead of being placed at the root.
- Fixes the `@vercel/next-js` team name (it uses a dash instead of a
period)
- Adds `:notify` to reviewers so that all of the people listed are
notified of the pull request, but only a single person would be
requested as a reviewer.
- `@vercel/web-tooling:optional` was made optional so that they are not
requested for any change to `pnpm-lock.yaml` but still have the ability
to approve PRs that modify it.

---------
2023-06-14 20:07:32 -07:00
JJ Kasper
f9ae5b7f31
Revert "test(next-dev): hard fail if next-dev runs with turbopack intenral flag" (#51327)
Reverts vercel/next.js#51308
2023-06-14 20:06:55 -07:00
OJ Kwon
a7c31cc509
test(next-dev): hard fail if next-dev runs with turbopack intenral flag (#51308)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Run `pnpm prettier-fix` to fix formatting issues before opening the
PR.
- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md


## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

WEB-1183

Context:
https://vercel.slack.com/archives/C04KC8A53T7/p1686768648161459?thread_ts=1686763527.218549&cid=C04KC8A53T7

We'd like to avoid false positives to the test cases if test supposed to
run turbopack (having __INTERNAL_ flags) but somehow test fixture does
not run turbopack correctly.
2023-06-14 19:29:59 -07:00
vercel-release-bot
dde67aec5a v13.4.6-canary.6 2023-06-15 01:39:48 +00:00
JJ Kasper
2e68ff7dc0
Revert "Route Module Cleanup" (#51322)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04MEB9L9RQ/p1686788708114089?thread_ts=1686770561.895939&cid=C04MEB9L9RQ)

Reverts vercel/next.js#50936
2023-06-14 18:30:14 -07:00
Shu Ding
38d1f1699d
Fix Server Actions compiler (#51318)
Make sure we are using `var` instead of `const` as we always put the new
appended statements to the end of the module body, but they can still be
referenced before in the HOC case in the runtime. This causes a runtime
error.

Tl;dr: `a = 1; var a` is fine, but `a; const a = ...` will result in a
compilation error.

Closes #49344.
2023-06-14 17:01:05 -07:00
JJ Kasper
409668107d
Revert "Prefer module fields for RSC server layer" (#51316)
Closes: https://github.com/vercel/next.js/issues/51309

Reverts vercel/next.js#51179
2023-06-14 16:55:38 -07:00
JJ Kasper
115b6ad953
Allow configuring analyzerMode in bundle-analyzer (#47468)
It's valid to want to output JSON instead of HTML for the bundle
analyzer so we can expose this specific config the same as
`openAnalyzer`. cc @mknichel
2023-06-14 16:33:39 -07:00
vercel-release-bot
40ce621901 v13.4.6-canary.5 2023-06-14 21:54:03 +00:00
Shu Ding
9a36f337da
Simplify server CSS handling (#51018)
Remove the Server CSS manifest and related logic, and use the chunkGroup
CSS files instead for each entry to inject stylesheet links.

Why was that manifest needed in the first place? When implementing CSS
collection for RSC and nested layout initially, we collect CSS imports
at each layer and create corresponding client entries. But then soon got
hit by the problem of duplication and improper tree-shaking. Two layers
can have the same CSS imported so we solved it in a way that "if an
upper layer imports this module, skip it in child layers". Note that
this is deduped by module, so we need to keep the information of "layer
(entry) → CSS modules" somewhere, in a manifest.

Another reason is that we create the client entry before Webpack
optimizes modules, so we can inject the client entry into the same
compilation. But that means the collected client modules from the server
layer are not properly optimized (DCE). **This is a general issue at the
moment that's not specifically related to CSS, although using that
manifest to collect DCE'd info and join the original collected CSS files
with that info temporarily solved it.** That's why I disabled some tests
related to font CSS collection and want to improve it in a more general
way.

Why is that not needed anymore? Main reason is to keep a good balance
between duplication and number of chunks, and delegate the decision to
Webpack's splitChunks plugin. It is not possible to get to a point of 0
duplication unless we ship every CSS module as a single chunk. And since
in #50406 we made the duplication better but at the chunk asset level,
instead of the original module level.

Prior work: #50406, #50610.
2023-06-14 14:43:08 -07:00
mPaella
d492b937e2
fix: Incorrect build size outputs for app dir (#50768)
### What?
Fixes https://github.com/vercel/next.js/issues/50129

### Why?
The current denormalization of app dir paths doesnt account for the
normalization done in `normalizeAppPath`, causing build log outputs for
certain paths such as anything under a route groups to be incorrect

### How?
There's 2 ways this could be fixed:

1.) Denormalize the app dir paths by reading the
`app-path-routes-manifest.json` and mapping back to the original file
path
2.) (what I chose to do) Normalize the keys of `appBuildManifest`

### Result

App dir paths, including route groups, now have their correct output
size

<img width="494" alt="image"
src="https://github.com/vercel/next.js/assets/93682696/0eee79b8-7d60-4c88-b07a-dfb750aa9592">

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-14 14:24:57 -07:00
bri
c76653f2f7
chore: update next/font/google font list (#49969)
Ran script `update-google-fonts`, adding these fonts to `next/font/google`:

- [Instrument Sans](https://fonts.google.com/specimen/Instrument+Sans)
- [Noto Sans Nag Mundari](https://fonts.google.com/noto/specimen/Noto+Sans+Nag+Mundari)
- [Wix Madefor Display](https://fonts.google.com/specimen/Wix+Madefor+Display)
- [Wix Madefor Text](https://fonts.google.com/specimen/Wix+Madefor+Text)

and updating these fonts:
- [Radio Canada](https://fonts.google.com/specimen/Radio+Canada) (added `canadian-aboriginal` subset)

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-06-14 21:03:44 +00:00
tom
d4c2335b0f
chore: add dark mode for dev overlay (#48601)
This PR adds a dark mode to the error overlay which respects the browsers color scheme.
I just did this because I was blinded by the dev overlay a lot today and thought this change might be appreciated.

Screenshot (dark mode):
<img width="2056" alt="image" src="https://user-images.githubusercontent.com/17279485/233201837-0d005e10-d73f-4ddd-9f4a-285829ec63b1.png">
 
Screenshot (retained light mode):
<img width="1064" alt="image" src="https://user-images.githubusercontent.com/17279485/233202019-83ec79d8-d2ca-44c8-bc0a-7696355dfe72.png">


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-06-14 20:33:07 +00:00
JJ Kasper
916d2aa4d5
Validate i18n locale domain (#50220)
The `domain` value is meant to be a hostname and not include `http` or
port so this ensures we validate it doesn't contain `:` unexpectedly
causing invalid behavior.

Closes: https://github.com/vercel/next.js/issues/49656
x-ref:
https://github.com/vercel/next.js/issues/24991#issuecomment-870418366

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-06-14 11:07:58 -07:00
Wyatt Johnson
616ae108d9
Route Module Cleanup (#50936)
This cleans up some setup functions within the route modules, improves logic around headers, and handles the case where the URL is invalid better for routes using the request adapters.
2023-06-14 17:54:23 +00:00
OJ Kwon
2761cf34fa
feat(turbopack): enable sassOptions (#51259)
### What?

Minor fix to remove guards to the config since turbopack have this feature enabled.
2023-06-14 17:27:04 +00:00
Shu Ding
754c6480cb
Invalidate client cache when cookies have changed in Server Actions (#51290)
Similar to tags and paths, when `cookies().set()` is called we have to
invalidate the client router cache as well so routes with
`cookies().get()` will not holding the stale data. This is critical for
auth and other scenarios.

In the future we can have an optimization to only invalidate routes that
actually rely on cookies, similar to paths.
2023-06-14 17:26:27 +02:00
Jimmy Lai
c6c4a3d3eb
app router: fix double fetch on prefetch={false} (#51292)
This PR fixes a few reports that we were double fetching when navigating via a link that had prefetch false.

## Context

The bug was happening because we were inadvertently eagerly fetching even if we potentially bailed out of the optimistic navigation, which would then trigger another fetch from going through the regular navigation path.

There's potentially another bug here where we should potentially not bail out of optimistic navigation in the cases reported but we can fix that later.



fix #49844
link NEXT-1287
2023-06-14 13:42:14 +00:00
vercel-release-bot
cbeecba83b v13.4.6-canary.4 2023-06-14 11:21:24 +00:00
Tim Neutkens
dd937bde09
Remove edge functions tracking in dev server (#51122)
## What?

While looking at the CPU profile of booting up Vercel's site I noticed
that we call `getPageStaticInfo` a lot. Looking into this more it turns
out `getPageStaticInfo` is currently called for all routes, `pages` and
`app`, even though the data is only being used to keep track of which
routes are edge functions, however, this is already tracked as part of
the build output so this didn't make sense to me. First I tried
commenting out this entire block and all tests were passing, so I
removed it except for middleware as middleware can provide a `matcher`
which does need to be known before compiling the file as of right now.

After that change a different set of tests started failing, specifically
the one that checks if we warn correctly. Interestingly by fixing
`getPageStaticInfo` being called early and for all routes it also caused
these warnings to no longer trigger as there was a case in the manifest
plugin that called `getPageStaticInfo` with less information. Calling
`getPageStaticInfo` there was not needed either as we call
`getPageStaticInfo` at the beginning of the build for each entrypoint so
we already have the information required, it just had to be passed down
so that the manifest plugin could use it.

For Vercel's site this change improves booting the dev server by over 1
second.

Related to #48748

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation

- Read the Docs Contribution Guide to ensure your contribution follows
the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

### Adding or Updating Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2023-06-14 13:17:16 +02:00
vercel-release-bot
c8f65ede87 v13.4.6-canary.3 2023-06-14 06:52:30 +00:00
JJ Kasper
f676d001b6
Correct build workers perf issue (#51271)
This continues off of https://github.com/vercel/next.js/pull/49937 and
https://github.com/vercel/next.js/pull/50194 ensuring we don't regress
on build perf due to reducing the amount of workers being used in
parallel.

Fixes: https://github.com/vercel/next.js/issues/51201
Fixes: https://github.com/vercel/next.js/issues/50555
2023-06-13 23:23:50 -07:00
Joost De Cock
667a90262b
[docs] Clarify .md handling with @next/mdx (#49785)
…iles as MDX

I got bitten by this passage because it reads as if merely changing the
`extension` setting will cause `.md` files to be loaded as MDX.

See: https://github.com/mdx-js/mdx/issues/2302

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 22:53:04 -07:00
Riqwan Thamir
825eefe7c0
Add mikroORM to external package list (#50487)
### What?

Adds mikroORM to external package list

### Why?

To prevent developers using
[MedusaJS](https://github.com/medusajs/medusa) modules with NextJS from
having to add this in their next config.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 22:49:50 -07:00
Choi Sumin
8ac9b342e3
chore(router): fix typo in comment (#50581)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->


### What?

fix typo in comment (withRoute -> withRouter)
2023-06-13 21:10:36 -07:00
Baffin Lee
2bd76827f0
Fix build error about trace file and edge route (#50808)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

### What?

Error occurs when processing trace file rules of edge route.

### Why?

Edge routes have no trace files, so we don't need to process exclude and
include rules about it's trace file.

### How?

Fixes https://github.com/vercel/next.js/issues/50791

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 21:04:10 -07:00
Zack Tanner
3427d324d8
fix: app router hash scrolling should respect scroll-padding (#51268)
When navigating to a route with a hash parameter, the layout router
jumps to the element by scrolling to the node's `offsetTop` value.
However, this will ignore `scroll-padding`, which deviates from browser
behavior.

It looks like this isn't an issue in the pages router which currently
makes use of
[`scrollIntoView`](https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/router/router.ts#L2262).

Closes NEXT-1171
Fixes #49612

---------
2023-06-13 20:50:51 -07:00
Baffin Lee
4ef3982f62
chore: remove useless duplicate code (#50705)
<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

## What?

Remove useless duplicate code in `next-server.ts`, there are exactly the
same code in next lines.

## Why?

That code have no side effect, run it twice won't make any difference,
seems like someone forgot to delete it.


![image](https://github.com/vercel/next.js/assets/17738556/848d4b03-78cd-40a4-ae8b-a3126101efac)

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 20:38:01 -07:00
Willem-Jaap
0bda6287b6
fix(cli): add all available options to cli commands, format them consistently (#48708)
### What?
Add all available options to cli commands
Consistent formatting for all options

### Why?
Options were not consistent across all commands, some were missing



Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-06-14 02:36:08 +00:00
Michael Novotny
94accfacf1
Adds homepage to eslint-config-next package (#51059)
Fixes (partially) #50843.

---------

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-13 11:22:05 -07:00
Delba de Oliveira
3d41ccb916
Update codeowners (#51250)
Tweak code owners after some testing and feedback. 

- Move the Next.js team up to be optional global code owners (so that everyone can review but are not tagged for review). Global individuals should still be tagged if there are no specific `.vercel.approvers` files in subdirectories.
- Adds @vercel/devex to image files so there's coverage on those files for the docs
- Target specific folder and files for Styfle to get notified
- Deletes some rules in the old GitHub codeowners
2023-06-13 17:47:12 +00:00
Will Binns-Smith
8f4ae065e0
Turbopack: remove __internal_nextjs_integration_test compile-time feature (#51204)
This removes the `__internal_nextjs_integration_test` compile-time feature. This would end up requiring an additional set of build targets for running integration tests was only used for two cases:

* Determining whether to read from an env var to load mocked Google fonts responses in next/font/google tests. This now uses the presence of this variable to determine whether to use mocked responses.
* Enabling the `next-dev/serializable` feature. This is now set directly instead.

Test Plan:
* Integration tests with Turbopack.
* Manual test of next/font/google with Turbopack
2023-06-13 16:26:44 +00:00
Jiachi Liu
6e5169b17a
Add buildId into RSC payload (#50974)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2023-06-13 17:58:07 +02:00
Shu Ding
9ffea84080
Simplify the client manifest structure (#51183)
Both of our bundlers won't split different exports of a module into different chunks, we can rely on https://github.com/facebook/react/pull/26624 to simplify the structure. This reduces the size of the client reference manifest by ~70%.
2023-06-13 15:25:39 +00:00
Sora Morimoto
0840793abf
Fix all 404 links (#51209)
I found some 404 links in jsdoc, so I used ripgrep to find and fix all the broken links to fix all the other links in this PR.
2023-06-13 14:25:40 +00:00
vercel-release-bot
b80dc83b23 v13.4.6-canary.2 2023-06-13 13:13:56 +00:00
vercel-release-bot
6e9113fe59 v13.4.6-canary.1 2023-06-12 22:32:21 +00:00
Jiachi Liu
9d0129c635
Fix standalone not found (#51172)
Fixes #50232

Passing down the private env into `'render-server'` module to pick up the proper react with require-hook in standalone server
fix NEXT-1260
2023-06-12 21:14:32 +00:00
Jiachi Liu
8a11835fbe
Strip _rsc query for navigation between app and page (#51195)
Fix a missing case from #50970

When navigating from app to page, the `_rsc` query should still be stripped
2023-06-12 20:36:36 +00:00
Steven
a6a9d65c8c
fix: helpful error when output: export and next export -o (#51191)
We already have a warning when using `next export` with `output: export` because the `next export` is effectively a no-op (the exported output was already generated during `next build`).

However, this PR ensures that `next export -o <dir>` throws an error when `output: export` is defined because the files were already emitted to the `distDir` in the `next build` step and we can't safely no-op at this point.

We also guide the user to the correct solution which is to use `output: export` along with `distDir: <dir>` in your next.config.js (instead of mixing legacy behavior with the new behavior).

fix #48207
fix NEXT-980
2023-06-12 20:15:58 +00:00
Shu Ding
de83bf5598
Revert "Do not merge chunkGroups' CSS files" (#51193)
Reverts vercel/next.js#51103
2023-06-12 19:42:06 +00:00
Delba de Oliveira
d106155c9c
Update next/head warning to link to the correct docs page (#51013)
Fixes https://github.com/vercel/next.js/issues/50844
2023-06-12 19:16:04 +00:00
Jiachi Liu
74225d1945
Prefer module fields for RSC server layer (#51179)
Follow up for #50548 

There're some packages like `aws-sdk-js-v3` which doesn't have a exports field yet: 

```
  "main": "./dist-cjs/index.js",
  "types": "./dist-types/index.d.ts",
  "module": "./dist-es/index.js",
 ```
 
 This PR let u pick up by the js assets based on main fields, will prefer `"module"` field instead of `"main"`
 
 Closes NEXT-1286
2023-06-12 17:50:12 +00:00
Shu Ding
b664cdb1c0
Add option for debugging CPU usage (#51174)
Add a `NEXT_CPU_PROF` environment variable to programmatically profile CPU for the router worker and two render workers. This is helpful because the `--cpu-prof` isn't reliably writing the result (#27406) especially with our multi-process architecture.

![CleanShot-2023-06-12-GS9p3SbN@2x](https://github.com/vercel/next.js/assets/3676859/b7cf80d2-a35a-4e90-978d-dec70be89f90)
2023-06-12 15:31:36 +00:00
Tobias Koppers
6b0a6f0c25
add turbopack integration tests to CI (#50904)
### What?

* enable turbopack tests in new CI
* split pre-build step into native and JS builds to allow to start
native tests faster
* update swc_core to sync with turbo
* update turbopack

### Why?

Running our test suite is still important as long we don't have the full
integration test suite enabled.

### Turbopack updates

* https://github.com/vercel/turbo/pull/5215 <!-- OJ Kwon - ci(workflow):
upload benchmark results to datadog -->
* https://github.com/vercel/turbo/pull/5239 <!-- OJ Kwon -
fix(swc_plugin): use shared runtime -->
* https://github.com/vercel/turbo/pull/3090 <!-- CHEN Yuan - Docs: prior
to run testcases, add guides to install dependencies for testcases. -->
* https://github.com/vercel/turbo/pull/5264 <!-- Tobias Koppers - update
test runner -->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-12 07:47:43 -07:00
vercel-release-bot
bb092bc127 v13.4.6-canary.0 2023-06-12 11:38:47 +00:00
Jiachi Liu
aa3e043bbf
Add unique search query for RSC requests to be cacable on CDN (#50970)
Adding a `_rsc` query for RSC payload requests so that they can be
differentiated on resources level for CDN cache for the ones that didn't
fully respect to VARY header.

Also stripped them for node/edge servers so that they won't show up in
the url

x-ref:
https://github.com/vercel/next.js/pull/49140#issuecomment-1549405009

Closes #49140
Closes NEXT-1268
2023-06-12 11:52:36 +02:00
Shu Ding
38d789f826
Do not merge chunkGroups' CSS files (#51103)
This is a temporary fix before we can ship #51018 (more details there). If there're multiple chunk groups holding the same CSS module, we use files from the first one. This has some flaws but still better than our current status.
2023-06-11 16:05:26 +00:00
Jiachi Liu
cfd64aab55
Fix windows metadata slashes (#51088)
Fixes #51086

The path is used as href, should be normalized as posix style
fix NEXT-1282
2023-06-10 23:30:32 +00:00
vercel-release-bot
db10dd6740 v13.4.5 2023-06-10 22:03:48 +00:00
vercel-release-bot
d683006526 v13.4.5-canary.12 2023-06-10 21:17:36 +00:00
Shu Ding
2ede83560f
Remove redundant condition (#51070)
This review comment was sent after merging the PR: https://github.com/vercel/next.js/pull/51067#discussion_r1224745071

The layer condition doesn't do anything if `hasServerComponents` is disabled.
2023-06-10 20:50:43 +00:00
vercel-release-bot
41d92fe3fd v13.4.5-canary.11 2023-06-10 19:47:11 +00:00
vercel-release-bot
387430c659 v13.4.5-canary.10 2023-06-09 23:46:48 +00:00
JJ Kasper
32a9c3553f
Fix another case with app router revalidation (#51076)
This ensures we don't attempt streaming a response during revalidation
in deployed environments.

x-ref: https://github.com/vercel/next.js/pull/51062
x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1686216024812579)
2023-06-09 16:40:41 -07:00
Steven
1a0b5d25c6
fix: moduleResolution: bundler support in tsconfig.json (#51065)
- Fixes https://github.com/vercel/next.js/issues/47858
- Closes https://github.com/vercel/next.js/pull/50289

fix #47858
fix NEXT-1281

Co-authored-by: Kevin Wolf <3157426+kevinwolfcr@users.noreply.github.com>
2023-06-09 21:48:13 +00:00
Jiachi Liu
2bc1061609
Apply optimization to middleware when using babel (#51067)
Like how we handled RSC loader transform before, we also apply swc
loader to middleware to make sure the imports optimization is applied so
og package won't be bundled

Fixes #50492
2023-06-09 13:33:14 -07:00
JJ Kasper
804552590e
Update app router revalidate handling on deploy (#51062)
This ensures we clear the RSC headers during revalidate when deployed so
that the HTML revalidation isn't treated as the RSC revalidation.
2023-06-09 13:23:44 -07:00
Simon Podlipsky
be960ccd02
fix: verbatimModuleSyntax: true support in tsconfig.json (#48018)
### What?

When `verbatimModuleSyntax: true` is set, `isolatedModules: true` are not allowed by TS

### Why?

Next always adds `isolatedModules: true` which causes TS error.

### How?

- Fixes #46509

fix NEXT-689

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-06-09 19:07:30 +00:00
Jiachi Liu
558632b5f2
Avoid server insertion react key warning (#51053)
Wrap server inseration children with react key to avoid react key
warning display
2023-06-09 10:18:19 -07:00
JJ Kasper
4080f63505
Ensure id handling applies for dynamic import in pages (#51049)
Noticed this case wasn't handled in pages so added additional test
coverage and patched the case.
2023-06-09 09:51:51 -07:00
JJ Kasper
480df20086
Ensure headers instance is serialized (#51047)
This makes sure we properly include headers in the cache key when a
headers instance is used.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1686234796532989)
2023-06-09 09:35:45 -07:00
Michael Novotny
55b29fb351
Updates prettier to latest version. (#51000)
There are some incoming docs / MDX changes where prettier will throw an error when using the older version. Updating prettier before I bring in those changes.

Looks like the most notable change is adding parentheses around `typeof` checks in TypeScript. 

**Before**

```
export type Locale = typeof i18n['locales'][number]
```

**After**

```
export type Locale = (typeof i18n)['locales'][number]
```
2023-06-09 14:58:19 +00:00
Jiachi Liu
2a2890cae6
Fix esm module import warning for middleware loader (#51014)
We need to spread the module into an object instead of access the module exports that could not exist, to avoid triggering the warning. Fix the bad loader change introduced in #50548 

```
Attempted import error: './middleware.js' does not contain a default export (imported as '
mod').
- info Using locally built binary of @next/swc
- warn You are using an experimental edge runtime, the API might change.
- wait compiling...
- warn ../../../../packages/next/dist/build/webpack/loaders/next-middleware-loader.js?abso
lutePagePath=%2FUsers%2Fhuozhi%2Fworkspace%2Fnext.js%2Ftest%2Fe2e%2Fapp-dir%2Fapp%2Fmiddle
ware.js&page=%2Fmiddleware&rootDir=%2FUsers%2Fhuozhi%2Fworkspace%2Fnext.js%2Ftest%2Fe2e%2F
app-dir%2Fapp&matchers=!
Attempted import error: './middleware.js' does not contain a default export (imported as '
mod').
- wait compiling...
```
2023-06-09 14:14:50 +00:00
Jimmy Lai
41675c07cb
edge: use JSON parse instead of inlining the manifests objects (#50960)
Manifests tend to be really big and our strategy is to inline them in the edge function script itself and we're hitting some constraints this way. 

This PR switches this behaviour via inlining the script and creating a JS object at runtime instead, with the hope that the parsing time will be faster as JSON.parse is very well optimised in V8.

The end goal ofc is to have smaller manifests but this should be a good stopgap.



link NEXT-1273
2023-06-09 12:58:55 +00:00
Jiachi Liu
f19b31ad93
Fix rsc payload fetch failures due to state tree encoding (#51017)
Encode the state tree where the content could contain unicode when
request the RSC payload, to avoid the fetch failure due to bad encoding
for headers

Fixes #48728
fix NEXT-1258
2023-06-09 12:06:00 +02:00
Balázs Orbán
96e47d3f37
chore: mark forceOptimisticNavigation as internal (#47905)
### What?

Hide internal API.

### Why?

Ref: https://vercel.slack.com/archives/C035J346QQL/p1669125601246609?thread_ts=1669125167.045259&cid=C035J346QQL

### How?

Mark the internal property with `@internal` so it's not shown by IntelliSense.

Related #47894
2023-06-09 09:36:36 +00:00
vercel-release-bot
f2dfa1a92a v13.4.5-canary.9 2023-06-09 08:30:52 +00:00
JJ Kasper
cdd366fd97
Fix usage of router.refresh() with Draft Mode in App Router (#50941)
After enabling Draft Mode, `router.refresh()` was incorrectly causing the page to crash and do a full page refresh.

This PR fixes this case.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-06-09 00:15:55 +00:00
Will Binns-Smith
994c61a807
Turbopack next/font/google: Use capsize's xWidthAvg to compute fallbacks (#50878)
Instead of using azAvgWidth for next/font/google, use xWidthAvg as the webpack implementation does. For now, next/font/local in both the webpack and Turbopack implementations continue to use azAvgWidth. We should align these in the future.

Test Plan: We now pass 26 next/font tests in Turbopack, up from 22.
2023-06-08 23:02:28 +00:00
Jiachi Liu
f2e637d24d
Upgrade webpack to 5.86.0 (#50992)
To resolve issue #49382, we found layer doesn't get applied for dynamic imports, so we fixed it on webpack side in https://github.com/webpack/webpack/pull/17310

This PR is to upgrade webpack to 5.86.0 with that patch as a precedence. After this we need to fix the `next/image` client components is missing in client reference manifest when using dynamic imports to fix the issue.
2023-06-08 20:35:12 +00:00
Shu Ding
5150506452
Move required chunk collection to the upper level (#50983)
This is an optimization to make the plugin faster, we're currently doing
redundant work `getAppPathRequiredChunks()` for all modules during
`recordModule()` while it's not changing.
2023-06-08 20:22:38 +02:00
Steven
9a9d095b54
Bump to typescript@5.1 (#50557)
We need to upgrade TypeScript to land the following fixes:

- https://github.com/vercel/next.js/pull/50289
- https://github.com/vercel/next.js/pull/48018

And it should fix async components:
- https://twitter.com/sebsilbermann/status/1664356039876124672

Also see this related TS 5.0 issue:

- https://github.com/microsoft/TypeScript/issues/53402
2023-06-08 17:18:37 +00:00
Jiachi Liu
a035224dc3
Pick esm main fields and condition names first for RSC server layer (#50548)
For RSC server layer so far we bundle all dependencies, ESM format is the better one rather than CJS to analyze and tree-shake out the unused parts. This PR changes pick the condition names that are in ESM format first for server layer.

Also fixes the misorder of condition names of edge runtime, `conditionNames` should only contain either ESM or CJS, previously the main fields are mixed with conditon names which is not expected for webpack, we separate them now.

Since we're picking ESM instead CJS now, the error of require `exports * from` doesn't exist anymore, but if you're using a CJS dependency which require a ESM package, it will error. This is the existing behavior for our webpack configuration but could happen on server layer bundling

Other related changes:

* Imports are hoisted in ESM, so migrate`enhanceGlobals` to a imported module
* Use `...` to pick the proper imports by import expression, and prefer the `react-server` / `edge-light` condition names for corresponding cases
* Remove edge SSR duplicated `middleware` export checking
2023-06-08 16:24:03 +00:00
Wyatt Johnson
ea63e92e87
Bump @types/node (#50940)
This bumps @types/node to 20.2.5 to prepare for upgrades to other packages requiring updated Node.js typescript types.
2023-06-08 15:52:17 +00:00
vercel-release-bot
d52c030d94 v13.4.5-canary.8 2023-06-08 15:01:09 +00:00
Shu Ding
b7d438cfc1
Invalidate prefetch cache when a tag or path has been revalidated on the server (#50848)
This makes sure that if `revalidateTag` is called in a Server Action, the client router cache and prefetch cache are invalidated correctly so following navigations won't reuse the cache that might hold stale data.

Similar case for `revalidatePath`. I left a TODO where we can't just invalidate the subtree under the revalidate paths because of current implementation limitations. To ensure correctness, we just do the same as `revalidateTag`.
2023-06-08 13:44:42 +00:00
Shu Ding
2010928d9a
Drop the chunks field in the client manifest for SSR (#50959)
The `ssrModuleMapping`/`edgeSSRModuleMapping` fields store information
for the Flight client that does SSR to resolve the correct modules in
the SSR bundle. This works as a module ID mapping between the client
bundle and the SSR bundle. During the mapping, we can drop the `chunks`
field because we don't actually have external chunks to load during SSR
as everything is locally `require`'d.

This reduces the client manifest size by at least 20%.
2023-06-08 14:47:24 +02:00
Delba de Oliveira
8c2e5bd072
Update codeowners to use Vercel Spaces (#50841)
Move as much of codeowners as possible to use Vercel Spaces. 

1. Makes `@timneutkens @ijjk @shuding @huozhi @feedthejim` global owners
2. Make the `@vercel/next-js` team _optional_ owners of **/docs**,
**/errors**, and **/contributing**, makes team owners of a few packages
as per old config.
3. Make `@vercel/devex` (docs and devrel) owners of **/docs**,
**/errors**, and **/contributing**
4. Make `@vercel/devrel` (devrel only) owners of **/examples**
5. Make `@vercel/web-tooling` owners of specific files and folders (as
per old config)

Leaves @styfle as owner of **image** files on the old config since this
pattern `/**/*image*/** ` can't be used with Vercel Spaces.

Note: We cannot add * or / at the end of files.
[Docs](https://spaces-docs.vercel.sh/docs/code-owners#:~:text=Code%20Owners%20files%20are%20meant%20to%20encourage%20distributed%20ownership%20definitions%20across%20a%20codebase.)
2023-06-08 12:02:18 +02:00
JJ Kasper
22ea7d9909
Revert "Revert "update turbopack"" (#50947)
Fixed in https://github.com/vercel/next.js/pull/50946

Reverts vercel/next.js#50942
2023-06-08 04:02:03 +00:00
Shu Ding
18d2f7da33
Fix shorthand prop wrongly handled in the Server Actions compiler (#50937)
This PR fixes the case of having a shorthand prop `{ id }` referenced from a non-top level closure in the Server Actions compiler. The main problem is that an `Ident` in `PropOrSpread` is not considered as an `Expr`.

See corresponding issue report and test case for more details.
fix #50445
fix NEXT-1254
2023-06-08 03:03:54 +00:00
JJ Kasper
2a62513ecd
Revert "update turbopack" (#50942)
The builds are failing 

x-ref:
https://github.com/vercel/next.js/actions/runs/5206362546/jobs/9392872573
x-ref:
https://github.com/vercel/next.js/actions/runs/5206362546/jobs/9392873009
x-ref:
https://github.com/vercel/next.js/actions/runs/5206362546/jobs/9392873120

Reverts vercel/next.js#50819
2023-06-07 19:02:29 -07:00
Leah
0d46361f8e
update turbopack (#50819)
### Turbopack Updates
* https://github.com/vercel/turbo/pull/5156 
* https://github.com/vercel/turbo/pull/5159 
* https://github.com/vercel/turbo/pull/5162 
* https://github.com/vercel/turbo/pull/5161 

* https://github.com/vercel/turbo/pull/5174 
* https://github.com/vercel/turbo/pull/5178 
* https://github.com/vercel/turbo/pull/5121 
* https://github.com/vercel/turbo/pull/5200 
* https://github.com/vercel/turbo/pull/5207 
* https://github.com/vercel/turbo/pull/5211 
* https://github.com/vercel/turbo/pull/5210 
* https://github.com/vercel/turbo/pull/5221 
* https://github.com/vercel/turbo/pull/5218 
* https://github.com/vercel/turbo/pull/5226 
* https://github.com/vercel/turbo/pull/5139 
* https://github.com/vercel/turbo/pull/5227 
* https://github.com/vercel/turbo/pull/5189
2023-06-08 01:23:14 +00:00
JJ Kasper
06abd63489
Add experimental caseSensitiveRoutes config (#50869)
This adds an experimental `caseSensitiveRoutes` config that currently applies for `rewrites`, `redirects`, and `headers` to change the default of case-insensitive. 

x-ref: [slack thread](https://vercel.slack.com/archives/C02K2HCH5V4/p1686080359514479?thread_ts=1686077053.623389&cid=C02K2HCH5V4)
x-ref: [slack thread](https://vercel.slack.com/archives/C057RG6Q9MX/p1686078875948069?thread_ts=1686077882.133609&cid=C057RG6Q9MX)
x-ref: https://github.com/vercel/next.js/issues/21498
2023-06-07 21:50:22 +00:00
JJ Kasper
6ef76195a5
Update next-swc handling for PR stats (#50933)
This fixes the wasm swc build being used for PR stats unexpectedly since
pnpm pack wasn't actually including the swc binary. This also adds a
hard error preventing the wasm swc binary from being leveraged in the
future for PR stats.

x-ref:
[vercel/next.js/actions/runs/5193512579/jobs/9364168639](https://github.com/vercel/next.js/actions/runs/5193512579/jobs/9364168639)
x-ref:
https://github.com/vercel/next.js/pull/50853#issuecomment-1579055731

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-06-07 14:31:57 -07:00
Jiachi Liu
8eb14280e8
Polish error page styling (#50916)
Polish default client error page styling:

* shrink the `line-height` to `2em` for better mobile display
* remove `text-align: left` to let the text center properly

#### After vs Before
(both **app router** and **pages** default client error page)
<p>
<img width="300" alt="image" src="https://github.com/vercel/next.js/assets/4800338/de7260af-7046-4783-8f82-8ac5f39f25b7">
<img width="300" alt="image" src="https://github.com/vercel/next.js/assets/4800338/f4207809-f11f-448d-95ec-0a32b54f3562">
</p>


#### After
(both **app router** and **pages** default client error page)


Closes NEXT-1263
2023-06-07 17:54:48 +00:00
Toru Kobayashi
675dec04ca
fix: App Router with assetPrefix: / (#49622)
This is a follow-up PR for #49403.

#49403 validates `assetPrefix` is not a relative path. But App Router throws an error with the `assetPrefix: "/"` option. So I've fixed this.

<img width="964" alt="Screenshot 2023-05-10 at 23 41 56" src="https://github.com/vercel/next.js/assets/250407/6e83cb57-468c-46d6-a91a-747ad39d6c3c">

`assetPrefix: "/"` has no meaning, but it shouldn't fail.
2023-06-07 14:46:02 +00:00
vercel-release-bot
e19007df42 v13.4.5-canary.7 2023-06-07 09:53:16 +00:00
Josh Story
92b29d2f17
Update react to latest versions (#50604)
Update Vendored React Dependencies
2023-06-07 09:50:27 +00:00
Tim Neutkens
9a1db5fc5e
Add additional font-loader spans for tracing (#50889)
## What?

Adds additional spans for running postcss and fontloader in next-font-loader.
2023-06-07 09:32:07 +00:00
Tim Neutkens
a24c607a4d
Add layer to module trace (#50851)
## What?

Adds `layer` to the traces for `build-module-x`, will allow us to figure
out in what layer the module was compiled, as you can now get multiple
for the same module.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-06-07 10:51:42 +02:00
Jiachi Liu
452d390ec0
Fill basic twitter metadata with opengraph when missing (#50854)
When twitter metadata is not provided but opengraph metadata is, fill the opengraph basic information for twitter metadata.
Twitter card can't be displayed if there's no information from twitter meta tags, at least the `twitter:card`. We fill the `title` `description` and `images` these 3 overlapped properties from opengraph image so they can be displayed properly

Closes NEXT-1111
2023-06-06 20:54:14 +00:00
Justin Ridgewell
1a2fac2b5a
[turbopack]: Use tip-of-branch for benchmarks (#50615)
With vercel/turbo#5156, we'll be able to install our the locally built `next` package. Before, we'd test the tip-of-branch `next-dev` binary against the last cut `next` canary, which causes headaches when we make breaking changes.

With this PR, we'll now test tip-of-branch `next-dev` binary against a tip-of-branch `next` package, and breaking changes can be properly benched.

Fixes WEB-1133
2023-06-06 20:36:11 +00:00
JJ Kasper
1e0566b9ac
Update id config handling (#50847)
Adds a separate flag for leveraging the env variable.
2023-06-06 07:54:06 -07:00
Kiko Beats
218c683db7
upgrade edge-runtime dependency (#50636)
Hello,

We removed some core non-necessary dependencies that make Edge Runtime
smaller 🙂.

Also, Edge Runtime is exposing `WebSocket`, so nothing additional should
be done.

Closes https://github.com/vercel/next.js/issues/50760

---------

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2023-06-06 16:13:44 +02:00
Wyatt Johnson
099ca3a36a
Pages Route Module Rendering (#50404)
This starts the process of moving the rendering logic for pages into the
bundle. The `render` method on the module now provides the same
capability as the underlying `renderHTML` method available on the
`NextNodeServer`. In the next few change sets, more layers of the
rendering pipeline will shift into the bundled code, removing them from
the main boot path.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-06-06 16:12:04 +02:00
Tim Neutkens
230641adfd
Bail out of 404 page when favicon.ico doesn't exist (#50795)
## What?

Anytime you open a Next.js application that doesn't have a `favicon.ico`
you'll notice `/_error` is being compiled because the browser requests
`favicon.ico`. This PR ensures the 404 page is not compiled in
development for that request. It helps a little with compilation speed.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-06-06 10:58:40 +02:00
Jiachi Liu
ec5ba3184b
Shrink the react key size in metadata RSC payload (#50739)
Follow up for #50678 as @gnoff commented in https://github.com/vercel/next.js/pull/50678#pullrequestreview-1457858336

Now metadata is shorter with the shorter key with just numbers

```
self.__next_f.push([1,"5:[[\"$\",\"meta\",\"0\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]\n"])
```
2023-06-06 08:51:00 +00:00
JJ Kasper
8e9613fae5
Update fetch dynamic error handling (#50822)
Updates to not throw the dynamic server error inside of the patched
fetch as it's typical for fetch errors to be caught and handled and this
error is not meant to be caught by users. This instead throws it during
rendering so we can ensure we catch it instead of users.

x-ref:
https://github.com/vercel/next.js/actions/runs/5182384027/jobs/9339123096
2023-06-05 21:47:01 -07:00
vinay
c2d7bbd1b8
change(create-next-app): Get-pkg-manager logic change. (#50372)
Simplified Get-pkg-manager logic.

---------

Co-authored-by: Steven <steven@ceriously.com>
2023-06-05 19:31:10 -04:00
OJ Kwon
78ed08d88e
fix(next-swc): reenable filesystem cache (#50651)
### What?

Quick fix for the regressions that next.js cannot load plugin due to missing filesystem cache.
2023-06-05 15:42:13 +00:00
vercel-release-bot
b04c70573a v13.4.5-canary.6 2023-06-05 13:13:22 +00:00
Tim Neutkens
8ab38cef41
Improve compile time on large application (#50792)
## What?

While investigating slow compilation for a page on vercel.com in
development I found that there was close to 10 seconds of time
unaccounted for in `.next/trace`. Ran a profile and found that time was
spent in watchpack `batch`, specifically calling `close` many times.
When I tried to debug this further by running unbundled webpack I
noticed the same issue didn't exists.

### Before

<img width="1329" alt="Before"
src="https://github.com/vercel/next.js/assets/6324199/9ace4628-db04-4de7-993f-65aef9dffc55">

### After

<img width="1278" alt="After"
src="https://github.com/vercel/next.js/assets/6324199/55d5e58b-4a27-4235-8dea-723a7a78c117">

## Raw numbers

<table>
<tr>
 <td>Before</td>
 <td>After</td>
 <td>Delta</td>
 <td>Delta (percent)</td>
</tr>
<tr>
 <td>13840 ms</td>
 <td>3580 ms</td>
 <td>-10260 ms</td>
  <td>-74.13%</td>
</tr>
</table>

## How?

Investigated further and found that specifically not minifying watchpack
solved the issue.

<!-- Thanks for opening a PR! Your contribution is much appreciated.
To make sure your PR is handled as smoothly as possible we request that
you follow the checklist sections below.
Choose the right checklist for the change(s) that you're making:

## For Contributors

### Improving Documentation or adding/fixing Examples

- The "examples guidelines" are followed from our contributing doc
https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
- Make sure the linting passes by running `pnpm build && pnpm lint`. See
https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md

### Fixing a bug

- Related issues linked using `fixes #number`
- Tests added. See:
https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md

### Adding a feature

- Implements an existing feature request or RFC. Make sure the feature
request has been accepted for implementation before opening a PR. (A
discussion must be opened, see
https://github.com/vercel/next.js/discussions/new?category=ideas)
- Related issues/discussions are linked using `fixes #number`
- e2e tests added
(https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
- Documentation added
- Telemetry added. In case of a feature if it's used or not.
- Errors have a helpful link attached, see
https://github.com/vercel/next.js/blob/canary/contributing.md



## For Maintainers

- Minimal description (aim for explaining to someone not on the team to
understand the PR)
- When linking to a Slack thread, you might want to share details of the
conclusion
- Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
- Add review comments if necessary to explain to the reviewer the logic
behind a change

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-06-05 15:05:54 +02:00
vercel-release-bot
ccee374e2a v13.4.5-canary.5 2023-06-05 07:18:40 +00:00
Tim Neutkens
dd714796d7
Optimize next-app-loader resolving speed (#50745)
## What?

We recently implemented an optimized resolving method for `app` in Turbopack, this ports some of the main changes in that resolving logic to optimize `next-app-loader` which during compilation resolves the tree structure that we use to render in `app-render.tsx`.

Here's the results for a page that is nested a few levels deep on vercel.com using App Router. These results only cover `next-app-loader`, not any modules compiled below it.

### Before

<img width="671" alt="CleanShot 2023-06-03 at 22 36 26@2x" src="https://github.com/vercel/next.js/assets/6324199/0edeb060-2460-4a7d-95a7-1c22ea26a065">

### After

<img width="673" alt="CleanShot 2023-06-03 at 22 55 10@2x" src="https://github.com/vercel/next.js/assets/6324199/f40964fc-b169-4d95-8711-73cbff3ec76a">


## Raw numbers

<table>
<tr>
 <td>Before</td>
 <td>After</td>
 <td>Delta</td>
 <td>Delta (percent)</td>
</tr>
<tr>
 <td>1.620 ms</td>
 <td>76.39 ms</td>
 <td>-1.543.61 ms</td>
  <td>-95.2%</td>
</tr>
</table>

## How?

Changed the resolving logic to use `fileExists`, looping over the provided pageExtensions.
For Turbopack we have a process that does only one pass for generating all trees. That also only reads directories instead of checking individual files, which is even better (<5ms for generating all possible trees) but this PR is a quick win that has a big impact already without refactoring the entire entries generation in webpack.
2023-06-05 06:51:02 +00:00
vercel-release-bot
793d9bfc6a v13.4.5-canary.4 2023-06-02 17:59:01 +00:00
Steven
d13fe04f1e
fix: conditional cookies in draft mode (#50660)
fix NEXT-1246
2023-06-02 17:30:10 +00:00
Will Binns-Smith
e657741b99
next/font: tolerate missing unused fields in capsize map (#50708)
Some font entries in capsize do not include fields like `cap_height` and `x_height`. Since these are unused by next/font, remove these from the serde structure entirely.

Additionally, this makes it so that failing to read or deserialize the capsize map results in an `Error` rather than a `FontFallbackError`, which causes a build failure rather than silently omitting a fallback font. `next/font` should always include this map, and it obscured the real issue here. However, a missing entry in this map _should_ result in omitting a fallback.
2023-06-02 17:10:28 +00:00
Toru Kobayashi
a7afb53a87
fix: a11y issues in the overlay component (HMR) (#49782)
This is a follow-up PR for #49460.

I've fixed some a11y issues at #49460, but I've noticed that Next has other overlay implementations.
So I've applied that into another implementation, which seems to be for HMR overlay.

There is another overlay implementation for Turbopack, so I'll fix it later.

- https://github.com/vercel/next.js/tree/canary/packages/react-dev-overlay/src/internal
- https://github.com/vercel/next.js/tree/canary/packages/next/src/client/components/react-dev-overlay/internal
- https://github.com/vercel/next.js/tree/canary/packages/next-swc/crates/next-core/js/src/overlay/internal

I couldn't get the way to run an application with `--turbo` in the monorepo by `next-with-deps`. I tried `pnpm next-with-deps --turbo ./examples/app-dir-mdx`, but I've got the `Error: Cannot find module 'next/dist/server/node-polyfill-fetch'` error  and couldn't fix it. I tried building `next-swc` by `pnpm build-native`, but couldn't fix the error.
How can I run a local application with `--turbo`?

I expect this is a temporary fix because it would be nice if I could remove duplicated components by removing duplicated components and importing from one place.
I feel `packages/react-dev-overlay` is the right place for this because it's a separate package. But `packages/react-dev-overlay` imports some modules from `next/dist/client/components/react-dev-overlay/`, which is an opposite dependency.

e.g. afddb6ebda/packages/react-dev-overlay/src/client.ts (L3)

I've also found `@next/react-dev-ovrelay` is imported from `package/next` as a combiled package like `next/dist/compiled/@next/react-dev-overlay/dist/client`

- afddb6ebda/packages/next/src/client/dev/error-overlay/hot-dev-client.ts (L31-L37)
- afddb6ebda/packages/next/src/server/dev/next-dev-server.ts (L61-L66)

What do you think? I'll work on this if it makes sense.
2023-06-02 16:18:18 +00:00
Jiachi Liu
062dc38fb9
Fix image loader file emission path for edge runtime (#50683)
[slack-thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1685646762333709?thread_ts=1685643782.265269&cid=C04DUD7EB1B)

Using image in pages SSR emitting the static image files into `<rootDir>/static/media`, which should be located at `<rootDir>/.next/static/media`
2023-06-02 14:01:53 +00:00
Jiachi Liu
1b9fea7a8c
Perf: reduce metadata RSC payload (#50678)
### What
Currently when all the metadata rendered as JSX as server components, all the empty metadata which should be skipped as they're rendered as `null` in JSX, are still included in the RSC payload. This helps reduce the initial html size.

### How

Change the JSX components into function calls, and filter out the nullable component that won't be rendered, then they won't show up in the react tree and be serialized.

Before
```
self.__next_f.push([1, "5:[[[\"$\",\"meta\",null,{\"charSet\":\"utf-8\"}],null,null,null,null,null,null,null,null,null,null,[\"$\",\"meta\",null,{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],null,null,null,null,null,null,null,null,null,null,[]],[null,null,null,null],null,null,[null,null,null,null,null],null,null,null,null,null]\n"])
```

After
```
self.__next_f.push([1, "5:[[[\"$\",\"meta\",\"charset\",{\"charSet\":\"utf-8\"}],[\"$\",\"meta\",\"viewport:width=device-width, initial-scale=1\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}]]]\n"])
```


Closes NEXT-1232
2023-06-02 11:30:42 +00:00
Shu Ding
89a62ac4c8
Remove cssFiles field (#50610)
This field is no longer needed. Although removing it might cause
unnecessary styles being included that could be tree-shaken potentially,
it solves a more critical issue of missing CSS resources: since now CSS
import can be "hoisted" to its parent entry (e.g. a layout), we can't
simply get all used CSS resources from the "leaf entry" (e.g. a page).
2023-06-02 09:24:03 +02:00
Shu Ding
a0314c09cc
Ensure user-installed opentelemetry package has the minimal required version (#50554) 2023-06-02 08:28:29 +02:00
Shohei Maeda
0a61aa18d6
Add new Google-InspectionTool token to known bot UA list (#50467)
Google apparently started using a new bot UA token recently:

- https://kw.linkedin.com/posts/garyillyes_google-crawler-user-agent-overview-google-activity-7064560799226175488-g_nh
- https://developers.google.com/search/docs/crawling-indexing/overview-google-crawlers#google-inspectiontool
2023-06-01 22:58:44 +00:00