Commit graph

20978 commits

Author SHA1 Message Date
Sebastian Silbermann
a25e7d2fe9
Update React from 04b058868c to 81c5ff2e04 (#65869) 2024-05-22 14:46:57 +02:00
JJ Kasper
7e34b4cf98
Tweak flakey metadata error tests (#66060)
Seems we weren't grabbing the latest cli output inside of `check` so if
it wasn't ready by the time the first check successive checks wouldn't
have it either.

x-ref:
https://github.com/vercel/next.js/actions/runs/9182806177/job/25253023758
x-ref:
https://github.com/vercel/next.js/actions/runs/9182324607/job/25254072867
2024-05-21 21:53:16 -05:00
vercel-release-bot
d299bbf431 v14.3.0-canary.76 2024-05-21 23:23:05 +00:00
Will Binns-Smith
35d300e5cc
Add dedicated client entry for Turbopack builds (#65824)
Previously with Turbopack, we would attempt to establish a websocket
connection to the HMR server, even when running production builds. This
adds `next-turbopack.ts`, which includes the necessary runtime code for
Turbopack, but does not include HMR code.

Test Plan: `TURBOPACK=1 TURBOPACK_BUILD=1 pnpm next build
test/e2e/app-dir/app-middleware`

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-05-21 22:43:41 +00:00
vercel-release-bot
22f822ebb7 v14.3.0-canary.75 2024-05-21 21:18:04 +00:00
Sebastian Silbermann
99f59438c3
Improve sync-react changelog generator (#66051) 2024-05-21 21:10:08 +00:00
Zack Tanner
1f545aff05
[Breaking] disable client router cache for page segments (#66039)
This configures the default client router cache `staleTime.dynamic`
value to be `0`.

This means that:
- Navigating between pages will always fire off a network request to get
RSC data for the page segment, rather than restoring from router cache
- Loading states will remain cached for 5 minutes (or whatever
`config.experimental.staleTimes.static` is set to)
- Shared layout data will continue to remain cached due to [partial
rendering](https://nextjs.org/docs/app/building-your-application/routing/linking-and-navigating#4-partial-rendering)
- Back/forward behavior will still restore from cache to ensure the
browser can restore scroll position.

It's possible to opt-out of this, and into the previous behavior, by
setting the
[`staleTimes`](https://nextjs.org/docs/app/api-reference/next-config-js/staleTimes)
config in `next.config.js`:

```js
/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    staleTimes: {
      dynamic: 30
    },
  },
}

module.exports = nextConfig
```

<!-- 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 #

-->
2024-05-21 13:54:23 -07:00
qqww08
16c4e47c14
Update Google Analytics example for App Router (#66021)
<!-- 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 #

-->
Hello 

This PR updates the `with-google-analytics` example to use:
- App Router
- TypeScript
- @next/third-parties

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-21 20:47:09 +00:00
vercel-release-bot
5cba51e342 v14.3.0-canary.74 2024-05-21 19:54:31 +00:00
Tim Neutkens
413d1223d8
Upgrade lightningcss, disable grid prefixing (#65986)
## What?

Requires https://github.com/vercel/turbo/pull/8176 first.

Grid scoping in CSS Modules is disabled because Webpack CSS Modules
handling doesn't handle grid currently. This ensures moving from Webpack
to Turbopack doesn't have mismatching behavior around CSS grid.

Fixes #64509
Fixes #63758
Fixes PACK-2976

<!-- 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 #

-->
2024-05-21 19:39:46 +00:00
OJ Kwon
39bd310b57
ci(workflow): skip building next-swc with latest turbopack (#66048)
### What

this was the way we run ci on turbopack's repo and to get the latest
test results, which isn't required anymore.
2024-05-21 18:45:13 +00:00
JJ Kasper
4818c4c32f
Revert webpack bundling layer changes for middleware/pages (#66049)
This reverts the below changes to avoid a breaking change in pages with
importing `react-dom/server` as this is disallowed in `app` but
shouldn't be in `pages`.

Revert "Bundle the installed react for middleware (#65811)"
Revert "Error in build for middleware when import client-only (#65792)"

This reverts commit fdd8f0c65f.
This reverts commit 082072ca95.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03S8ED1DKM/p1716305493514869)
2024-05-21 18:31:31 +00:00
Will Binns-Smith
5c9949386c
Update lightningcss to 1.0.0-alpha.56 (#66046)
To sync with Turbopack.

x-ref: vercel/turbo#8176
2024-05-21 18:28:59 +00:00
yasmin p
a38caf402b
Update create-next-app template CSS (#66043)
Updates the `create-next-app` template CSS to:
- Prevent browsers (e.g. Safari) from using synthetic bold font weights
- Move CSS variables out of global CSS / Tailwind config, to simplify
the process of wiping the default template.

<!-- 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: JJ Kasper <jj@jjsweb.site>
2024-05-21 18:27:40 +00:00
JJ Kasper
1ad97e42f2
Fix swc test path from node_modules (#66047)
Noticed while testing turbopack version of tests that we weren't loading
the correct swc binary since this path wasn't absolute and was just the
relative path in `node_modules`.

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-21 11:01:35 -07:00
Vercel Release Bot
93303b41b9
Update Turbopack development test manifest (#66044)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-05-21 17:44:30 +00:00
Steven
9d70996ee9
chore(docs): remove suggestion of manually installing sharp (#66034)
Users no longer need to install `sharp` manually thanks to the
following:

- https://github.com/vercel/next.js/pull/63321
2024-05-21 15:42:55 +00:00
Janka Uryga
bd2520a7d3
Add missing 'prerenderEarlyExit: false' in tests (#66032)
Since, https://github.com/vercel/next.js/pull/65830, I've been seeing
weird flakes from
`test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts`.
```
TIMED OUT: /Invalid revalidate value "1" on "\/", must be a non-negative number or "false"/
```

The build output looks like this:

```
  ▲ Next.js 14.3.0-canary.73

   Creating an optimized production build ...
   
[snip]

Error: Invalid revalidate value "1" on "/_not-found", must be a non-negative number or "false"

[snip]

     Generating static pages (2/4) 
  > Build error occurred
  Error: Export encountered an error on /_not-found, exiting due to prerenderEarlyExit: true being set
```
Note that there's no `Invalid revalidate value "1"` message for `/`, so
the test will fail.

This looks like a race condition: the invalid `revalidate` value is set
in a layout, so if `_not-found` happens to be prerendered before `/`,
it'll abort the whole prerender (because of `prerenderEarlyExit: true`).
so if the timing is right, the test -- which is looking for build errors
for `/` -- will never see them and time out.

There might be more of these, but unfortunately they're basically race
conditions, so I think we'll have to squash them as they come up.

CC @ijjk
2024-05-21 07:51:38 -07:00
Niaz Morshed Nayeem
03f34f2d52
Fix typo in JSDoc of ppr flag of next.config.js (#66028) 2024-05-21 16:16:36 +02:00
Janka Uryga
7507f1b2e6
add pre-push hook to guard against accidental pushes directly to canary (#66030)
We allow users in the Next.js team to push directly canary in order to allow emergency fixes (and, AFAIU, some other things in GH workflows). This PR adds a guardrail to prevent absentminded people from doing it by accident, requiring a 'git push --no-verify' to bypass the hook.
2024-05-21 12:54:05 +02:00
Janka Uryga
4c702392d8 add missing "prerenderEarlyExit: false" to dynamic-data test 2024-05-21 12:08:37 +02:00
Sebastian Silbermann
e7065a951c
Include base commit in changes included by a React sync (#65868)
Include the base commit in the generated changelog for React syncs.
2024-05-21 11:16:22 +02:00
Vercel Release Bot
af49a5b54c
Update Turbopack production test manifest (#66007)
This auto-generated PR updates the production integration test manifest
used when testing Turbopack.
2024-05-20 21:08:22 -07:00
Lee Robinson
da8fb8ebc8
docs: Update Route Handlers docs for dynamic (#66010)
- Remove unnecessary `dynamic` route segment configs
- Add version history
- Remove caching opt-out section, since it's dynamic now

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-20 22:40:05 -05:00
Jude Gao
d498f9c173
Fix router.refresh missing canonical url override (#65999)
Fixes https://github.com/vercel/next.js/issues/65970

----

The browser update happens at
10d5c278bc/packages/next/src/client/components/app-router.tsx (L685),
which sets the browser location to `canonicalUrl`. `canonicalUrl` was
correctly set at
ab03c3261f/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts (L98),
but then mistakenly overriden at
51549d92de/packages/next/src/client/components/router-reducer/reducers/refresh-reducer.ts (L129).

This PR fixes that and includes an E2E test to prevent future
regression.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-20 18:11:07 -07:00
Vercel Release Bot
b6a72f3932
Update Turbopack development test manifest (#66002)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-05-20 17:17:17 -07:00
JJ Kasper
6f9c4720f9
[Breaking] Disable automatic static generation for route handlers (#65825)
## Background

Currently route handlers will be attempted to statically generate the
same as normal pages in app router. If a route handler accessed dynamic
data such as `cookies()`, `headers()`, `req.url`, or similar we would
bail from this static generation but this didn't handle the case where
you would do data fetching via a non-fetch based library e.g. `redis` or
even using `Date.now()` or `Math.random()` so users would expect these
to be run every request like normal API endpoints but they would be
static so wouldn't be executed again after a build.


## New Behavior

As discussed this disable the default static generation handling for
route handlers as we've seen this confuse our users since in most cases
when creating a route handler you are handling dynamic workloads. This
doesn't remove the ability to static generate route handlers though as
you can still manually specify:

If you specify `export const revalidate = 1` we will still bail if
dynamic data is accessed to prevent accidental `revalidate` configuring
but this can be avoided via `force-static` being used as well.
 
```js
export const dynamic = 'force-static'
// or
export const dynamic = 'error'
// or
export const revalidate = false
// or
export const revalidate = 1 // value great than 0
// or 
export const generateStaticParams() {}
```

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-20 16:25:02 -07:00
vercel-release-bot
49c1e127aa v14.3.0-canary.73 2024-05-20 23:23:18 +00:00
Will Binns-Smith
4ff11d0631
Turbopack: Implement next/font/local with BeforeResolvePlugin and show custom error message (#65870)
Depends on vercel/turbo#8165

This:
- Creates and uses a `BeforeResolvePlugin` to handle requests to
`next/font/local/target.css` instead of `ImportMapping` replacers
- Returns a `ResolveResultItem::Error` which includes a custom
`StyledString` describing the missing font file

Test Plan: `TURBOPACK=1 pnpm test-dev
test/e2e/app-dir/next-font/next-font.test.ts`
2024-05-20 15:46:19 -07:00
Sam Ko
325a490616
chore(github-workflow): move issues, prs, features to #next-info channel (#65991)
## Why?

Moving these cron updates to a different channel to create less noise.
2024-05-20 22:23:33 +00:00
Arindam Majumder
60ad8affd7
feat: Add option to enable Turbopack with create-next-app (#65926)
This PR addresses an issue where the `dev` script in `package.json` was
not correctly updated to use the `--turbo` option when specified. The
changes ensure that the `dev` script is set to `next dev --turbo` if the
`turbo` option is enabled.

### Changes:
1. **Function Modification**:
- Updated the `modifyPackageJson` function to include a check for the
`turbo` parameter.
- If `turbo` is true, the `dev` script in `package.json` is set to `next
dev --turbo`.
   - If `turbo` is false, the `dev` script remains `next dev`.

2. **Integration in App Creation**:
- Integrated the `modifyPackageJson` function into the app creation
process to ensure the `dev` script is correctly set based on the `turbo`
parameter.

### Testing:
- Verified that the `dev` script in `package.json` is correctly updated
to `next dev --turbo` when the `turbo` option is enabled.
- Ensured that the `dev` script remains `next dev` when the `turbo`
option is not enabled.

### Related Issues:
- Fixes #65924

### Notes:
- This change ensures that developers opting to use Turbopack for
development will have the correct script set up automatically.

---------

Signed-off-by: Arindam Majumder <arindammajumder2020@gmail.com>
Co-authored-by: Lee Robinson <me@leerob.io>
Co-authored-by: devjiwonchoi <devjiwonchoi@gmail.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-20 20:34:24 +00:00
Zack Tanner
0eedddbf89
short-circuit OPTIONS requests to pages (#65295)
Currently `OPTIONS` requests to page handlers (eg `pages/foo.tsx` or
`app/foo/page.tsx`) will respond as though it's handling a `GET`
request. There should be no reason for these routes to handle `OPTIONS`
requests as the only valid option is `GET`.

We do not need to special-case actions here because those will always be
invoked from the same origin as the canonical browser URL.

<!-- 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 #

-->


Closes NEXT-3305
2024-05-20 19:58:48 +00:00
JJ Kasper
c5a0878946
Change default of prerenderEarlyExit to true (#65830)
## Background

Historically during prerendering we have waiting until all paths have
been attempted before we exit the process and fail the build. This is
nice if you want to collect all potential errors to address them at the
same time although this has the drawback of slowing down builds if
things are timing out or if the same error is occurring across numerous
paths.

## New Behavior

This changes our default behavior to immediately exit when the first
error occurs during prerendering so that builds don't stall out from
timeout errors or from the same error occurring across numerous paths.
This will help from holding up CI or similar un-necessarily.

If users want to opt-in to the previous behavior the flag is still
present under `experimental.prerenderEarlyExit`.
2024-05-20 12:51:01 -07:00
Jam Balaya
03026eb2ef
fix(docs): update styled components option (#65718)
To [Port babel-plugin-styled-components to
SWC](https://github.com/vercel/next.js/issues/30802) was completed,
apply and re-order options.

<!-- 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: Sam Ko <sam@vercel.com>
2024-05-20 19:35:20 +00:00
Niaz Morshed Nayeem
e1e197a104
Add additional log to experimental ppr flag in next.config.js (#65944)
### What?

This PR adds an additional log that describes the function of the `ppr`
flag in `next.config.js`.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-20 09:22:10 -07:00
Jiwon Choi
79c934aaec
fix(next): initial prefetch cache not set properly with different search params (#65977)
cc @icyJoseph @ztanner

NOTE: The canary release
[`v14.1.1-canary.51`](https://github.com/vercel/next.js/releases/tag/v14.1.1-canary.51)
and below work as expected.

### Why?

Introduced from #61535, the initial prefetch cache is set based on the
`location.pathname`.
When a page is loaded WITH the search param, the cache key does not
contain information of the search param.

The issue is when on a dynamic page reading the `searchParams` value,
the value doesn't change if navigated as:

```
/?q=foo --> /
```

The prefetch cache hits, not re-rendering, and the `searchParams` value
is not passed properly.

### How?

For the prefetch cache, add the `location.search` as well.

Since `createPrefetchCacheKey` uses
[`createHrefFromUrl`](https://github.com/vercel/next.js/blob/canary/packages/next/src/client/components/router-reducer/create-href-from-url.ts)
which includes `location.search`, I'm expecting the change won't affect
current cache key behavior.

Fixes #64170
Fixes #65030

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-05-20 15:44:03 +00:00
Niko Sams
8a429e083e
Fix revalidateTimings route for catchall index route (#65843)
fixes #65842

When setting revalidateTimings correctly use toRoute to convert `/index`
to `/`, like done for get
(https://github.com/vercel/next.js/blob/canary/packages/next/src/server/lib/incremental-cache/index.ts#L213)

See #65842 for reproduction codesandbox.

The bug also exists in 14.2.3 (and below) - before #64370

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-20 15:13:07 +00:00
Janka Uryga
663488cf52
unstable_after: support nested unstable_after calls (#65950)
Adds support for nested `unstable_after()`.

This pattern previously threw a "Not supported yet" error, but works
now:

```js
function MyComponent() {
  after(() => asyncWork());
  return <div>...</div>
}

async function asyncWork() {
  after(() => { /* look ma, nesting!*/ })
  // more stuff...
}
```

### Implementation notes
Switched `AfterContext` to use a proper promise queue
([`p-queue`](https://www.npmjs.com/package/p-queue)) instead of plain a
callback array to support adding more callbacks as we execute (i.e. from
nested `after`s). Used a package because I didn't want to reinvent the
wheel here.

As a nice bonus, `p-queue` lets us limit the concurrency of running
tasks if we're worried about resource consumption. **This PR doesn't do
that**, but it's very easy to add. That could be controlled via
`process.env.NEXT_AFTER_MAX_CONCURRENT_TASKS`, a next.config.js option
(`unstable_after: { maxConcurrentTasks: 5 }`), or something like that.
2024-05-20 15:09:16 +00:00
Lee Robinson
a142012428
docs: clarify gSSP docs for runtime (#65962)
Replaces https://github.com/vercel/next.js/pull/65948.
2024-05-20 09:50:58 -05:00
Vercel Release Bot
f95656a4ca
Update font data (#65961)
This auto-generated PR updates font data with latest available

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-05-20 14:35:39 +00:00
Lovell Fuller
dd8ee527b8
fix(next/image): prefer sharp defaults, use mozjpeg for JPEG (#65846)
### What?

Upgrades sharp to the latest version and relies on more of its default
settings (if the default settings are unsuitable, we should consider
improving these for all users in sharp itself).

- The `sequentialRead` setting is now managed for you based on each
input image and the operations to be applied to it.

- The concurrency detection is more accurate than `os.cpus()` as it now
inspects things like CPU set/affinity as well as the memory allocator.

- The (mostly archaic) concept of chroma subsampling is not required for
AVIF output. Using full chroma should improve the quality of red/orange
edges, as well as slightly reducing file size as it allows greater use
of AV1 chroma-from-luma prediction.

In addition, this PR also enables the use of mozjpeg features such as
trellis quantisation to produce smaller file sizes. The use of `mozjpeg:
true` infers `progressive: true`. This aligns JPEG output behaviour with
the previously-used squoosh, which always used mozjpeg.

/cc @styfle
2024-05-20 09:30:09 -04:00
vercel-release-bot
14a98734e3 v14.3.0-canary.72 2024-05-20 10:35:37 +00:00
Janka Uryga
79bebe7bd3
experimental: unstable_after (#65038)
Implements `unstable_after`, which lets the user schedule work to be
executed after the response is finished.

### Implementation notes

- `unstable_after()` is a dynamic function (bypassable only with `export
dynamic = "force-static"`)
- Usable in: server components (including `generateMetadata`), actions,
route handlers, middleware
- It is meant to run its callbacks even if a response didn't complete
successfully (thrown error) or called `notFound()`/`redirect()`
- Currently gated behind a `experimental.after` feature flag, because it
touches many runtime bits (including a React monkeypatch...)
- The state for `unstable_after()` in a given request lives in
`requestAsyncStorage` (added via `RequestAsyncStorageWrapper`)

- the implementation is based around two functions that we inject via
`renderOpts`:
- `waitUntil(promise)` - keep a function invocation alive until a
promise settles. it is provided as a platform primitive in serverless
contexts, and a noop in `next start`
- for serverless (nodejs), Next.js will attempt to get `waitUntil` from
`globalThis[Symbol.for('@next/request-context')].get().waitUntil`. This
should be considered unstable for now. See
`packages/next/src/server/after/wait-until-builtin.ts` for details.
- `onClose(callback)` **[NEW]** - run something when a response is done.
basically `res.on('close', callback)`, but also implemented for Web APIs
- unfortunately, for Web, this requires some potentially expensive
tricks - see `packages/next/src/server/web/web-on-close.ts`
2024-05-20 08:49:53 +00:00
vercel-release-bot
3843166730 v14.3.0-canary.71 2024-05-18 23:21:55 +00:00
Arinjay Dhar
695aec91cb
Mention Renaming of useFormState (#65934)
The useFormState hook was renamed to useActionState in react 19. At this
moment react 19 is still in Canary, it would be hard for beginners to
realise this.

Mentioning the fact of it being renamed will ideally help new people.

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-18 19:16:34 +00:00
Tim Neutkens
aae77765e1
Fix send-trace-to-jaeger boolean span values (#65920)
Jaeger does not support booleans as span values and will throw an error.
This ensures the boolean values are turned into strings.

<!-- 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 #

-->
2024-05-18 18:46:24 +02:00
Joseph
0cd20e0ea5
chore: Bump react-modal to 3.16.2 in with-router-as-modal example (#65841)
### What?

Example update to `with-route-as-modal`, which used `react-modal@13.1.2`

### Why?

The `react-modal` version specified, did not include react 18 as
peer-dependency.

This causes users to have problems when creating the example:
https://github.com/vercel/next.js/discussions/65835

### How?

Bump version to latest available, 13.16.1.

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-17 22:56:40 -07:00
日高 凌
6a80f2b25d
Docs: Replace "twitter.com" to "x.com" (#65917)
### What?
Replace `twitter.com` links in the docs with `x.com`

### Why?
Now that Twitter (twitter.com) has officially moved to the x.com domain

### How?
- Replace the link, then click on the link to make sure there are no
problems

Closes NEXT-
Fixes #65916

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-05-18 05:49:49 +00:00
yasmin p
c0b3f430ed
Update create-next-app template (#65803)
Updates the `create-next-app` template with a new design by @evilrabbit.

#### Updated template
![new —
light](https://github.com/vercel/next.js/assets/22132822/7abf8ac5-e2c5-4d2d-944a-53616dcae5ed)
![new —
dark](https://github.com/vercel/next.js/assets/22132822/a06a948d-6071-4a44-9c7e-9a5077866b0a)

#### Previous template
![old —
light](https://github.com/vercel/next.js/assets/22132822/49c97cdf-46ae-4d28-88c7-52fe0e9c995b)
![old —
dark](https://github.com/vercel/next.js/assets/22132822/fb028dda-a38a-443c-ad13-21886b750d7a)

<!-- 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: Sam Ko <sam@vercel.com>
2024-05-17 22:33:19 -07:00
vercel-release-bot
9c31149967 v14.3.0-canary.70 2024-05-17 23:23:12 +00:00