Commit graph

8968 commits

Author SHA1 Message Date
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