Commit graph

16948 commits

Author SHA1 Message Date
Tim Neutkens
d4ff236f48
Reuse RenderWorker type (#53782)
Found that this type was duplicated. This just reuses the existing definition.
2023-08-10 04:35:33 +00:00
Steven
89be8c4b35
chore(docs): add missing "try it out" (#53815)
Follow up to https://github.com/vercel/next.js/pull/53760

This follows the same pattern as other demo links on this page.
2023-08-10 00:30:56 +00:00
JJ Kasper
6bd8cd7cac
Ensure we set cache-control: no-cache for actions (#53824)
This ensures we don't accidentally allow caching server actions causing unexpected behavior.
2023-08-09 23:59:42 +00:00
Lucas Constantino Silva
0350e00d0d
docs: document cache tagging mechanism (#53806)
This PR document the cache tagging semantics in Next.js, and how to benefit from it during cache revalidation.
2023-08-09 23:18:02 +00:00
Luud Janssen
5fe332186e
Add changeFrequency and priority attributes to sitemaps (#48484)
Closes #48479. 

Couldn't find the source for the Next.js beta docs, so I didn't add documentation.

Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-08-09 20:36:22 +00:00
Zack Tanner
712669f605
improve error message for conflicting parallel segments (#53803)
This is a follow-up to log both conflicting paths & a link to route group docs, which I believe is the only scenario someone could trigger this

- https://github.com/vercel/next.js/pull/53752
2023-08-09 17:21:24 +00:00
JJ Kasper
7d67f00f8f
Sort root entries per pageExtensions config for consistency (#53769)
While running our `test/integration/middleware-src` test suite across
systems, noticed this behaved inconsistently due to us relying on the
order the filesystem ordered duplicates e.g. `middleware.ts` and
`middleware.js`.

Considering we already have a loud warning for this duplicate this adds
consistency across systems by ensuring these are sorted per our
pageExtensions order which is `ts` takes priority over `js` by default.

An additional test case was not added as the above mentioned suite
covers this but was verified as passing on one of the systems (mac OS)
where it was not previously.
2023-08-09 09:54:55 -07:00
Lee Robinson
3077a0e9ff
docs: Add more information about Server Actions (#53805)
A few helpful additions based on conversations I've had recently.
2023-08-09 15:48:24 +00:00
Steven
87301834b3
chore: add light/dark mode theme detection to image component example (#53760)
This PR adds documentation for light/dark mode detection with `next/image`.

In the future, we could also document the picture solution once https://github.com/vercel/next.js/pull/51205 goes stable (although some of the preloading would not be possible).

* x-ref: https://twitter.com/victorbayas/status/1688596439704780822
2023-08-09 14:55:42 +00:00
Balázs Orbán
6809edccd5
chore(actions): exclude drafts from PR notificiation (#53669)
### What?

Do not count draft PRs

### Why?

These are still being worked on
2023-08-09 14:38:49 +00:00
Delba de Oliveira
8e0d108836
Docs: Add option for fetching data using route handlers - from the client (#53793)
In the data fetching page, we discuss the different ways you can fetch data in Next.js. This PR adds a fourth option which is to call route handlers from client components. I've also added a note that you shouldn't call a route handler from a server component. 

Co-authored-by: Lee Robinson <9113740+leerob@users.noreply.github.com>
2023-08-09 13:55:44 +00:00
OJ Kwon
e127c51327
test(turbo): allow to run test with --experimental-turbo (#53396)
### What?

Allows to configure test runs with --experimental turbo.
2023-08-09 05:48:54 +00:00
JJ Kasper
6b492974b7
Move next-rs API tests from unit to e2e (#53771)
These tests aren't unit per-se as they rely on e2e-utils so this moves
them to the `development` test folder.

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1691520079363229)
2023-08-08 21:50:04 -07:00
Emilien Kenler
64d9475f37
Fix typo in data fetching documentation (#53772)
Fix a typo in data fetching documentation.
2023-08-09 04:45:49 +00:00
JJ Kasper
4b4533787b
Add warnings for static generation bail outs (#53761)
Currently using server actions on a page or using edge runtime causes
that page to bail out of ISR or static generation so this adds warnings
to make users aware of this.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1690816539472449)

---------

Co-authored-by: Zack Tanner <zacktanner@gmail.com>
2023-08-08 20:09:34 -07:00
Vercel Release Bot
5c9553002c
Update font data (#53759)
This auto-generated PR updates font data with latest available
2023-08-09 01:10:50 +00:00
MrAdib
2566d0781d
Fix a link in incrementalCacheHandlerPath.mdx (#53718)
fix the default cache handler link
2023-08-09 00:55:13 +00:00
Eric Fennis
5e716ec918
fix: Update outdated transform imports lucide-react (#53697)
### What?

Fixing outdated import mapping with the latest `lucide-react` changes. See [lucide-icons/lucide@v0.264.0](https://github.com/lucide-icons/lucide/releases/tag/v0.264.0)

Closes: lucide-icons/lucide#1482

### Why?

Import mapping was outdated

### How?

By updating the default config and the tests.

## Notes

Maintainer here from @lucide-icons.
To this day I didn't know the Nextjs default config file has predefined hardcoded modularize imports. 
I was a bit surprised that there is a default mapping for libraries that could change in the future like Lucide. 

I'm not in favor of this hardcoded "modularize imports", because this creates a hard dependency on libraries. With Lucide, we still have not reached 1.0 and will sometimes rename icons and add aliases for them. So issues will occur in the future, and constantly updating this config doesn't feel right. 

Is there, not a better way? Like for example, a package exposing a config file containing the import mapping?
This way import map will automatically be in sync with changes in a package. 

Let me know what you think of this.
2023-08-09 00:48:48 +00:00
Josh Story
79b7c1493b
App Router Preinitialize all required scripts except one for bootstrap (#53705)
Currently all scripts that are required for every page are loaded as
part of the bootstrap scripts API in React. Unfortunately this loads
them all as sync scripts and thus requires preloading which increases
their priority higher than they might otherwise be causing things like
images to load later than desired, blocking paint. We can improve this
by only using one script for bootstrapping and having the rest
pre-initialized. This only works because all of these scripts are
webpack runtime or chunks and can be loaded in any order asynchronously.

With this change we should see improvements in LCP and other metrics as
preloads for images are favored over loading scripts

Co-authored-by: Steven <steven@ceriously.com>
2023-08-08 17:28:17 -07:00
Zack Tanner
d58fd68f0a
fix parallel route tests & improve error for conflicting pages (#53752)
This fixes some tests that were disabled due to a missing `page` segment for the corresponding slots in `/parallel/nested`. 

While fixing, I also noticed if you accidentally create two pages that resolve to the same URL segment (which is fairly easy to do accidentally do with route groups), we were throwing an unhelpful error of "Cannot find module: '<snip>/page_client-reference-manifest.js'" when building (and fail silently in dev). For example, this scenario was throwing a manifest error:

```
app
  (groupa)
    page.tsx
  (groupb)
    page.tsx
```

This will now throw with a more helpful error when resolving parallel segments if the page segment was already resolved. This also re-enables the disabled tests.

Closes NEXT-1440
Fixes #53569 (by virtue of throwing a more helpful error)
2023-08-08 22:56:39 +00:00
Dingan(Will) Wang
5cfb936edd
Fix example/with-material-ui broken links (#53707)
Fixed the example/with-material-ui broken links.

It seems the external websites got updated.
2023-08-08 22:37:41 +00:00
Steven
195d1f1a2b
fix(next/image): priority in App Router causes double fetch on mobile (#53700)
The root cause is `ReactDOM.preload()` inserts `<link rel="preload">` above the `<meta name="viewport">`. 

This PR adds a test to prove that upgrading React fixes the issue (see commits).

- Depends on https://github.com/facebook/react/pull/27201
- Depends on https://github.com/vercel/next.js/pull/53742
- Fixes https://github.com/vercel/next.js/issues/53574
- Related https://github.com/vercel/next.js/issues/52995
2023-08-08 21:02:54 +00:00
Josh Story
f0dab3a8da
update vendored React packages to the the latest canary (#53742)
Updated React from 9377e1010 to cb3404a0c.

### React upstream changes

- https://github.com/facebook/react/pull/27190
- https://github.com/facebook/react/pull/27189
- https://github.com/facebook/react/pull/27201
- https://github.com/facebook/react/pull/27147
- https://github.com/facebook/react/pull/26949
- https://github.com/facebook/react/pull/27058
- https://github.com/facebook/react/pull/27142
- https://github.com/facebook/react/pull/27133
- https://github.com/facebook/react/pull/27130
- https://github.com/facebook/react/pull/27105
- https://github.com/facebook/react/pull/27117
- https://github.com/facebook/react/pull/27057
2023-08-08 20:16:24 +00:00
Zack Tanner
ee15b3be5d
fix: error overlay hijacking application focus (safari) (#53693)
### What?
When Safari is in the background and HMR triggers a full page reload,
Safari hijacks application focus.

### Why?
Having a `role="dialog"` is correctly prompting Safari to autofocus the
first focusable element (the close button). However, Safari's behavior
seems to also bring the application to the foreground when a background
focus event occurs.

### How?
This only adds the role when the document is focused. 

#### Before

https://github.com/vercel/next.js/assets/1939140/9d2cce52-c6ee-4d49-9262-03620efad86c

#### After

https://github.com/vercel/next.js/assets/1939140/dc7d337c-b621-49e9-9a17-03b5d8b5c3f4

Confirmed voiceover behavior still appears to be correct
<img width="1371" alt="CleanShot 2023-08-07 at 12 14 34@2x"
src="https://github.com/vercel/next.js/assets/1939140/e53acfbc-cf6b-4d74-8b83-cf98edb2c2ab">

slack x-ref:
https://vercel.slack.com/archives/C03KAR5DCKC/p1691264077313599

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-08 21:45:03 +02:00
Tobias Koppers
9d1b3f43a1
Turbopack: add hmr test case and fix bugs (#53719)
### What?

test case for HMR

### Turbopack Changes

* https://github.com/vercel/turbo/pull/5686 <!-- Tobias Koppers - remove
error in update -->
2023-08-08 17:07:24 +02:00
vercel-release-bot
d7405b0c28 v13.4.14-canary.1 2023-08-08 14:11:47 +00:00
Tim Neutkens
c5a8e0989e
Consolidate Server and Routing process into one process (#53523)
In the current version of Next.js there are 4 processes when running in
production:

- Server
- Routing
- Rendering Pages Router
- Rendering App Router

This setup was introduced in order to allow App Router and Pages Router
to use different versions of React (i.e. Server Actions currently
requires react@experimental to function). I wrote down more on why these
processes exist in this comment:
https://github.com/vercel/next.js/issues/49929#issuecomment-1637185156

This PR combines the Server and Routing process into one handler, as the
"Server" process was only proxying to the Routing process. In my testing
this caused about ~2x the amount of memory per request as the response
body was duplicated between the processes. This was especially visible
in the case of that memory leak in Node.js 18.16 as it grew memory usage
on both sides quickly.

In the process of going through these changes I found a couple of other
bugs like the propagation of values to the worker processes not being
awaited
([link](https://github.com/vercel/next.js/pull/53523/files#diff-0ef09f360141930bb03263b378d37d71ad9432ac851679aeabc577923536df84R54))
and the dot syntax for propagation was not functioning.

It also seemed there were a few cases where watchpack was used that
would cause many more files to be watched than expected, for now I've
removed those cases, specifically the "delete dir while running" and
instrument.js hmr (instrument.js is experimental). Those tests have been
skipped for now until we can revisit them to verfiy it

I've also cleaned up the types a bit while I was looking into these
changes.

### Improvement

⚠️ Important preface to this, measuring memory usage / peak usage is not
super reliable especially when JS gets garbage collected. These numbers
are just to show the rough percentage of less memory usage.

#### Baseline

Old:

```
next-server: 44.8MB
next-router-worker: 57.5MB
next-render-worker-app: 39,6MB
next-render-worker-pages: 39,1MB
```

New:

```
next-server: Removed
next-router-worker: 64.4MB
next-render-worker-app: 43.1MB (Note: no changes here, this shows what I meant by rough numbers)
next-render-worker-pages: 42.4MB (Note: no changes here, this shows what I meant by rough numbers)
```

Overall win: ~40MB (process is removed)

#### Peak usage

Old:

```
next-server: 118.6MB
next-router-worker: 223.7MB
next-render-worker-app: 32.8MB (I ran the test on a pages application in this case)
next-render-worker-pages: 101.1MB
```

New:

```
next-server: Removed
next-router-worker: 179.1MB
next-render-worker-app: 33.4MB
next-render-worker-pages: 117.5MB
```

Overall win: ~100MB (but it scales with requests so it was about ~50% of
next-router-worker constantly)

Related: #53523

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-08-08 16:06:32 +02:00
Zack Tanner
fef6f82aba
Add docs page for uncaught DynamicServerErrors (#53402)
When using imports from `next/headers` in a layout or page,
`StaticGenerationBailout` will throw an error to indicate Next.js should
fallback to dynamic rendering. However, when async context is lost, this
error is uncaught and leads to a confusing error message at build time.

This attempts to improve DX surrounding this error by linking out to a
page that explains when it might happen. I've also tweaked
`StaticGenerationBailout` to always throw a fully descriptive reason as
opposed to just `DynamicServerError: Dynamic server usage: cookies`

Closes NEXT-1181
Fixes #49373

---------

Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-08-08 12:49:53 +02:00
Balázs Orbán
b41497d763
fix(next/image): don't call ReactDOM.preload if missing, such as jest (#53443)
### What?

`ReactDOM.preload` is available in `react-dom@experimental` builds. If it's not available, we should fall back to `Head`+`link`

### Why?

Since `ReactDOM.preload` is only available in `react-dom@experimental` builds, certain environments (like Jest or [Storybook](https://github.com/storybookjs/storybook/issues/23661)) might have a version of `react-dom` installed that won't work with `preload()`

### How?

Closes NEXT-1482
Fixes #53272

See also: https://github.com/storybookjs/storybook/issues/23661

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-08 01:04:40 +00:00
vinay
c669c383a0
(example) update github-pages example (#52168)
Removed `appDir: true` from experimental flag and code refactor.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-07 22:35:06 +00:00
JJ Kasper
1283270a5b
Update env variable for fonts data workflow (#53701)
Removes temporary token in favor of permanent one also updates diffing logic.

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-08-07 22:07:50 +00:00
Jiachi Liu
9035f14dda
Fix not-found rendering in production with edge (#53687)
Edge runtime doesn't have `/404` entry points as not-found, if server hits 404 it's hitting `/_not-found` entry point of edge bundles unlike nodejs server rendering.

In app-render it needs the information that when `pathname` (or can call `pagePath`) is `/404` it can render the `not-found.js` components properly

Separate the not-found test suite into 2 parts, a basic case testing all urls with `not-found.js` boundary, and another conflict route case with `not-found.js` with `not-found/` route at the same time

Fixes #53652
Fixes #53210
2023-08-07 20:05:22 +00:00
Janicklas Ralph
033732a3e5
Adding GoogleMaps and Youtube embed components (#52909)
Adding GoogleMapsEmbed and YoutubeEmber components into `@next/third-parties`
Adding tests and README
Each component is tagged with `data-ntpc` attribute

cc: @kara @housseindjirdeh @huozhi @gnoff 




Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2023-08-07 19:38:13 +00:00
Tobias Koppers
4b78349048
fix azure test cases (#53692) 2023-08-07 19:15:18 +00:00
Tobias Koppers
654bd8c803
add unit test case for next.rs api (#53679)
### What?

unit test for next.rs api

### Why?

ensure that it's working

### How?
2023-08-07 19:26:44 +02:00
Steven
7ec76eb7e4
fix(create-next-app): fix CI defaults (default to typescript) (#53686)
Since the default for `create-next-app` has been TypeScript for some time, we should make sure this is also the case for CI.

This PR also makes sure that CI will use the same value as if the question was asked. Therefore changing defaults in the future will automatically change the behavior of CI defaults.

- Related https://github.com/vercel/next.js/issues/42592
2023-08-07 17:24:45 +00:00
Jude Gao
de0ff6fd59
Fix doc grammatical errors (#53672)
### Improving Documentation

- Ran `pnpm prettier-fix`
2023-08-07 16:24:42 +00:00
Thomas Knickman
3db5c16546
fix(node): pnpm 8.6 needs node 16.14 (#53677)
The `pnpm` version was recently updated to `8.6`, however the node version was left at `16.8`. `pnpm@8.6` requires at least `node@16.14` ([source](https://github.com/pnpm/pnpm/blob/main/pnpm/package.json#L145)).

This fixes the engines spec to avoid conflicting versions.
2023-08-07 15:15:26 +00:00
Alex Kirszenberg
589150184e
Turbopack: Hide Turbo Engine internals (#53007)
See https://github.com/vercel/turbo/pull/5584
2023-08-07 14:55:13 +00:00
Jonathan Steele
786812d214
docs(with-stripe-typescript): Update README demo link (#53662) 2023-08-07 08:58:02 -05:00
Tobias Koppers
87aa5dc613
enable more test cases for next.rs api (#53670)
### What?

more tests
2023-08-07 15:17:23 +02:00
vercel-release-bot
5ea372d642 v13.4.14-canary.0 2023-08-07 12:49:08 +00:00
Tobias Koppers
25e6db4274
Turbopack: add edge app routes (#53387)
### What?

* adds middleware manifest and other missing items for edge app routes
* fixes react-server condition in edge context
* fixes node.js route context

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
2023-08-07 13:00:06 +02:00
Alex Kirszenberg
9483ff170a
Initial HMR Nexturbo API implementation (#52950)
This implements a MVP of HMR. HMR works similarly as in turbopack-dev-server, but instead of going through the router to retrieve output assets, output assets are eagerly stored into a global hash map, and retrieved directly from there (see `VersionedContentMap`).

This will require some more glue on the Next.js side in order to handle:
* RSC headers;
* handling Turbopack subscriptiob HMR events from the Next.js WS server, proxying them to `hmr_events`, and sending back the stream of updates.

There's currently no way to evict deleted output assets, nor to communicate these events to the client. @sokra mentioned the `VersionedContentMap` could store a list of assets per entrypoint, instead of having a top-level flat map.

Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
2023-08-07 10:37:57 +00:00
yudai yamamoto
b993afbf7c
Fix action failures due to state tree encoding (#53655)
fixes #53654

### Related PRs
- #51017
2023-08-07 10:02:48 +00:00
Arpit Patidar
78b04980be
update eslint config (#53637)
## Fixing a bug
- I checked the eslint config and found that override property is not supposed to be inside another override property.
- I couldn't checked the entire file as it was a big config file, but I guess it was supposed to be a part of global overrides array of eslint.

Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
2023-08-07 09:41:14 +00:00
vercel-release-bot
498692b698 v13.4.13 2023-08-07 06:57:47 +00:00
Shen Lu
0363cef4c0
Fix: missing equal sign (#53650)
Missing an equal sign in Image docs

1e02a92a94/docs/02-app/02-api-reference/01-components/image.mdx (L690)
2023-08-07 01:52:37 +00:00
vercel-release-bot
1e02a92a94 v13.4.13-canary.18 2023-08-07 01:06:01 +00:00
JJ Kasper
3c55417f16
Update font data (#53649)
This auto-generated PR updates font data with latest available

Co-authored-by: vercel-release-bot <infra+release@vercel.com>
2023-08-06 17:54:10 -07:00