Commit graph

5719 commits

Author SHA1 Message Date
Tim Neutkens
1bce086a55
Fix next-swc native binary write in tests (#64744)
## What?

In the past folks on the team have reported that anytime the SWC /
Turbopack binary changes they had to suddenly run `pnpm build-native` in
`packages/next-swc`, even though they didn't build from source before.
While investigating optimizing packing for tests I found that it's
copying the native binary into the original repository not the temporary
repository, which then keeps the file there, even after the tests
finish. This fixes the path to use the tmp repository instead.


<!-- 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-3157
2024-04-18 11:43:51 -07:00
Zack Tanner
39661815d8
prevent erroneous route interception during lazy fetch (#64692)
When the router cache can't find a cache node for the requested segment,
it performs a request to the server to get the missing data. This
request to the server currently will always include the `next-url`
header, and on soft-navigations, the router will route the request to
the intercepted handler. This lazy fetch is treated as a soft navigation
by the server, and will incorrectly return data for the intercepted
route.

Similar to the handling in `router.refresh`, and the server action
reducer, we should not include the `next-url` header if there's no
interception route currently in the tree, as otherwise we'll be
erroneously triggering the intercepted route.

Fixes #64676
Closes NEXT-3146
2024-04-18 13:22:13 +00:00
Vercel Release Bot
c14c0bd3c7
Update Turbopack development test manifest (#64709)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-04-18 10:59:50 +02:00
Zack Tanner
10d5c278bc
Revert "fix TypeError edge-case for parallel slots rendered multiple times" (#64690)
Reverts vercel/next.js#64271

This appears to be causing problems rendering error boundaries on SPA
navigations and needs further investigation

Closes NEXT-3150
2024-04-17 23:45:20 +00:00
Jiachi Liu
81defe2b6d
Fix: resolve mixed re-exports module as cjs (#64681)
### Why

If you have a client entry that mixing `default` re-export and `*`
re-export, atm we cannot statically analyze all the exports from this
the boundary, unless we can apply barrel file optimization for every
import which could slow down speed.

```js
// index.js
'use client'
export * from './client'
export { default } from './client'
```

Before that happen we high recommend you don't mixing that and try to
add the client directive to the leaf level client module. We're not able
to determine what the identifiers are imported from the wildcard import
path. This would work if we resolved the actual file but currently we
can't.

### What

When we found the mixing client entry module like that, we treat it as a
CJS client module and include all the bundle in client like before what
we have the client components import optimization.

Ideally we could warn users don't apply the client directive to these
kinda of barrel file, and only apply them to where we needed.


Fixes #64518 
Closes NEXT-3119
2024-04-18 01:06:29 +02:00
JJ Kasper
3aa3f51f2d
Revert "chore(test): run related E2E deploy tests on PRs" (#64682)
Reverting for now as this is failing on all PRs 

Reverts vercel/next.js#63763

Closes NEXT-3147

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1713391373933249)
x-ref: [slack
thread](https://vercel.slack.com/archives/C04KC8A53T7/p1713385017892539)
2024-04-17 22:40:21 +00:00
Patrick Dahms
048697bd55
fix(next-server): 'quiet' setting delegate for custom server (#64512)
## Info

I did not create a GitHub issue, but this PR for fixing the issue. Hope
that's okay.

## The bug

We run a 'normal' custom server described here:
https://nextjs.org/docs/pages/building-your-application/configuring/custom-server

```ts
const next = require('next');
const dev = process.env.NODE_ENV !== 'production';
const port = 3000;
const app = next({ dev, port, quiet: !dev })
const handle = app.getRequestHandler()
// ...
```

The `quiet` settings is missed in some deeper Next.js internal api
calls. For that reason, the setting did not work at all. This works only
in production mode.

## Testing

I tried to implement a test in `/test/production/custom-server` but I
failed to get the `stderr` messages. When someone give me some guidance,
I will add a new test.

Here are some criteria:

- need: custom server with `quiet: true` setting
- need: a next.js page with thrown error. e.g. `export const
getServerSideProps = () => { throw new Error('failed') }`
- need: collect all `stderr` messages

I tested the fix in our project by editing the files in `node_modules`
-- it worked.

## Background

We upgrade our project from next `13.3.4` to `14.2.0` and saw this
regression. I can not tell in which version this bug was added. We run a
Next.js + 'custom server' + Docker setup. Because we have a lot of
traffic, we need to suppress the standard Next.js logging and using our
own logging.


<!-- 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-04-17 13:07:50 -07:00
Jiachi Liu
1e3a1cbaab
Upgrade typescript to 5.3 (#64043)
Closes NEXT-2997

---------

Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
2024-04-17 18:35:29 +02:00
Tim Neutkens
1fd93eed90
Improve top level await coverage (#64508)
## What?

- Changes webpack output target to `es6` (required for `async function`
output)
- Adds tests for top level await in server components and client
components (App Router)
- Converted the async-modules tests to `test/e2e`
- Has one skipped test that @gnoff is going to look into. This shouldn't
block merging this PR 👍


Adds additional tests for top level `await`.

Since [Next.js
13.4.5](https://github.com/vercel/next.js/releases/tag/v13.4.5) webpack
has top level await support enabled by default.

Similarly Turbopack supports top level await by default as well.

TLDR: You can remove `topLevelAwait: true` from the webpack
configuration.


In writing these tests I found that client components are missing some
kind of handling for top level await (async modules) so I've raised that
to @gnoff who is going to have a look.

<!-- 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-3126
Fixes https://github.com/vercel/next.js/issues/43382
2024-04-17 17:44:40 +02:00
Balázs Orbán
3192172898
chore(test): run related E2E deploy tests on PRs (#63763) 2024-04-17 11:06:23 +00:00
Shu Ding
754fadacf3
Revert "fix(next): global not-found not working on multi-root layouts" (#64601)
Reverts #63053.

Closes NEXT-3135
2024-04-17 11:19:18 +02:00
Jiachi Liu
8b82225fea
Fix ASL bundling for dynamic css (#64451)
### Why

For app page rendering on edge, the `AsyncLocalStorage` (ALS) should be
bundled as same instance across layers. We're accessing the ALS in
`next/dynamic` modules during SSR for preloading CSS chunks. There's a
bug that we can't get the ALS store during SSR in edge, I digged into it
and found the root cause is:

We have both import paths:
`module (rsc layer) -> request ALS (shared layer)`
`module (ssr layer) -> request ALS (shared layer)`

We expect the ALS to be the same module since we're using the same layer
but found that they're treated as different modules due to applying
another loader transform on ssr layer. They're resulted in the same
`shared` layer, but with different resource queries. This PR excluded
that transform so now they're identical across layers.


### What

For webpack, we aligned the loaders applying to the async local storage,
so that they're resolved as the same module now.

For turbopack, we leverage module transition, sort of creating a new
`app-shared` layer for these modules, and apply the transition to all
async local storage instances therefore the instances of them are only
bundled once.
To make the turbopack chanegs work, we change how the async local
storage modules defined, separate the instance into a single file and
mark it as "next-shared" layer with import:

```
any module -> async local storage --- use transition, specify "next-shared" layer ---> async local storage instance
```

Closes NEXT-3085
2024-04-17 10:18:09 +02:00
Zack Tanner
f93ae7c89e
fix TypeError edge-case for parallel slots rendered multiple times (#64271)
### What
When rendering a parallel slot multiple times in a single layout, in
conjunction with using an error boundary, the following TypeError is
thrown:

> Cannot destructure property 'parallelRouterKey' of 'param' as it is
null

### Why
I'm not 100% sure of the reason, but I believe this is because of how
React attempts to dededupe (more specifically, "detriplficate") objects
that it sees getting passed across the RSC -> client component boundary
(and an error boundary is necessarily a client component). When React
sees the same object twice, it'll create a reference to that object and
then use that reference in future places where it sees the object. My
assumption is that there's a bug somewhere here, as the `LayoutRouter`
component for the subsequent duplicated parallel slots (after the first
one) have no props, hence the TypeError.

### How
Rather than passing the error component as a prop to `LayoutRouter`,
this puts it as part of the `CacheNodeSeedData` data structure. This is
more aligned with other properties anyway (such as `loading` and `rsc`
for each segment), and seems to work around this bug as the
`initialSeedData` prop is only passed from RSC->client once.

EDIT: Confirmed this is also fixed after syncing the latest React, due
to https://github.com/facebook/react/pull/28669

Fixes #58485
Closes NEXT-2095
2024-04-17 01:18:06 +00:00
Zack Tanner
ddf2af59c6
fix incorrect refresh request when basePath is set (#64589)
`initialCanonicalUrl` differs from the `canonicalUrl` that gets set on
the client, such as when there's a basePath set.

This hoists the `canonicalUrl` construction up so we can re-use it when
adding refetch markers to the tree.

This also renames `pathname` -> `path` since it also includes search
params. I added a test to confirm no extra erroneous fetches happened in
both cases.

Fixes #64584


Closes NEXT-3130
2024-04-16 18:01:46 -07:00
Zack Tanner
e9aeb9e1b9
memoize layout router context (#64575)
Since `AppRouterState` is promise-based (so we can `use` the values and
suspend in render), the state itself isn't stable between renders. Each
action corresponds with a new Promise object. When a link is hovered, a
prefetch action is dispatched, even if the prefetch never happens (for
example, if there's already a prefetch entry in the cache, and it
doesn't need to prefetch again). In other words, the prefetch action
will be dispatched but won't necessarily change the state.

This means that these no-op actions that don't actually change the state
values will trigger a re-render. Most of the context providers in
`AppRouter` are memoized with the exception of `LayoutRouter` context.
This PR memoizes those values so that consumers are only notified of
meaningful updates.

Fixes #63159


Closes NEXT-3127
2024-04-16 16:23:39 -07:00
Vercel Release Bot
065cefd29d
Update Turbopack development test manifest (#64579)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-04-16 21:01:48 +02:00
Jiachi Liu
2a1e17063b
fix: filter out middleware requests in logging (#64549)
### What

When middleware.js is present, the logging is duplicated. We should
filter out the 1st middleware request and only log the actual one going
through request handler / renderer

Closes NEXT-3125
2024-04-16 16:17:06 +02:00
Zack Tanner
9fb775e2f8
fix refresh behavior for discarded actions (#64532)
When an action is marked as "discarded", we enqueue a refresh, since the
navigation event will be invoked immediately without waiting for the
action to finish. We refresh because it's possible that the discarded
action triggered some sort of mutation/revalidation, and we want the
router to still be able to respond to that new data.

However there's a bug in this logic -- it'll only enqueue the refresh
action if there were no other actions in the queue, ignoring the case
where something is still in the queue. This makes sure that the refresh
is handled after `runRemainingActions` finishes.

When adding a test for the server component case (which doesn't hit this
refresh branch), I noticed `LayoutRouter` caused React to suspend
indefinitely, because it got stuck in the `use(unresolvedThenable)`
case. We should only suspend indefinitely if we kicked off a the
`SERVER_PATCH` action, as otherwise it's possible nothing will ever
break out of that branch.

Fixes #64517
Closes NEXT-3124
2024-04-16 06:56:48 -07:00
Jiachi Liu
fa30290353
Fix cjs client components tree-shaking (#64558)
## What

Determine if the client module is a CJS file and `default` export is
imported, then we include the whole module instead of using webpack
magic comments to only extract `default` export.

## Why

Unlike ESM, The `default` export of CJS module is not just `.default`
property, we need to include `__esModule` mark along with `default`
export to make it function properly with React client module proxy


Fixes #64518
Closes NEXT-3119
2024-04-16 15:06:42 +02:00
Jimmy Lai
d52d32f423
perf: improve Pages Router server rendering performance (#64461)
### What

This PR's goal is to improve the throughput performance of the Next.js
server when handling Pages Router routes.

Note that the results from this are very synthetic and do not represent
the real-life performance of an application. If we only wanted to handle
hello worlds, we could probably make this even faster but on production,
a slow fetch call to your DB is probably what's slowing you down.

I'll look into App Router next.

### Why?

I guess I got nerd-sniped into it 😃 

### How?

A few optimizations:
- I looked deeply at the pipeline for rendering a Pages Router page. I
noticed a lot of intermediary streams being created here and there to
eventually be concatenated to a simple string. I think this is probably
left over code from when we wanted to support streaming there and so
there's some code that was shared with the App Router, which we
absolutely don't need I think. I refactored it to be slightly simpler
with just a few string concats here and there.
- misc: I removed some redundant Promises being created here and there
and added a small inline optimisation to eliminate `if (renderOpts.dev)`
code in production.

### Nummies

Test setup: hello world pages router app, next start + autocannon

- requests handled in 10s: 18k  -> 33K, **~80% improvement**
- avg latency: 4.89ms -> 2.8ms, **~42% improvement**
- avg req/res: 1846.5 -> 2983.5, **~61% improvement**

Before

<img width="742" alt="image"
src="https://github.com/vercel/next.js/assets/11064311/658e7ade-eba7-4604-a7c9-619bd51a5ec8">

vs

after

<img width="880" alt="image"
src="https://github.com/vercel/next.js/assets/11064311/2f46cf69-b788-4db2-bf90-6f65dc7abd82">




<!-- 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-3103
2024-04-16 14:25:45 +02:00
Vercel Release Bot
abf3ca2d7d
Update Turbopack development test manifest (#64546)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-04-16 10:47:25 +00:00
Tobias Koppers
064788fee3
fix HMR for cases where chunking changes (#64367)
* test case for https://github.com/vercel/turbo/pull/7947
* fix source map retrieval for HMR-updated assets

Closes PACK-2944
2024-04-16 12:36:41 +02:00
Adam Jones
f563940f69
next/script: Correctly apply async and defer props (#52939)
### Summary

Fixes #52935

`next/script` has a `Script` component that supports an `async` prop.
However, when scripts are loaded with the `async` prop set to false, the
script is loaded as if async was set to true. This may cause scripts to
execute out of order. Repro:
https://github.com/domdomegg/next-async-script-reproduction

I think this is occurring because Next uses setAttribute to set the
async and defer attributes. However, this is not a valid way to set
these properties on a script. This is because . Demo:
https://jsfiddle.net/6ktpfae1/

This PR fixes this behaviour by using removeAttribute after calling
setAttribute (rather than using setAttribute "false"). This appears to
result in correct behaviour.

Given it appears this workaround was already applied in `next/head`,
I've harmonised the code between these two.

### Next steps

I think this PR is ready for review. I acknowledge there are no test
changes, but there are no existing tests for `next/script` at all and
creating them I think would be disproportionally difficult given issues
in #52943.

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Sam Ko <sam@vercel.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-15 15:01:50 -07:00
Will Binns-Smith
f79440260c
Turbopack: Allow client components to be imported in app routes (#64520)
Resolves #64412

This adds a client transition to the app route `ModuleAssetContext` and
the corresponding transforms so that client components can be safely
imported and referenced (as their proxies) in app routes.

Test Plan: Added an integration test


Closes PACK-2964
2024-04-15 14:18:56 -07:00
Jiwon Choi
81450de6af
hotfix: hardcoded skip turbopack tests to manifest (#64515)
cc @shuding 

CI run failed after #63053 on turbo production, which had not yet been
targeted for turbo.

x-ref: #63103

---------

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
Co-authored-by: Leah <8845940+ForsakenHarmony@users.noreply.github.com>
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-04-15 19:46:42 +00:00
Tobias Koppers
6178693b39
disable production chunking in dev (#64488)
### What?

The production chunking plugin shouldn't be enabled in development

### Why?

It doesn't handle HMR yet


Closes PACK-2956
2024-04-15 21:22:22 +02:00
Jiwon Choi
2bd27e72e5
fix(next): Metadata.openGraph values not resolving basic values when type is set (#63620)
### What?

The string value of `Metadata.openGraph.emails` throws error:

```tsx
export const metadata = {
  openGraph: {
    type: 'article',
    emails: 'author@vercel.com',
  },
};
```

Error:

```sh
r.map is not a function
```

The type is:

```tsx
type OpenGraphMetadata = {
  // ...
  emails?: string | Array<string>
}
```

### Why?

Basic values such as `emails` and `phoneNumbers` were not included when
`ogType` was set while resolving the values.

### How?

Include basic values when resolving the metadata.

Fixes #63415
2024-04-15 21:17:48 +02:00
JJ Kasper
4024a89ee8
Fix DynamicServerError not being thrown in fetch (#64511)
This ensures we properly skip calling a fetch during build-time that has
`cache: 'no-store'` as it should only be called during runtime instead.

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

Closes NEXT-3114
2024-04-15 10:09:57 -07:00
Jiwon Choi
30521f20ff
fix(next): global not-found not working on multi-root layouts (#63053)
## Why?

For multi-root layouts (route groups on the root with their root
layouts, no layout file on the root), it is not possible to use global
`not-found` since the `layout` is missing on the root.

```sh
.
└── app/
    ├── (main)/
    │   └── layout.js
    ├── (sub)/
    │   └── layout.js
    └── not-found.js --> ERR: missing layout
```

Current Behavior:

```sh
not-found.js doesn't have a root layout. To fix this error, make sure every page has a root layout.
```

## What?

Let multi-root layouts also benefit from the global `not-found`.

## How?

Wrap root `not-found` with default layout if root layout does not exist.
Although this solution is not `multi-root` specific, it won't produce
critical issues since a root `layout` is required for other cases.

Fixes #55191 #54980 #59180
2024-04-15 18:25:53 +02:00
Sebastian Silbermann
edb9f7a142
Add typechecking test for all entrypoints (#64478) 2024-04-15 17:52:44 +02:00
Damien Simonin Feugas
e7a8645cb8
BREAKING CHANGE: remove deprecated analyticsId from config, and the corresponding performance-relayer files and tests (#64199)
### 🤔 What's in there?

We've deprecated config's `analyticsId` in 14.1.1 [almost 3 months
ago](https://github.com/vercel/next.js/releases/tag/v14.1.1-canary.2).
Users can opt in fot `@vercel/speed-insights`, or use
`useReportWebVitals` to report to any provider they'd like.

This PR:
- removes `analyticsId` key from configuration
- stops setting `__NEXT_PUBLIC_ANALYTICS_ID` env variable when the key
was present
- stops injecting `performance-relayer` file, when the variable is set
- cleans up related test code.
2024-04-15 15:23:30 +00:00
Ryota Murakami
4623eace76
chore: Update pnpm v8.15.1 to v8.15.7 (#64479)
Here are the release notes for pnpm versions v8.15.2 through v8.15.7,

- [v8.15.2 Release
Notes](https://github.com/pnpm/pnpm/releases/tag/v8.15.2)
- [v8.15.3 Release
Notes](https://github.com/pnpm/pnpm/releases/tag/v8.15.3)
- [v8.15.4 Release
Notes](https://github.com/pnpm/pnpm/releases/tag/v8.15.4)
- [v8.15.5 Release
Notes](https://github.com/pnpm/pnpm/releases/tag/v8.15.5)
- [v8.15.6 Release
Notes](https://github.com/pnpm/pnpm/releases/tag/v8.15.6)
- [v8.15.7 Release
Notes](https://github.com/pnpm/pnpm/releases/tag/v8.15.7)
2024-04-15 14:54:28 +00:00
Jiachi Liu
cb8fb3291a
Fix client boundary inheritance for barrel optimization (#64467)
### What

Inherit the client boudaries from the found matched target in load
barrel

### Why
The root cause with the barrel transform, we missed the client boundary
directive during the transform.
Since the new version of mui's case looks like this:

Import path
page.js (server module) -> `<module>/index.js` (shared module) ->
`<module/subpath>/index.js` (client module) ->
`<module/subpath/sub-module.js> (client module)

After our transform, we lost the `"use client"` which causes the
mismatch of the transform:

In `rsc` layer: the file pointing to the sub module entry
(`<module/subpath>/index.js`), but without the client boundary.


Fixes #64369 
Closes NEXT-3101
2024-04-14 23:36:20 +02:00
Zack Tanner
a5bb7c46b1
router restore should take priority over pending actions (#64449)
Since the router processes events sequentially, we special case
`ACTION_NAVIGATE` events to "discard" a pending server action so that it
can process the navigation with higher priority. We should apply this
same logic to `ACTION_RESTORE` events (e.g. `router.back()`) for the
same reason.

Fixes #64432


Closes NEXT-3098
2024-04-13 10:49:57 -07:00
Zack Tanner
f602b2979c
default fetchCache to no-store when force-dynamic is set (#64145)
`fetchCache` is a more fine-grained segment level cache-control
configuration that most people shouldn't have to use. Current semantics
of `dynamic = "force-dynamic"` will still treat the fetch as cacheable
unless explicitly overriding it in the fetch, or setting a segment level
`fetchCache`.

The `dynamic` cache configuration should be seen as a "top-level"
configuration, while more fine-grained controls should inherit logical
defaults from the top-level. Otherwise this forces people to opt-into
the `fetchCache` configuration, or manually override each `fetch` call,
which isn't what you'd expect when forcing a segment to be dynamic.

This will default to not attempting to cache the fetch when
`force-dynamic` is used. As a result, I had to update one of the
`app-static` tests to use `revalidate: 0` rather than `force-dynamic`,
as the revalidate behavior is slightly different in that it won't modify
the revalidation time on a fetch if it's non-zero.

Closes NEXT-2067
2024-04-13 17:05:47 +00:00
Zack Tanner
14ed612dbc
tweak test for Azure (#64424)
Looks like the `useTempDir` function throws when running in Azure rather
than piping the message to stderr. This makes the test resilient to both
cases.

<!-- 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-3095
2024-04-13 10:05:25 -07:00
Jiachi Liu
7ef6c4eb17
Revert "Fix: css in next/dynamic component in edge runtime" (#64442)
The fix is not correct, we already have request ALS wrapping the request
in app-render, shouldn't get another one for edge adapter. This is
actually a bundler bug

Reverts vercel/next.js#64382

Closes NEXT-3097
2024-04-13 13:32:18 +02:00
Colton Ehrman
9994e74a6c
fix(next-lint): update option --report-unused-disable-directives to --report-unused-disable-directives-severity (#64405)
## Why?

The Option name and type has been incorrect for
`--report-unused-disable-directives` (it's likely that
https://github.com/vercel/next.js/pull/61877 exposed this.

For correctness, we have updated the name to
`--report-unsed-disable-directives-severity` →
https://eslint.org/docs/v8.x/use/command-line-interface#--report-unused-disable-directives-severity.

- Fixes https://github.com/vercel/next.js/issues/64402

---------

Co-authored-by: samcx <sam@vercel.com>
2024-04-12 22:09:05 +00:00
Jiachi Liu
56d0988af7
Fix: css in next/dynamic component in edge runtime (#64382)
### What

Wrap async local storage for all edge runtime routes in adapter 

Basically fixed the case reported in [this
tweet](https://x.com/keegandonley/status/1778538456458854880)

### Why

We're relying on the ALS for dynamic css preloading but we didn't wrap
the ALS for request handlers for edge. So if you have CSS imports in
`next/dynamic` in edge runtime it would break.

Closes NEXT-3085
2024-04-12 10:52:40 +02:00
Jiachi Liu
0b3ead5e6b
test: skip turbopack build test (#64356)
x-ref:
https://github.com/vercel/next.js/actions/runs/8649384009/job/23715530094?pr=64348

Closes NEXT-3079
2024-04-12 09:23:01 +02:00
Wyatt Johnson
4b44857159
[PPR] Added generateMetadata tests (#64080)
<!-- 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?

This adds a missing test case for a page which accesses dynamic API's
within `generateMetadata`. It also adds a test case to verify that any
of the URL's being tested can succeed based on the components link
components (it relies on finding a link to click in the browser).

Closes NEXT-3004
2024-04-11 21:38:57 -06:00
Shu Ding
34524f01ad
Fix Server Action error logs for unhandled POST requests (#64315)
## Why

Currently, Server Action handlers are just normal routes and they
accepting POST requests. The only way to differentiate a normal request
(page access, API route, etc.) from a Server Action request is to check
that if it's a POST and has a Server Action ID set via headers or body
(e.g. `multipart/form-data`).

Usually, for existing page and API routes the correct handlers (page
renderer, API route handler) will take precedence over Server Action's.
But if the route doesn't exist (e.g. 404) it will still go through
Server Action's handler and result in an error. And we're eagerly
logging out that error because it might be an application failure, like
passing a wrong Action ID.

## How

In this PR we are making sure that the error is only logged if the
Action ID isn't `null`. This means that it's an intentional Server
Action request with a wrong ID. If the ID is `null`, we just handle it
like 404 and log nothing.

Fixes #64214.

Closes NEXT-3071
2024-04-12 01:21:28 +02:00
Tobias Koppers
cbee70991f
update turbopack (#64347)
* https://github.com/vercel/turbo/pull/7409 <!-- hrmny - chore: add
parallel rust frontend and remove unused rust dependencies -->
* https://github.com/vercel/turbo/pull/7920 <!-- Tobias Koppers - remove
warning when there is no PostCSS config -->
* https://github.com/vercel/turbo/pull/7856 <!-- Donny/강동윤 - build:
Update `swc_core` to `v0.90.29` -->
* https://github.com/vercel/turbo/pull/7941 <!-- Tobias Koppers - fix
recursion cycle when having a cycle of dynamic imports -->
* https://github.com/vercel/turbo/pull/7943 <!-- Tobias Koppers - fix
HMR by removing chunks from chunk list hash -->
2024-04-11 19:16:27 +02:00
Tobias Koppers
b912492392
Turbopack: import webpack loader rules conditions (#64205)
### What?

* remove custom next-* conditions
* add `foreign` condition
* allow `false` in turbo.rules
* improve schema for turbo.rules

### Why?

### How?



Closes PACK-2913

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-04-11 17:35:43 +02:00
Jiachi Liu
cd09f8b815
Inject preview props into edge manifest (#64108)
### What

Bump the edge runtime manifest version and add `environments` property
to each route for inlining values for deployment build.

### Why

In edge runtime, extract the preview props into edge functions manifest
that holding the non-deterministic inline values, then the output build
will be more deterministic that helps deployment speed

x-ref: https://github.com/vercel/vercel/pull/11390
x-ref: https://github.com/vercel/vercel/pull/11395
Closes NEXT-3012
Closes NEXT-1912
2024-04-11 11:18:49 +02:00
Balázs Orbán
b93ead0c9c
chore: add test mapping script (#63757)
### What?

This adds a script that first gets a list of changed files compared to
our base branch (`canary`) in PRs and identifies related test files by
looking them up from a `related-tests-manifest.json`, then runs them.

### Why?

We would like to be able to run related E2E tests when certain files
change, so we can test deployment stability.

NOTE: We still want to run all E2E tests on PRs, but this script can be
used to also test deployments for hot paths. Since these tests can take
up to [3-4
hours](https://github.com/vercel/next.js/actions/workflows/test_e2e_deploy.yml),
we aim to run a subset of these tests first.


Closes NEXT-2947
2024-04-11 09:44:47 +02:00
Will Binns-Smith
11575a45da
Escape url-unsafe characters in names of app router scripts and styles (#64131)
Building on #58293, this expands escaping of url-unsafe characters in
paths to “required” scripts and styles in the app renderer.
    
This also refactors the test introduced in #58293 and expands it to
include stylesheet references as well as checking resources in the head,
which include special characters like turbopack references like
`[turbopack]`.
    
Test Plan: `TURBOPACK=1 pnpm test-dev
test/e2e/app-dir/resource-url-encoding`

Closes PACK-2911
2024-04-10 17:42:53 -07:00
Jeongjin Oh
04c87ae2d7
fix: show the error message if images.loaderFile doesn't export a default function (#64036)
<!-- 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

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

-->

fixes #63803 

## What I do?

- If the loader file export the function as `named`, Next.js throws the
error.
- But this error is a bit confusing for the developers.
- So I open this PR for showing the accurate error message.

## AS-IS / TO-BE

### AS-IS

```
TypeError: Cannot use 'in' operator to search for '__next_img_default' in undefined
```
<img width="1202" alt="스크린샷 2024-03-28 16 10 53"
src="https://github.com/vercel/next.js/assets/33178048/e7c81cb5-7976-46ff-b86f-9c8fd9a7a681">

### TO-BE

```
Error: The loader file must export a default function that returns a string.
See more info here: https://nextjs.org/docs/messages/invalid-images-config
```
<img width="500" alt="스크린샷 2024-03-28 16 10 53"
src="https://github.com/vercel/next.js/assets/33178048/c391e61b-6a44-4f85-8600-28ab6cb5b0eb">

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-04-10 18:11:38 +00:00
Jiachi Liu
a7107a3df4
[turbopack] Fix css FOUC in dynamic component (#64021)
Follow up for #64294 to make turbopack side work as well

---------

Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
2024-04-10 18:44:17 +02:00
Jiachi Liu
142050ddc0
Fix css FOUC in dynamic component (#64294)
### What

CSS imports in components that loaded by `next/dynamic` in client
components will cause the css are missing initial in
SSR, and loaded later on client side which will lead to FOUC. This PR
fixes the issue and get CSS preloaded in the SSR for dynamic components.

### Why

The CSS from client components that created through `next/dynamic` are
not collected in the SSR, unlike RSC rendering we already collect the
CSS resources for each entry so we included them in the server rendering
so the styles are availble at that time. But for client components, we
didn't traverse all the client components and collect the CSS resources.

In pages router we kinda collect all the dynamic imports and preload
them during SSR, but this approach is not able to be applied to app
router due to different architecture. Since we already have all the
dynamic imports info and their related chunks in
react-loadable-manifest, so we can do the similar "preloading" thing in
app router. We use the current dynamic module key (`app/page.js ->
../components/foo.js`) which created by SWC transform and match it in
the react loadable manifest that accessed from `AsyncLocalStorage`, to
get the css files created by webpack then render them as preload
styleshee links. In this way we can SSR all the related CSS resources
for dynamic client components.

The reason we pass down the react loadable manifest through
`AsyncLocalStorage` is that it's sort of exclude the manifest from RSC
payload as it's not required for hydration, but only required for SSR.

Note: this issue only occurred in dynamic rendering case for client
components.

### Other Changes Overview

- Change the react loadable manifest key from pages dir based relative
path to a source dir based relative path, to support cases with both
directory or only one of them

Closes NEXT-2578
Fixes #61212
Fixes #61111
Fixes #62940

Replacement for #64021 but only with production test
2024-04-10 16:16:20 +02:00
Tim Neutkens
bccf55c870
Update turbopack-build-manifest (#64290)
## What?

Updates the manifest with the `test/integration` run.

<!-- 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-3058
2024-04-10 15:46:57 +02:00
Vercel Release Bot
6ddf2b75b8
Update Turbopack development test manifest (#64285)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-04-10 11:06:22 +02:00
Zack Tanner
85b9ed5eb8
provide revalidateReason to getStaticProps (#64258)
Provides a `revalidateReason` argument to `getStaticProps` ("stale" |
"on-demand" | "build").

- Build indicates it was run at build time
- On-demand indicates it was run as a side effect of [on-demand
revalidation](https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation)
- Stale indicates the resource was considered stale (either due to being
in dev mode, or an expired revalidate period)

This will allow changing behavior based on the context in which it's
called.

Closes NEXT-1900
2024-04-09 09:53:08 -07:00
Sam Ko
39a1c2aa0b
fix(fetch-cache): add check for updated tags when checking same cache key (#63547)
## Why?

When we fetch the same cache key (URL) but add an additional tag, the
revalidation does not re-fetch correctly (the bug just uses in-memory
cache again) when deployed.

:repro: →
https://github.com/lostip/nextjs-revalidation-demo/tree/main

---------

Co-authored-by: Ethan Arrowood <ethan@arrowood.dev>
2024-04-09 16:36:32 +00:00
Steven
8c9c1d2b6d
feat(next/image): add overrideSrc prop (#64221)
- Fixes https://github.com/vercel/next.js/discussions/60888
- Related
https://merj.com/blog/optimising-nextjs-image-component-for-image-search
2024-04-09 10:48:01 -04:00
Donny/강동윤
40e58f15bb
test: Disable next build test for turbopack (#64236)
### What?

Skip one test completely

### Why?

To make CI green

### How?


Closes PACK-2921
2024-04-09 07:26:27 -07:00
Zack Tanner
136979fedb
forward missing server actions to valid worker if one exists (#64227)
### What
When submitting a server action on a page that doesn't import the action
handler, a "Failed to find server action" error is thrown, even if
there's a valid handler for it elsewhere.

### Why
Workers for a particular server action ID are keyed by their page
entrypoints, and the client router invokes the current page when
triggering a server action, since it assumes it's available on the
current page. If an action is invoked after the router has moved away
from a page that can handle the action, then the action wouldn't run and
an error would be thrown in the server console.

### How
We try to find a valid worker to forward the action to, if one exists.
Otherwise it'll fallback to the usual error handling. This also adds a
header to opt out of rendering the flight tree, as if the action calls a
`revalidate` API, then it'll return a React tree corresponding with the
wrong page.

Fixes #61918
Fixes #63915

Closes NEXT-2489
2024-04-09 07:10:06 -07:00
Jiachi Liu
5e2ac0986f
chore: externalize undici for bundling (#64209)
Currently acornjs has an issue with compiling undici, add undici
externalize, once it's resolved we can remove the externalization for it

```
You may need an additional loader to handle the result of these loaders.
|       // 5. If object is not a default iterator object for interface,
|       //    then throw a TypeError.
>       if (typeof this !== 'object' || this === null || !(#target in this)) {
|         throw new TypeError(
|           `'next' called on an object that does not implement interface ${name} Iterator.`

Import trace for requested module:
../../../../node_modules/.pnpm/undici@6.12.0/node_modules/undici/lib/web/fetch/util.js
../../../../node_modules/.pnpm/undici@6.12.0/node_modules/undici/lib/web/fetch/headers.js
../../../../node_modules/.pnpm/undici@6.12.0/node_modules/undici/index.js
./app/undici/page.js
```

Closes NEXT-3030
2024-04-09 07:26:53 +00:00
Donny/강동윤
9638b9d464
chore: Fix CI (#64233)
### What?

Fix CI, which is broken due to https://github.com/vercel/next.js/pull/58534

### Why?

The PR was out of sync and CI didn't check turbo build

### How?


Closes PACK-2920
2024-04-09 01:40:23 +00:00
Donny/강동윤
5aa984de75
feat: Do not mangle AbortSignal to avoid breaking node-fetch (#58534)
### What?

Add `AbortSignal` to the reserved list of the name mangler.

### Why?

We don't want `node-fetch`  to throw an exception.

x-ref: https://vercel.slack.com/archives/C04KC8A53T7/p1700123182211619?thread_ts=1700090771.304599&cid=C04KC8A53T7

### How?


This PR modifies the mangle option from the Rust side code.

Closes PACK-1977
2024-04-09 09:28:03 +09:00
Sebastian Silbermann
ed4d772359
Stop using baseUrl in root tsconfig (#64117) 2024-04-09 00:25:43 +02:00
Jiachi Liu
2d99073b87
test: pin eslint version to 8 in test to avoid breaking changes (#64202)
x-ref:
https://github.com/vercel/next.js/actions/runs/8598454715/job/23559349141?pr=64110

Follow up for #64141

Closes NEXT-3028
2024-04-09 00:18:16 +02:00
Jiachi Liu
530382aeea
Fix hydration error higlight when tag matched multi times (#64133)
### What

We introduced a new algorithm to find the matched hydration error tags,
when there're two tags indicating children and parent as bad descendence
relationship. Now we search for the child first from the last index, and
then from found child to search its above parent. This way we can find
the two related tags in O(1), since they could be not directly nested.

### Why

When a hydration error occurred, such as bad nesting `div` under `p`,
one of the tag `div` is matched multiple times in the component stack,
it shouldn't be highlighted multiple times. This PR fixes the bad
matching about multiple nested tags, e.g. when there're many `div` tag
and `div` is one of the bad tag, only the one directly under p should be
highlited.

Case
```
Page > div > div > p > div
```

Current Result: all `div` and `p` get highlighted, `[]` represents
highlighted.
```
Page > [div] > [div] > [p] > [div]
```

Expected: only the related 2 tags are highlighted, `[]` represents
highlighted.
```
Page > div > div > [p] > [div]
```

Thanks @JohnPhamous for reporting the issue


Closes NEXT-3022
2024-04-08 19:12:03 +02:00
Zack Tanner
b103f73bf9
ensure seeded prefetch entry is renewed after expiry (#64175)
When we seed the prefetch cache with an entry for the loaded page, we
should also mark `lastUsedTime` to be the current time. Otherwise, if
the prefetch entry has technically expired, it'll incorrectly be
considered "reusable" because the `lastUsedTime` will be set to when
it's first routed to client-side.

x-ref:
https://github.com/vercel/next.js/discussions/54075#discussioncomment-9031149
<!-- 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-3025
2024-04-08 06:49:58 -07:00
Julius Marminge
a7c24aca6f
feat: allow module: Preserve tsconfig option (#64110)
Fixes #64018

Adds support for modern configurations introduced in TS 5.4

Expected output: not modifying the `module`, `esModuleInterop` configs
since `module: preserve` is present

```
   We detected TypeScript in your project and reconfigured your tsconfig.json file for you. Strict-mode is set to false
 by default.
   The following suggested values were added to your tsconfig.json. These values can be changed to fit your project's n
eeds:

        - lib was set to dom,dom.iterable,esnext
        - allowJs was set to true
        - skipLibCheck was set to true
        - strict was set to false
        - noEmit was set to true
        - incremental was set to true
        - include was set to ['next-env.d.ts', '**/*.ts', '**/*.tsx']
        - exclude was set to ['node_modules']

   The following mandatory changes were made to your tsconfig.json:

        - isolatedModules was set to true (requirement for SWC / Babel)
        - jsx was set to preserve (next.js implements its own optimized jsx transform)
```

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-04-08 11:30:04 +00:00
Vercel Release Bot
8c6532fa70
Update Turbopack development test manifest (#64190)
This auto-generated PR updates the development integration test manifest used when testing Turbopack.
2024-04-08 09:36:25 +02:00
Donny/강동윤
697ae8af5b
feat(turbopack): Align behavior for link rel="preconnect" with webpack mode (#64011)
### What?

Emit `<link data-next-font="size-adjust" rel="preconnect" href="/"
crossorigin="anonymous"/>` in more cases.

### Why?

To align with the default mode

### How?
2024-04-08 08:24:18 +02:00
Vercel Release Bot
9a6db5704a
Update Turbopack development test manifest (#64160)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-04-08 09:46:08 +09:00
Jiachi Liu
14c8900e70
style(dev-overlay): refine the error message header styling (#63823)
### What

Polish the UX based on the feedbacks from @sambecker 

* Fix the font that still use mono
* Align the color, to use red for the warnings
* Give the title to build error
* Only highlight the nextjs doc url as link

### After vs Before

#### Runtime Error


<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/64f2f692-1eae-41db-9287-046aff9ba112">
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/2d4bad15-745e-4083-ba57-8968c0f321c2">

#### Build Error

<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/ecfc3883-4522-40c6-b042-6d85e7ea970e">
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/bbf37ec5-b639-4b95-a87f-9911182e431c">



Closes NEXT-2958
2024-04-05 23:39:22 +02:00
Tim Neutkens
411846a016
Always throw error when build fails during test (#64116)
## What?

When creating the Next.js instance fails for whatever reason (most
commonly `next build` failing) it currently exits the process, this
causes Jest to not report these tests as failed.

The change in this PR ensures that anytime creating the instance fails
it throws an error that is caught by Jest and then causes Jest to report
the tests as failed.

The reporting of tests is relevant as our monitoring tools (i.e. DataDog
/ Turbopack test manifest) rely on correct reporting of all failing
tests.


<!-- 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-3016
2024-04-05 21:33:19 +02:00
Tobias Koppers
f6baf61b61
fix encoding for filenames containing ? or # (#58293)
Closes PACK-1935

---------

Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
2024-04-05 10:25:30 -07:00
JJ Kasper
0baa85dec7
Fix missing CNA tests env variable (#64092) 2024-04-05 10:04:38 -07:00
Vercel Release Bot
763b9a6604
Update Turbopack development test manifest (#64101)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-04-05 10:57:44 +02:00
Zack Tanner
51549d92de
fix refreshing inactive segments that contained searchParams (#64086)
When adding refresh markers for refetching segments that are "stale"
(the soft navigation case where they are still in the Router State Tree
but not part of the page that we're rendering), they only contained a
reference to the pathname. Once the actual refresh was triggered we
added the current search params to the request.

However, this causes an issue: segments in the `FlightRouterState` can
contain searchParams (ie, `__PAGE__?{"foo": "bar}` is what the segment
becomes when adding `?foo=bar` to a page). This means that when we
refresh those nodes from the server, it won't know how to find the
`CacheNode` for the stale segment since we won't have them in the
refetch tree. This updates to keep a reference to the searchParams that
were part of the request that made it active.

While fixing this, I also noticed that we were missing a spot to add the
refetch marker in `applyRouterStatePatchToTree` in the case of a root
refresh (caught by these tests failing in PPR)


[x-ref](https://github.com/vercel/next.js/discussions/63900#discussioncomment-9002137)

<!-- 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-3007
2024-04-04 23:44:54 +00:00
Nikhil Mehta
c502308bca
fix: cookie override during redirection from server action (#61633)
### What?
Fixes #61611

### Why?
Any one having custom server may be having logic to set cookies during
GET requests too. Currently nextjs in app directory does not allow to do
so but with custom server its very much possible.

### How?
By merging cookies of redirect response and server action POSt response

### Tests
I have added one more test to existing suite and it passing with fix in
place.

![image](https://github.com/vercel/next.js/assets/6815560/858afdbb-c377-49eb-9002-fcbdf06583a4)

### Notes
This bug is reproducible only if developer has custom server on top of
next app but still very probable

---------

Co-authored-by: Shu Ding <g@shud.in>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-04 14:08:13 -07:00
Jiachi Liu
02197bc364
Fix status code for /_not-found route (#64058)
### What

Fix the status code in static generation metadata for `/_not-found`
route, aligning it as 404 for both dev and build

### Why
`/_not-found` route should still return 404 code as it's reserved as
default not found route

Closes NEXT-3001
2024-04-04 17:35:27 +02:00
Donny/강동윤
cfca07996d
test: Use the correct matcher pattern for stack traces (#63927)
### What?

Match on `pages_api_unknown-domain-no-await_.*?\.js/` instead of
`/at.+\/pages\/api\/unknown-domain-no-await.js/`

### Why?

Turbopack generates a different chunk path for js files. This PR fixes
one integration test case.

### How?



Closes PACK-2883
2024-04-04 23:56:21 +09:00
Donny/강동윤
3ae6e1c9fe
feat(turbopack): Print error message for next/font fetching failure (#64008)
### What?

Print an error message to stdout if stylesheet fetching fails.

### Why?

To align behavior with the default mode. This PR fixes one integration
test case.

### How?



Closes PACK-2896
2024-04-04 23:56:10 +09:00
Vercel Release Bot
74943b67c7
Update Turbopack development test manifest (#64055)
This auto-generated PR updates the development integration test manifest used when testing Turbopack.
2024-04-04 16:58:58 +09:00
OJ Kwon
fd73584c7f
fix(turbopack): throws api issues (#64032)
### What

Correctly raises error for the /api, unlike other places we were
suppressing it.

Closes PACK-2900
2024-04-03 13:50:30 -07:00
Jiwon Choi
e8349a52ba
test(cna): split and refactor (#63921)
> Note: Did not add additional tests or make many changes to the utils,
possible refactoring on the following PR.

This PR split the legacy tests into four sections to improve the
maintenance and concurrency of CNA tests:

- `prompts`: target prompt interactions. `Y/n`
- `examples`:  target `--example` and `--example-path` flags.
- `templates`: target the flag values such as `--app`, `--eslint`, etc.
- `package-manager`: target package managers: npm, pnpm, yarn, bun

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-03 10:16:40 -07:00
Zack Tanner
ad98cda23b
fix interception route refresh behavior with dynamic params (#64006)
### What
When triggering an interception route that has a parent with dynamic
params, and then later going to "refresh" the tree, either by calling
`router.refresh` or revalidating in a server action, the refresh action
would silently fail and the router would be in a bad state.

### Why
Because of the dependency that interception routes currently have on
`FlightRouterState` for dynamic params extraction, we need to make sure
the refetch has the full tree so that it can properly extract earlier
params. Since the refreshing logic traversed parallel routes and scoped
the refresh to that particular segment, it would skip over earlier
segments, and so when the server attempted to diff the tree, it would
return an updated tree that corresponded with the wrong segment
(`[locale]` rather than `["locale", "en", "d]`).

Separately, since a page segment might be `__PAGE__?{"locale": "en"}`
rather than just `__PAGE__`, this updates the refetch marker logic to do
a partial match on the page segment key.

### How
This keeps a reference to the root of the updated tree so that the
refresh always starts at the top. This has the side effect of
re-rendering more data when making the "stale" refetch request, but this
is necessary until we can decouple `FlightRouterState` from interception
routes.

shout-out to @steve-marmalade for helping find this bug and providing
excellent Replays to help track it down 🙏

x-ref:

- https://github.com/vercel/next.js/discussions/63900

<!-- 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-2986
2024-04-03 09:03:58 -07:00
JJ Kasper
6a1e70ae55
Ensure unstable_cache bypasses for draft mode (#64007)
Currently we aren't detecting the draft mode case properly in
`unstable_cache` so the cache is unexpectedly being leveraged. This
ensures we bypass the cache for `unstable_cache` in draft mode the same
way we do for the fetch cache handling.

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

Closes NEXT-2987
2024-04-03 08:08:28 -07:00
Tim Neutkens
4271c095fb
Fix last examples for Turbopack (#64020)
## What

AMP is not supported with Turbopack. The knex example uses `@next/env`
so it needs to be installed.

<!-- 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-2989
2024-04-03 16:02:52 +02:00
Balázs Orbán
add2e6ea05
fix(log): skip logging non-route requests (#63973) 2024-04-03 12:16:20 +02:00
JJ Kasper
8ac023583f
Update flakey prerender fallback test (#64001)
This test could flake as it's racing the fallback data loading and the
initial assertion checking the initial fallback text so this skips
waiting for hydration to allow checking fallback text faster.

x-ref:
https://github.com/vercel/next.js/actions/runs/8529790447/job/23366315476?pr=64000

Closes NEXT-2985
2024-04-02 15:31:31 -07:00
JJ Kasper
d49e2c2c4c
Fix abort condition for requests (#64000)
This ensures we don't attempt passing a closed body to a
Request/Response object when a request is aborted as this triggers the
disturbed/locked error condition.

<details>

<summary>Example error</summary>

```sh
TypeError: Response body object should not be disturbed or locked
        at extractBody (node:internal/deps/undici/undici:4507:17)
        at new Request (node:internal/deps/undici/undici:5487:48)
        at new NextRequest (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/web/spec-extension/request.js:33:14)
        at NextRequestAdapter.fromNodeNextRequest (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/web/spec-extension/adapters/next-request.js:94:16)
        at NextRequestAdapter.fromBaseNextRequest (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/web/spec-extension/adapters/next-request.js:70:35)
        at doRender (/private/var/folders/cw/z0v1fby13ll4ytx_j3t8hhqh0000gn/T/next-install-d72b2dfb54a1417294505ab189942a38fd6bc139c24b9a8089fc3248568ff902/node_modules/.pnpm/file+..+next-repo-aef41a0c8a591889bcb0dc2e751aa71aa1c2e78c82d9e9b2fe3515c3d40f6c03+packages+n_wd7e7pnjmf2re4cc3l4tp6yzqe/node_modules/next/dist/server/base-server.js:1365:73)
```

</details>

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

Closes NEXT-2984
Closes NEXT-2904
2024-04-02 15:30:13 -07:00
Jiwon Choi
1511433212
fix(next): next build --debug log output layout is broken (#63193)
### Why?

The output layout breaks when running `next build --debug`

#### Current

```sh
 ✓ Generating static pages (10/10) 
   Finalizing page optimization  .   Collecting build traces  .Redirects

┌ source: /:path+/
├ destination: /:path+
└ permanent: true
 

 ✓ Collecting build traces    
 ✓ Finalizing page optimization    
```

#### Expected

```sh
✓ Generating static pages (4/4) 
   Finalizing page optimization ...
   Collecting build traces ...


Redirects
┌ source: /:path+/
├ destination: /:path+
└ permanent: true
```

### How?

Moved the `debug` output right above the `routes` output.
Also, ensured that the output layout has a consistent number of line
breaks (example below marked as `>`):

> Two line breaks for the next `option`, a single line break within the
same content.

```sh
   Collecting build traces ...
>
>
Redirects
┌ source: /:path+/
├ destination: /:path+
└ permanent: true
>
┌ source: /redirects
├ destination: /
└ permanent: true
>
>
Headers
┌ source: /
└ headers:
  └ x-custom-headers: headers
>
>
Rewrites
┌ source: /rewrites
└ destination: /
>
>
Route (app)                              Size     First Load JS
┌ ○ /                                    141 B          86.2 kB
└ ○ /_not-found                          876 B          86.9 kB
```

Fixes #63192

---------
2024-04-02 15:05:28 -07:00
Zack Tanner
17907b4316
fix server actions not bypassing prerender cache in all cases when deployed (#63978)
Trying to submit a server action when JS is disabled (ie, no action
header in the request, and in the "progressively enhanced" case) for a
static resource results in a 405 error when deployed to Vercel. In the
absence of an action ID header, the request content-type is used to
signal that it shouldn't try and hit the static cache. However with
multipart/form-data, this will include the boundary. This updates the
matcher to consider a boundary string.

Fixes #58814
Closes NEXT-2980
2024-04-02 14:32:52 -07:00
Zack Tanner
eddd1ee186
add telemetry events for ppr & staleTimes experimental flags (#63981)
Adds `NextConfig.experimental.ppr` and
`NextConfig.experimental.staletimes` to the `NEXT_BUILD_FEATURE_USAGE`
telemetry event.

<!-- 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-2981
2024-04-02 21:11:47 +00:00
Zack Tanner
d3492216f2
de-flake custom-error integration test (#63994)
- Ensures we clean up the inserted file 
- Retries the HMR check since there's a delta between writing to the
filesystem & HMR building the page.

<!-- 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-04-02 13:20:02 -07:00
Zack Tanner
52b81262a4
fix server-actions-relative-redirect types (#63985)
- https://github.com/DefinitelyTyped/DefinitelyTyped/pull/69250


[x-ref](https://github.com/vercel/next.js/actions/runs/8525684931/job/23353333460?pr=63981#step:27:272)

<!-- 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-2982
2024-04-02 16:57:01 +00:00
Zack Tanner
86cbc1f526
add experimental client router cache config (#62856)
This introduces an experimental router flag (`experimental.staleTimes`)
to change the router cache behavior. Specifically:

```ts
// next.config.js
module.exports = {
  experimental: {
    staleTimes: {
      dynamic: <seconds>,
      static: <seconds>,
    },
  },
};
```

- `dynamic` is the value that is used when the `prefetch` `Link` prop is
left unspecified. (Default 30 seconds)
- `static` is the value that is used when the `prefetch` `Link` prop is
`true`. (Default 5 minutes)

Additional details:
- Loading boundaries are considered reusable for the time period
indicated by the `static` property (default 5 minutes)
- This doesn't disable partial rendering support, **meaning shared
layouts won't automatically be refetched every navigation, only the new
segment data**.
- This also doesn't change back/forward caching behavior to ensure
things like scroll restoration etc still work nicely.

Please see the original proposal
[here](https://github.com/vercel/next.js/discussions/54075#discussioncomment-6754339)
for more information. The primary difference is that this is a global
configuration, rather than a per-segment configuration, and it isn't
applied to layouts. (We expect this to be a "stop-gap" and not the final
router caching solution)

Closes NEXT-2703
2024-04-02 05:42:18 -07:00
Vercel Release Bot
944159a6d4
Update Turbopack development test manifest (#63959)
This auto-generated PR updates the development integration test manifest used when testing Turbopack.
2024-04-02 16:29:52 +09:00
Donny/강동윤
4f142dc58b
test: Use the correct chunk path for testing (#63859)
### What?

Match on `/_next/static/chunks/%5Broot%20of%20the%20server%5D__` instead
of `/_next/static/chunks/main` while testing.

### Why?

Turbopack does not use `/_next/static/chunks/main` as the name of the
chunk

### How?



Closes PACK-2874

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-04-02 01:51:47 +00:00
Kevin Mårtensson
d2ac9c6c77
fix: pass nonce to next/script properly (#56995)
### What?

This fixes an issue where the `nonce` attribute isn't set on
`next/script` elements that has the `afterInteractive` (the default)
strategy resulting in `<link rel="preload" as="script"/>` tags without a
nonce.

### Why?

For apps that uses 3rd party scripts (or any script) with a nonce loaded
via `next/script` this is necessary unless you want them all to use
`beforeInteractive` which isn't super nice for performance.

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-04-01 23:27:38 +00:00
JJ Kasper
e0d4b4f414
Tweak flakey on-demand revalidate test (#63953)
This test flakes due to cache writing race so this uses retry instead to
avoid this.

x-ref:
https://github.com/vercel/next.js/actions/runs/8512132584/job/23313143810?pr=63921

Closes NEXT-2974
2024-04-01 15:00:40 -07:00
Zack Tanner
de049f8165
fix logic error in parallel route catch-all normalization (#63879)
### What & Why
There was some code added in the catch-all route normalization that
doesn't seem to make sense -- it was checking if the provided `appPath`
depth was larger than the catch-all route depth, prior to inserting it.
But it was comparing depths in an inconsistent way (`.length` vs
`.length - 1`), and the catch all path was also considering the `@slot`
and `/page` suffix as part of the path depth.

This means that if you had a `@modal/[...catchAll]` slot, it wouldn't be
considered for a page like `/foo/bar/baz`, because `/foo/bar/baz`
(depth: 4 with the current logic) and `/@modal/[...catchAll]/page`
(depth: 3 with the current logic) signaled that the `/foo/bar/baz` route
was "more specific" and shouldn't match the catch-all.

I think this was most likely added to resolve a bug where we were
inserting optional catch-all (`[[...catchAll]]`) routes into parallel
slots. However, optional catch-all routes are currently unsupported with
parallel routes, so this feature didn't work properly and the partial
support introduced a bug for regular catch-all routes.

### How
This removes the confusing workaround and skips optional catch-all
segments in this handling. Separately, we can add support for optional
catch-all parallel routes, but doing so will require quite a bit more
changes & also similar handling in Turbopack. Namely, if have a
top-level optional catch-all, in both the Turbopack & current Webpack
implementation, that top-level catch-all wouldn't be matched. And if you
tried to have an optional catch-all slot, in both implementations, the
app would error with:
> You cannot define a route with the same specificity as a optional
catch-all route ("/" and "/[[...catchAll]]")

because our route normalization logic does not treat slots specificity
differently than pages.

**Note**: This keeps the test that was added when this logic was first
introduced in #60776 to ensure that the case this was originally added
for still passes.

Fixes #62948
Closes NEXT-2728
2024-04-01 08:50:54 -07:00
Tim Neutkens
7ebc4b701c
Skip failing Turbopack build test (#63814)
## What?

This test currently causes others to fail. Trying adding a skip for this
to see if other issues come up before porting it to be isolated:


```
  ● Test suite failed to run\n\n    The name `source-map` was looked up in the Haste module map. It cannot be resolved, because there exists several different files, or packages, that provide a module for that particular name and platform. The platform is generic (no extension). You must delete or exclude files until there remains only one of these:\n\n      * `/root/actions-runner/_work/next.js/next.js/packages/next/src/compiled/source-map/package.json` (package)\n      * `/root/actions-runner/_work/next.js/next.js/test/integration/app-dir-export/output/standalone/packages/next/dist/compiled/source-map/package.json` (package)\n\n      at ModuleMap._assertNoDuplicates (../node_modules/.pnpm/jest-haste-map@29.7.0/node_modules/jest-haste-map/build/ModuleMap.js:189:11)\n
```

<!-- 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-2955
2024-04-01 15:54:37 +02:00
Maikel
4efe14238b
fix: bundle fetching with asset prefix (#63627)
Closes: https://github.com/vercel/next.js/issues/63623

When a relative assetPrefix was set (e.g. `/custom-asset-prefix`),
bundle fetching would always return a 404 as the assetPrefix was not
removed from filesystem path

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-29 16:38:24 -07:00
Evelyn Hathaway
5cfb7a0878
fix: skip checking rewrites with an empty has array in isInterceptionRouteRewrite (#63873)
<!-- 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?

Fixes #63871

-->

### What?

Adds safe traversal to rewrite `has` items in a certain new
(`isInterceptionRouteRewrite()` added in the v14.2.0 canaries) check to
the rewrite routes.

### Why?

The new check assumed that all `has` arrays had at least one item, when
previously Next.js accepted rewrites with empty `has`. Adding safe
traversal doesn't negatively impact the check, as the check only needs
rewrites with the first item.

Fixes #63871

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-29 16:38:06 -07:00
Donny/강동윤
29d53c87ea
feat(next-swc): Pass names of side-effect-free packages (#63268)
### What?

Pass the names of side-effect-free packages specified in `experimental.optimizePackageImports`.

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

### Why?

Some packages like `@tremor/react` causes a problem without `optimizePackageImports`.

### How?

Closes PACK-2527
2024-03-29 06:28:48 +00:00
JJ Kasper
b434ea401c
Ensure we dedupe fetch requests properly during page revalidate (#63849) 2024-03-29 01:56:11 +00:00
OJ Kwon
b90dcdd049
feat(next-core): set nextconfigoutput correctly (#63848)
### What

PR updates route's template injection correctly sets `nextConfigOutput`.
2024-03-28 17:35:35 -07:00
Jiachi Liu
389ea36673
fix: avoid metadata viewport warning during manually merging metadata (#63845)
We're incorrectly showing warnings for `viewport` if you manually merge
metadata.
Found this while fixing #63843 

Closes NEXT-2964
2024-03-29 00:32:22 +00:00
Jiachi Liu
488984cc03
fix: default relative canonical url should not contain search (#63843)
### What

Strip the search query for the `urlPathname` passed down to metadata
handling.

### Why
This is because the `urlPathname` from `staticGenerationStore` contains
query, so it will contain `?rsc` query for client navigation, which lead
to the relative path canonical url (e.g. `./`) will have the search
query along with it. This PR is to remove that and make sure always uses
pathname.

Reported by @pacocoursey 

Closes NEXT-2963
2024-03-28 23:16:22 +00:00
Zack Tanner
c116da32de
fix double redirect when using a loading boundary (#63786)
### What & Why
When an RSC triggers `navigate` after the shell has already been sent to
the client, a meta tag is inserted to signal to the browser it needs to
perform an MPA navigation. This is primarily used for bot user agents,
since we wouldn't have been able to provide a proper redirect status
code (since it occurred after the initial response was sent).

However, the router would trigger a SPA navigation, while the `<meta>`
tag lagged to perform an MPA navigation, resulting in 2 navigations to
the same URL.

### How
When the client side code attempts to handle the redirect, we treat it
like an MPA navigation. This will suspend in render and trigger a
`location.push`/`location.replace` to the targeted URL. As a result,
only one of these navigation events will win.

Fixes #59800
Fixes #62463

Closes NEXT-2952
Closes NEXT-2719
2024-03-28 16:08:39 -07:00
Will Binns-Smith
e519634c81
Turbopack: Fail when next/font is used in _document (#63788)
Test Plan:
d01a621961/test/development/next-font/font-loader-in-document-error.test.ts (L19)


Closes PACK-2858
2024-03-28 15:29:03 -07:00
Dima Voytenko
d0ea2894b7
OTEL: use the current context when creating a root span (#63825)
Fixes: https://github.com/vercel/next.js/issues/63783
2024-03-28 20:26:37 +00:00
JJ Kasper
3299fe0b3a
Use local AMP validator to reduce test flakiness (#63838)
We've seen test flakiness from the upstream AMP resource being
unavailable so this pulls that resource to the repo and uses that
instead.

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

Closes NEXT-2961
2024-03-28 20:25:35 +00:00
Zack Tanner
dfeb3d10ed
skip HEAD request in server action redirect (#63819)
When a server action performs a redirect, we currently initiate a `HEAD`
request to the targeted URL to verify if it has a proper RSC response.
If it does, it then invokes a GET and streams the response. This leads
to an extra request to the server which can be costly and poor for
performance. If the `GET` returns an invalid RSC response, we'll discard
the response. The client router will also see the invalid response which
will signal that it needs to perform an MPA navigation to the targeted
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-2956
2024-03-28 12:54:29 -07:00
OJ Kwon
7b2563da00
feat(custom-transform): more static info warning (#63837)
### What

Add few more warning assertions for the page static info.

requires https://github.com/vercel/next.js/pull/63780.

Closes PACK-2868
2024-03-28 19:31:13 +00:00
OJ Kwon
493130b789
feat(custom-transforms): partial page-static-info visitors (#63741)
### What

Supports partial `get-page-static-info` in turbopack. Since turbopack
doesn't have equivalent place to webpack's ondemandhandler, it uses
turbopack's build time transform rule instead.

As noted, this is partial implementation to pagestatic info as it does
not have existing js side evaluations. Assertions will be added
gradually to ensure regressions, for now having 1 assertion for
getstaticparams.

Closes PACK-2849
2024-03-28 09:47:33 -07:00
Zack Tanner
94749f073b
fix flaky prerender test (#63826)
This test doesn't clean up the file that it patches in the event any of
the assertions fail.


[x-ref](https://github.com/vercel/next.js/actions/runs/8468863964/job/23204091268?pr=63819#step:27:1227)
<!-- 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-03-28 08:57:12 -07:00
Zack Tanner
d2548b5435
fix router revalidation behavior for dynamic interception routes (#63768)
### What
When calling `revalidatePath` or `revalidateTag` in a server action for
an intercepted route with dynamic segments, the page would do a full
browser refresh.

### Why
When constructing rewrites for interception routes, the route params
leading up to the interception route are "voided" with a
`__NEXT_EMPTY_PARAM__` demarcation. When it comes time to look up the
values for these dynamic segments, since the params aren't going to be
part of the URL, they get matched via `FlightRouterState`
([ref](d67d658ce7/packages/next/src/server/app-render/app-render.tsx (L153-L201))).

The `shouldProvideFlightRouterState` variable only passes it through for
RSC requests; however, since the server action will perform the action &
return the flight data in a single pass, that means the updated tree
from the server action isn't going to receive the `FlightRouterState`
when constructing the new tree. This means the old tree will have a
`["locale", "en", "d"]` segment, and the new tree from the server action
will have `"[locale]"`. When the router detects this kind of segment
mismatch, it assumes the user navigated to a new root layout, and
triggers an MPA navigation.

### How
This unconditionally provides the `FlightRouterState` to
`makeGetDynamicParamFromSegment` so that it can properly extract dynamic
params for interception routes. We currently enforce interception routes
to be dynamic due to this `FlightRouterState` dependency.

Fixes #59796
Closes NEXT-2079
2024-03-28 13:35:22 +00:00
Zack Tanner
68de4c0357
fix revalidation/refresh behavior with parallel routes (#63607)
`applyRouterStatePatchToTree` had been refactored to support the case of
not skipping the `__DEFAULT__` segment, so that `router.refresh` or
revalidating in a server action wouldn't break the router. (More details
in this #59585)

This was a stop-gap and not an ideal solution, as this behavior means
`router.refresh()` would effectively behave like reloading the page,
where "stale" segments (ones that went from `__PAGE__` -> `__DEFAULT__`)
would disappear.

This PR reverts that handling. The next PR in this stack (#63608) adds
handling to refresh "stale" segments as well.

Note: We expect the test case that was added in #59585 to fail here, but
it is re-enabled in the next PR in the stack.

Note 2: #63608 was accidentally merged into this PR, despite being a
separate entry in the stack. As such, I've copied the issues from that
PR into this one so they can be linked. See the notes from that PR for
the refresh fix details.

Fixes #60815
Fixes #60950
Fixes #51711
Fixes #51714
Fixes #58715
Fixes #60948
Fixes #62213
Fixes #61341

Closes [NEXT-1845](https://linear.app/vercel/issue/NEXT-1845)
Closes [NEXT-2030](https://linear.app/vercel/issue/NEXT-2030)

<!-- 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-2903
2024-03-28 12:59:27 +00:00
Vercel Release Bot
1f443776fa
Update Turbopack development test manifest (#63776)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-03-27 20:43:22 +01:00
Tobias Koppers
ab5d0a2002
update turbopack (#63778)
* https://github.com/vercel/turbo/pull/7797 <!-- Tobias Koppers - fix
externals in side-effect optimized modules -->
* https://github.com/vercel/turbo/pull/7830 <!-- Tobias Koppers - Avoid
showing import map description in resolving issue when there is no
import map mapping -->
* https://github.com/vercel/turbo/pull/7833 <!-- Tobias Koppers - add
next.js trace format -->
* https://github.com/vercel/turbo/pull/7835 <!-- Tobias Koppers -
correct global start by first start time -->
* https://github.com/vercel/turbo/pull/7812 <!-- Will Binns-Smith -
Turbopack docs: Fix broken webpack loaders link -->
* https://github.com/vercel/turbo/pull/7847 <!-- Will Binns-Smith -
Turbo tasks: Reuse aggregation context and apply queued updates -->
* https://github.com/vercel/turbo/pull/7840 <!-- Tobias Koppers - add
concurrency corrected duration -->
* https://github.com/vercel/turbo/pull/7854 <!-- Tobias Koppers - fix
size_hint on count hash set -->
2024-03-27 20:09:08 +01:00
Tim Neutkens
0c0573fd65
Improve handling of failed nextBuild() calls in test suite (#63717)
## What?

Currently `next build` with Turbopack fails to run in certain tests (as
expected), the problem with that is that the `afterAll()` calls assume
the server was started, which doesn't happen when the build fails, and
then causes a timeout that can't be reported if an error happens. This
change ensures the error around `server['__app']` doesn't happen.

<!-- 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-2933
2024-03-27 19:29:16 +01:00
OJ Kwon
e820e92dc3
fext(next-core): inherit root layout segment config for the routes (#63683)
### What

Supports root segment config inherit from layout. Currently route
segment config only runs agasint own source, so individual route segment
config works but if the config is set in layout level it is being
ignored. PR introduces root segment and pass into each route if tree
level have a corresponding layout.

Closes PACK-2839
2024-03-27 16:38:23 +00:00
Jiachi Liu
93aac0e39b
Respect non 200 status to page static generation response (#63731)
### What

In static generation phase of app page, if there's any case that we're
receiving 3xx/4xx status code from the response, we 're setting it into
the static generation meta now to make sure they're still returning the
same status after build.

### Why

During static generation if there's any 3xx/4xx status code that is set
in the response, we should respect to it, such as the ones caused by
using `notFound()` to mark as 404 response or `redirect` to mark as
`307` response.

Closes NEXT-2895
Fixes #51021
Fixes #62228
2024-03-27 16:20:02 +01:00
Vercel Release Bot
5bc2ceab0b
Update Turbopack development test manifest (#63751)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-03-27 12:00:45 +01:00
Tobias Koppers
4296a0d9f5
improve tilde test case (#63470)
### What?

Test more cases


Closes PACK-2785
2024-03-27 06:16:49 +00:00
Josh Story
7425d51172
Fix ServerAction rejection reason (#63744)
Recently the serverActionReducer was updated to no longer use React's
thenable type to carry resolution/rejection information. However the
rejection reason was not updated so now when a server action fails we
were rejecting with `undefined` rather than the rejected reason. This
change updates the reject to use the rejection value.


Closes NEXT-2943
2024-03-26 17:46:50 -07:00
Zack Tanner
8d979b6233
de-flake prerender-prefetch test (#63739)
This test frequently fails, likely because it's possible to navigate
before the revalidation finishes


[x-ref](https://github.com/vercel/next.js/actions/runs/8441089149/job/23119594182#step:27:299)

[x-ref](https://github.com/vercel/next.js/actions/runs/8441133466/job/23119898500?pr=63606#step:27:297)

<!-- 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-2942
2024-03-26 14:47:22 -07:00
Zack Tanner
3fc65bac75
ensure null loading boundaries still render a Suspense boundary (#63726)
This ensures that even if a `loading.js` returns `null`, that we still
render a `Suspense` boundary, as it's perfectly valid to have an empty
fallback.

This was accidentally lost in #62346 -- this brings back the
`hasLoading` prop which will check the loading module itself (rather
than the `ReactNode`) for truthiness, and I've added a test to avoid
another regression.

<!-- 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-2936
2024-03-26 18:45:22 +00:00
Balázs Orbán
7569c8087a
feat(log): improve dev/build logs (#62946)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-26 15:33:09 +01:00
Vercel Release Bot
740d103282
Update Turbopack development test manifest (#63716)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-03-26 15:26:23 +01:00
Tim Neutkens
f4fc68765a
Ensure production integration test results are uploaded (#63706)
## What?

Ensures `test/integration` tests are uploaded for Turbopack build.

<!-- 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-2930
2024-03-26 10:41:16 +01:00
Tim Neutkens
40fbede8db
Revert "Revert "Update Turbopack production test manifest"" (#63700)
Relanding this PR after investigating why the test/integration tests
were running.

Reverts vercel/next.js#63688

Closes NEXT-2927
2024-03-26 10:22:02 +01:00
Tim Neutkens
f502ebbe44
Revert "Update Turbopack production test manifest" (#63699)
This had a failing suite. Reverting.

Reverts vercel/next.js#63688

Closes NEXT-2926
2024-03-26 08:46:04 +01:00
Vercel Release Bot
08a92e0aa5
Update Turbopack production test manifest (#63688)
This auto-generated PR updates the production integration test manifest
used when testing Turbopack.
2024-03-25 16:49:28 -07:00
michaltarasiuk
89a5251d73
refactor: unnecessary ternary operator (#63374)
Remove unnecessary ternary operator.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-25 22:04:00 +00:00
Balázs Orbán
752d6e49d5
feat(error-overlay): style tweaks (#63522) 2024-03-25 12:37:12 -06:00
Tim Neutkens
69f5fb260a
Skip test/integration development tests during Turbopack build test run (#63671)
## What?

Follow-up to #63665.

Ensures development tests are skipped during the production build run
for Turbopack (i.e. used to create the turbopack-build-tests-manifest).

Adds `pnpm test-dev-turbo` and `pnpm test-start-turbo` (and their
`testonly` equivalent) for running tests.

<!-- 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-2915
2024-03-25 18:37:34 +01:00
OJ Kwon
35f93e3be3
fix(dev-overlay): align codeframe to formatIssue (#63624)
Closes PACK-2825
2024-03-25 09:55:22 -07:00
Tim Neutkens
1e710ab73c
Rename process.env.TURBOPACK -> process.env.TURBOPACK_DEV in test skips (#63665)
## What?

Follow-up to #63653.

<!-- 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-2911
2024-03-25 14:17:56 +01:00
Donny/강동윤
6b6590592e
Update turbopack (#63541)
# Turbopack

* https://github.com/vercel/turbo/pull/7815 <!-- Tobias Koppers - fix
alias in getResolve -->
* https://github.com/vercel/turbo/pull/7796 <!-- Donny/강동윤 - Update
`swc_core` to `v0.90.24` -->
* https://github.com/vercel/turbo/pull/7775 <!-- Tobias Koppers - fix
single css chunks with import context -->
* https://github.com/vercel/turbo/pull/7776 <!-- Tobias Koppers - change
port of trace-server -->
* https://github.com/vercel/turbo/pull/7763 <!-- Tobias Koppers -
Tracing improvements -->
* https://github.com/vercel/turbo/pull/7813 <!-- Tobias Koppers - fix
webpack loader incorrectly calling custom_evaluate -->
* https://github.com/vercel/turbo/pull/7764 <!-- Tobias Koppers - fix
some small bugs in turbo-tasks that are required for GC -->
* https://github.com/vercel/turbo/pull/7816 <!-- Chris Olszewski -
chore: remove some unused imports -->
* https://github.com/vercel/turbo/pull/7823 <!-- OJ Kwon -
fix(sourcemap): update sourcemap, remove checker -->

### What?

Update SWC crates to
ad932f0921

### Why?

To keep in sync.

### How?



 - Closes PACK-2807
 - Closes PACK-2819

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-03-25 03:15:02 +00:00
Tim Neutkens
da1b259f2d
Remove Turbopack test skip for scss test (#63649)
## What?

Verified this passes now with Turbopack in dev even.


<!-- 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-2907
2024-03-24 20:04:12 +01:00
Vercel Release Bot
43f93f645d
Update Turbopack development test manifest (#63635)
This auto-generated PR updates the development integration test manifest
used when testing Turbopack.
2024-03-23 13:11:20 +01:00
OJ Kwon
16f7411a99
test(manifest): update manifest (#63613)
Closes PACK-2822
2024-03-22 11:59:19 -07:00
OJ Kwon
07a39eed2e
Revert "Revert "feat(next-core): support unsupported module runtime error (#63491)"" (#63609)
### What

This PR reenables reverted PR #63491, with fixing unexpectedly mark
supported node.js internals as unsupported.

Tried to add test cases for the supported case but hitting
https://vercel.slack.com/archives/C03EWR7LGEN/p1711128538909549, need
separate investigation.
2024-03-22 11:50:54 -07:00
Tim Neutkens
66be631d8a
Remove lodash from external packages list (#63601)
## What?

Since the work that Shu did for optimizing large barrel dependencies
marking lodash as external is no longer required.

<!-- 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-2899
2024-03-22 10:56:38 +00:00
Tim Neutkens
0234afa5a0
Add failing test for SCSS mixin that uses parenthesis (#63562)
## What?

Adds a test for a reported problem where sass-loader fails with `Null
check operator used on a null value`.

<!-- 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-2889
2024-03-22 11:24:25 +01:00
Jiachi Liu
053db6af8e
Remove the erroring on force-dynamic in static generation for app route (#63526)
### What
* Remove the erroring of force-dynamic is not able to use during static
generation
* Export the route segments properly in sitemap conventions

### Why

We discovered this error is showing up when users are using
force-dynamic with generating multi sitemaps.

When you have a dynamic `route /[id]/route.js` , and you have
generateSitemaps defined which is actually using `generateSitemaps`
under the hood , then you set the route to dynamic with `export dynamic
= 'force-dynamic'`.

We should keep the route still as dynamic. `generateStaticParams` is
only for generating the paths, which is static in build time. And the
`force-dynamic` is going to be applied to each generated path.

Closes NEXT-2881
2024-03-22 00:15:20 +01:00
Andrew Gadzik
4c467a2638
Improve experimental test proxy (#63567)
Followup on https://github.com/vercel/next.js/pull/52520 and
https://github.com/vercel/next.js/pull/54014

**Enhancements**
- Removes `--experimental-test-proxy` CLI argument from `next dev` and
`next start`
- Adds a new experimental config option `testProxy?: boolean`
- Instead of throwing an error, return the `originalFetch` response if
the current request context does not contain the `Next-Test-*` HTTP
headers

**Why?**
These changes allow us to write mixed Integration + E2E tests within the
same Playwright process.

```ts
// some-page.spec.ts

test.describe('/some-page', () => {
	test('some integration test', async ({ page, next }) => {
	  // by using the `next` fixture, playwright will send the `Next-Test-*` HTTP headers for 
	  // every request in this test's context.
	  next.onFetch(...);
	  
	  await page.goto(...);
	  await expect(...).toBe('some-mocked-value');
	});

	test('some e2e test', async ({ page }) => {
	  // by NOT using the `next` fixture, playwright does not send the `Next-Test-*` HTTP headers
	  await page.goto(...);
	  await expect(...).toBe('some-real-value');
	});
})
```

Now I can run `next dev` and locally develop my App Router pages AND run
my Playwright tests against instead of having to,
- run `next dev` to locally develop my change
- ctrl+c to kill server
- run `next dev --experimental-test-proxy` to locally run my integration
tests

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-21 21:31:29 +00:00
Tobias Koppers
7d95336779
Revert "feat(next-core): support unsupported module runtime error (#63491)" (#63575)
### What?

It's causing `__import_unsupported` is not defined in `instrumentation`
context
2024-03-21 18:43:58 +01:00
Steven
abe74a5211
fix: call instrumentationHook earlier for prod server (#63536)
This ensures that the instrumentation hook for Node.js will run
immediately during `next start` instead of waiting for the first request
like does it `next dev`.

However, if there is a separate instrumentation hook for Edge, that will
still be lazy evaluated and wait until the first request.

Fixes #59999 
Fixes NEXT-2738
2024-03-21 13:11:03 +00:00
Tim Neutkens
39340ab424
Fix edge-can-use-wasm-files test for Turbopack (#63552)
## What?

Test fix for Turbopack, the paths are slightly different. Fixes 1 test.

<!-- 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-2888
2024-03-21 11:05:02 +01:00
OJ Kwon
976dd526ae
feat(custom-transform): middleware dynamic assert transform (#63538)
### What

This PR implements runtime warning for dynamic codes (`eval`,
`Function`...) in edge runtime. Webpack uses middleware plugin to
replace / wrap codes, in case of Turbopack we don't have equivalent, so
creating a new transform visitor and run it if the context is edge.
Since sandbox augments global fn (__next_*), transform simply wraps the
expr if it matches to the condition.

Closes PACK-2804
2024-03-21 06:12:28 +01:00
Will Binns-Smith
aeafed9405
Turbopack: Fail when module type is unhandled (#63535)
This causes Turbopack to fail and communicate when a file with an
unhandled or unregistered extension is built.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/basic/hmr.test.ts`


Closes PACK-2803
2024-03-21 00:36:01 +00:00
Balázs Orbán
8ab62613fe
chore(test): fix false-positive tests (#63242)
<!-- 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-2798
2024-03-21 01:24:33 +01:00
Balázs Orbán
a2556196ea
refactor(test): switch tests to use pnpm in more places (#63196) 2024-03-20 15:00:58 -04:00
OJ Kwon
d95bc960c7
test(fixture): update test fixture (#63498)
### What
Followup for https://github.com/vercel/next.js/pull/63491, adjust
fixture setup to work with turbopack.

Closes PACK-2790
2024-03-20 11:03:01 -07:00
Balázs Orbán
3234b50f8f
refactor(test): don't use global as any in test utils (#63241) 2024-03-20 18:02:34 +00:00
Juan Settecase
e4cd547a50
feat: add support for localizations in sitemap generator (#53765)
### What?

Following up with [this
suggestion](https://github.com/vercel/next.js/discussions/53540) I went
ahead and implemented the proposal for the Next.js team to merge it if
they agree.

Things to keep in mind:
- Google has [three different
ways](https://developers.google.com/search/docs/specialty/international/localized-versions#methods-for-indicating-your-alternate-pages)
to do this. The three of them are equivalent
- Google seems to be the only search engine supporting this approach.
The rest of them should ignore it

### Why?

This is supported by
[Google](https://developers.google.com/search/docs/specialty/international/localized-versions#example_2)
to better understand the site when the same page is available in
multiple languages.

### How?

- I added a new key to the `MetadataRoute.Sitemap` type called
`alternates` which accepts just one sub key `languages` similar to the
current one in the
[Metadata](https://nextjs.org/docs/app/api-reference/functions/generate-metadata#alternates)
object
- I updated the `resolveSitemap` method to process the new key and
generate the expected sitemap
- I updated the related tests and documentation to reflect the new
syntax

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-20 17:00:20 +00:00
Tim Neutkens
859605a52c
Add reporting of turbopack-dev-examples-manifest.json (#63521)
## What?

Adds a manifest to track which examples have been checked with `next dev
--turbo` and reports it to areweturboyet.com

<!-- 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-2878
2024-03-20 14:58:01 +01:00
Tobias Koppers
1c998d86da
route/middleware/instrumentation use server assets instead of client assets (#62134)
### What?

route/middleware/instrumentation use server assets
server assets use full url rewrite

### Why?

### How?

https://github.com/vercel/turbo/pull/7750

Fixes PACK-2522

fixes PACK-2645
2024-03-20 12:06:29 +01:00
Balázs Orbán
33f8428f70
refactor(test): expose test mode as re-exported variables (#63240) 2024-03-20 01:03:49 +00:00
Zack Tanner
3ed46abcda
Fix interception/detail routes being triggered by router refreshes (#63263)
### What
Actions that revalidate the router state by kicking off a refetch (such
as `router.refresh()` or dev fast refresh) would incorrectly trigger an
interception route if one matched the current URL, or in the case of
already being on an intercepted route, would trigger the full detail
page instead.

### Why
Interception rewrites use the `nextUrl` header to determine if the
requested path should be rewritten to a different path. We currently
forward that header indiscriminately, which means that if you were on a
non-intercepted route and called `router.refresh()`, the UI would change
to the intercepted content instead (since it would treat it the same as
a soft-navigation).

### How
This updates various reducers to only forward the `nextUrl` header if
there's an interception route present in the tree. If there is, we want
to refresh its data, rather than the data for the underlying page. The
reverse is also true: if we were on the "full" page, and triggered a
`router.refresh()`, we won't forward `nextUrl` meaning it won't fetch
the interception data.

In order to determine if an interception route is present in the tree, I
had to add a new segment type for dynamic interception routes, as by the
time they reach the client they are stripped of their interception
marker.

**Note: There are a series of bugs related to `router.refresh` with
parallel/interception routes, such as the previous page/slot content
disappearing when triggering a refresh. This does not address all of
those cases, but I'm working through them!**

Fixes #60844
Fixes #62470
Closes NEXT-2737
2024-03-19 15:42:41 -07:00
JJ Kasper
d4f5368f2c
Update RSC etag generation handling (#63336)
Currently when we generate payloads in app router, the order of RSC
chunks aren't deterministic even if the content stays the same. This
means that any caches that rely on etags for detecting changes in
content aren't able to reliably cache/and avoid invalidating properly.
To avoid this we can manually sort the content before generating the
etag. Eventually this can be fixed upstream in react although that is a
bigger lift so we are doing this for now to alleviate the issue.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1709937748240119?thread_ts=1709856182.174879&cid=C042LHPJ1NX)

Closes NEXT-2825
2024-03-19 21:45:21 +00:00
OJ Kwon
3689c03d60
feat(next-core): support unsupported module runtime error (#63491)
### What

Implement webpack's middleware plugin equivalent for webpack, to raise
unsupported error in runtime.

PR utilizes import map alias for the edge context, to resolve into
modulereplacer internally provides a virtualsource to call runtime error
logic. Since we already have globally augmented, the virtualsource only
need to take export those into module.

Closes PACK-2789
2024-03-19 13:52:06 -07:00
JJ Kasper
b2b5ab4aff
Update tags limit handling for max items (#63486)
Continuation of https://github.com/vercel/next.js/pull/55083 this
ensures we also properly warn when the max number of tags is hit and we
must filter them out so that users are aware of this. Related
documentation is also updated to reflect this limit.

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

Closes NEXT-2870

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-03-19 12:02:35 -07:00
Zack Tanner
7d20ba17b8
Fix instant loading states after invalidating prefetch cache (#63256)
In #61573, I updated the navigation reducer to request a new prefetch
entry if it's stale. But this has the unintended consequence of making
instant loading states effectively useless after 30s (when the prefetch
would have expired). Blocking navigation and then rendering the loading
state isn't ideal - if we have some loading data in a cache node, we
should re-use it.

Now that #62346 stores loading data in the `CacheNode`, we can copy over
`loading` during a navigation.

This PR repurposes `fillCacheWithDataProperty` which wasn't being used
anywhere, to instead be a utility we can use to programmatically trigger
a lazy fetch on a particular segment path by nulling out it's data while
copying over other properties. We could have used the existing util
as-is, but ideally we only have a single spot where lazy fetching can
happen, which currently is in `LayoutRouter`.

When a stale prefetch entry is detected, rather than applying the data
to the tree, this PR will copy over the `loading` nodes and will
"delete" the data so it can be refetched.

<!-- 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-2806
2024-03-19 12:02:12 -07:00
Jiachi Liu
dd3a7df14d
test: switch order of tests to avoid flakniess (#63482)
x-ref:
https://github.com/vercel/next.js/actions/runs/8344655954/job/22838765632?pr=63476

We saw the playwright execution was broken while accessing url in
turbopack tests. Switching the order to check the content first solve
the problem

Closes NEXT-2867
2024-03-19 17:36:05 +00:00
Tim Neutkens
d2c28ee9bb
Skip test/integration in Turbopack build runs (#63480)
## What?

We need to go through all `test/integration` tests to make sure they're
only running the production piece.

<!-- 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-2866
2024-03-19 17:02:02 +01:00
Tim Neutkens
b9547e74fc
Implement Turbopack build manifest update (#63461)
WIP.

<!-- 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-2857
2024-03-19 13:00:33 +01:00
Tim Neutkens
d91e78adb7
Rename turbopack-tests-manifest to turbopack-dev-tests-manifest (#63409)
## What?

- Renames the Turbopack tests manifest to reflect that it only holds
development tests.
- Creates initial plumbing for Turbopack build tests manifest (currently
empty)
- Added running tests in the Turbopack builds test manifest on PRs
- Implements uploading the Turbopack builds manifest to areweturboyet

What this doesn't implement:
- Updating the Turbopack builds manifest

Open questions:
- Since the manifest is empty there are no test results, I had to add
handling for that in `run-tests.js`:
https://github.com/vercel/next.js/pull/63409/files#diff-269567847b110d8ecaaade3ab592df207bba02c7b446db23d72f18ff0e61d335R359
but not sure if that exit case was added for a specific special reason.

<!-- 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-2837
2024-03-19 10:26:14 +01:00
Vercel Release Bot
0c623678a4
Update Turbopack test manifest (#63452)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-19 08:37:32 +01:00
OJ Kwon
e12535c706
build(cargo): bump up turbopack (#63429)
### What

fix test/development/acceptance-app/app-hmr-changes.test.ts.

Closes PACK-2765
2024-03-18 21:11:37 +00:00
OJ Kwon
4064c64024
fix(next-core): carry over original segment config to metadata route (#63419)
### What

Fixes to honor metadata route's segment config - turbopack replaces it
into route handler, then parsed segment config so original segment
config was ignored always.

Closes PACK-2762
2024-03-18 13:26:04 -07:00
Will Binns-Smith
f96ec515d7
Turbopack HMR: use own snapshot in error-recovery (#63417)
This records dedicated snapshots for Turbopack for the remaining tests
in `test/development/acceptance/error-recovery.test.ts`. The only
remaining difference was the lack of Import trace information.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/acceptance/error-recovery.test.ts`


Closes PACK-2761
2024-03-18 12:15:52 -07:00
Karl Horky
51b878f5a3
Switch to postcss.config.mjs, add type (#63380)
<!-- 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?

Now that @phanect added support for ESM PostCSS config files in PR
#63109 (original issue #34448), PostCSS can use ESM config by default.

It needs to use an `.mjs` extension by default because `create-next-app`
scaffolds CommonJS apps by default.

This will also work with ESM projects which have added `"type":
"module"` in their `package.json`

### Why?

1. To convert one more file to ESM
2. To use the modern format
3. To follow other similar migrations that have taken place in the
Next.js codebase (eg. `next.config.mjs`)

### How?

- Change file extensions from `.cjs` to `.mjs` (change similar to PR
#58380)
- Change module format from CommonJS to ESM
- Add type for the config, for users who enable `checkJs: true` in
`tsconfig.json`

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-18 16:57:55 +00:00
Jiachi Liu
e1a7de0d04
feat(error-overlay): handle script under html hydration error (#63403)
script tag cannot be placed under html directly, users reported a case
in #51242 that having `<Script>` under html will cause hydration error,
this will display the React hydration error related warning of bad usage
for it.

You will see this warning in dev overlay instead of displaying nothing
```
In HTML, <script> cannot be a child of <html>.
This will cause a hydration error.
```

Added two other react warnings detection patterns  as well
* `Warning: In HTML, text nodes cannot be a child of <%s>.\nThis will
cause a hydration error.',`
* `Warning: In HTML, whitespace text nodes cann...`

But tested they're not generating hydration errors, only warnings in
console, so we don't need to have tests for them.

Closes NEXT-2835
2024-03-18 11:40:01 +01:00
Tim Neutkens
a35a89044d
Update switchable runtime snapshot for Turbopack (#63400)
## What?

Updates the test snapshot so that it passes for Turbopack.

<!-- 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-2833
2024-03-18 11:03:47 +01:00
Tim Neutkens
059302876e
Skip worker test in Turbopack (#63398)
## What?

`new Worker()` is not supported yet in Turbopack. Support for it will be
added after stable.

<!-- 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-2831
2024-03-18 10:31:38 +01:00
Tim Neutkens
6380b81bff
Ensure all metadata files have missing default export errors in Turbopack (#63399)
## What?

Fixes the `"app dir - metadata dynamic routes should error if the
default export of dynamic image is missing",` test. The check was
missing in the output code for 2 metadata variations.

<!-- 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-2832
2024-03-18 10:30:45 +01:00
Tobias Koppers
46a5882223
New CSS chunking algorithm (#63157)
### What?

This fixes more CSS ordering issues with production and webpack dev.

* CSS Modules must not be side effect free as side effect free modules
are per definition order independent which is not true for CSS
* fix order of iterating module references
* disable splitChunks for CSS
* special chunking for CSS with loose and strict mode
* more test cases

Closes PACK-2709
2024-03-18 10:29:13 +01:00
Oliver Lassen
af5b31c238
bug: Fields truncated when submitting form using Server Actions (#59877)
When using Server Actions with a form the fields are getting truncated
at 1MB because of `busboy`'s default `fieldSize` limit of 1MB.

This PR tries to solve https://github.com/vercel/next.js/issues/59277
however there is a mismatch about `fieldSize` and `bodySize`. I have
tried creating a PR for `busboy`
https://github.com/mscdex/busboy/pull/351 to allow configuring a max
size for the entire body.

### TODO:

- [ ] Figure out if this is acceptable
- [ ] Throw error when `bodySizeLimit` is hit.

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

-->

Fixes #59277, closes #61462.

---------

Co-authored-by: Shu Ding <g@shud.in>
2024-03-18 09:08:29 +00:00
Vercel Release Bot
8264ca89aa
Update Turbopack test manifest (#63370)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-18 07:41:07 +00:00
Tobias Koppers
43d911406b
add conditions for webpack loader rules (#63333)
### What?

* Allow to apply webpack loaders depending on "conditions".
* add a few next specific conditions depending on context type

### Why?

Some loaders need different behavior depending on context

### How?


Closes PACK-2748
2024-03-16 21:02:10 +01:00
Vercel Release Bot
f9cfccc231
Update Turbopack test manifest (#63356)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-16 20:57:59 +01:00
Jiachi Liu
53c21881de
fix(error-overlay): matching html tag with brackets in hydration error (#63365)
### What

* The tags extracted from hydration errors could be "<div>" and "p", we
need to stripe the brackets "<>" for matching the tag name from
component stack
* Change the dimmed text color to lighter so you can see it better in
light mode

#### After vs Before

<img width="450"
src="https://github.com/vercel/next.js/assets/4800338/6caed5ac-c073-41cc-a699-eb29f3785d59">

<img width="450"
src="https://github.com/vercel/next.js/assets/4800338/926aa80f-2a49-4362-b77e-16b819955b0a">


Closes NEXT-2828
2024-03-16 19:24:54 +00:00
Tobias Koppers
18b2e9d5ab
reenable initially skipped tests (#63347)
### What?

We initially skipped a few test cases. We need to reenable them.

### Why?

### How?


Closes PACK-2752
2024-03-16 02:32:31 +01:00
Will Binns-Smith
aa13705514
Turbopack HMR: Log when more errors cause full page reload (#63220)
Turbopack HMR: Log when more errors cause full page reload

Depends on vercel/turbo#7715

This adds messaging when HMR updates fail because:

- An HMR update could not be applied, such as updating an anonymous
function component
- An update follows a server-rendered error

Test Plan: See now passing tests in the manifest

Closes PACK-2728
2024-03-15 16:51:02 -07:00
OJ Kwon
6b2e2a0d2e
test(fixture): update middleware test fixture & manifest (#63340)
### What

Small update to test fixture to make test stable.

Closes PACK-2749
2024-03-15 15:12:24 -07:00
Vercel Release Bot
7ceff89bda
Update Turbopack test manifest (#63316)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-15 10:05:51 +01:00
Donny/강동윤
8cf86bba25
fix(turbopack): Remove error overlay when pages/_app is fixed (#63306)
### What?

Apply same patch as https://github.com/vercel/next.js/pull/62983 for
`pages/_app.js`

### Why?

To make turbopack match behavior of webpack mode, and make the test
passs

### How?

Closes PACK-2407
2024-03-15 12:03:08 +09:00
Zack Tanner
5e3bac5c1e
Store loading data in CacheNode (#62346)
This changes how loading components are provided to `LayoutRouter` to instead be part of the `CacheNode`. This makes it so that we can copy it over/expire it in a similar way to the `data` property on a `CacheNode`. Consequently, this fixes a bug in PPR navigations, where 2 different loading states (the prefetched one, followed by the updated one) might be displayed upon navigating. 

Note: This disables a PPR test that asserts the loading data gets expired after 5 minutes. As implemented, the loading data will remain cached for a particular segment. 

<!-- 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-2557
2024-03-14 16:32:51 -07:00
Steven
d8a58b5ac5
chore(test): fix typo occured => occurred (#63287)
Closes https://github.com/vercel/next.js/pull/63276

Closes NEXT-2818
2024-03-14 15:57:31 +00:00
Jiachi Liu
6556a342b9
fix: hydration error display for text under tag case (#63288)
There's a type of hydration warning is mismatch `"text content"` under a
`<tag>`, such as `Did not expect server HTML to contain the text node
"bad text" in <div>.`, we need to treate them separately from the text
diff or bad neseting tags.

### After

![image](https://github.com/vercel/next.js/assets/4800338/4dabfeae-b42a-4232-ab55-1704db36f5ce)


### Before


![image](https://github.com/vercel/next.js/assets/4800338/1da14435-cb3a-4883-84c8-7f0ce4c83b21)


Closes NEXT-2819
2024-03-14 16:03:28 +01:00
Vercel Release Bot
2509e08f94
Update Turbopack test manifest (#63274)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-14 10:38:01 +01:00
Tobias Koppers
efc5ae42a8
Turbopack: app externals test case improvements (#62871)
### What?

* rename test case
* improve error message and handle edge case for require resolving
* fix test case actually testing externals (webpack was silently
bundling, Turbopack showed error that helped to find the broken test
case)

### Why?

### How?


Closes PACK-2662
2024-03-14 07:22:40 +00:00
Dima Voytenko
82dc672af9
Disable cache in testmode (#63265)
Fixes #63127.
2024-03-14 00:20:54 -07:00
Donny/강동윤
6d45c3252c
fix(turbopack): Remove error overlay when issue is resolved (#62983)
### What?

Subscribe to changes of `_error` pages.

### Why?

To make the error overlay disappear when the error is fixed.

I tried skipping related entries by using `continue;` from
5f3b13584c/packages/next/src/server/dev/hot-reloader-turbopack.ts (L675-L684),
but it resulted in it page being rendered in the background while error
overlay does not disappear.

We need to remove the errors from `/_error` page to make the error
overlay disappear, so I tried removing them from the map and it worked.

### How?

Closes PACK-2405
Closes PACK-2644

---------

Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
2024-03-14 04:31:37 +00:00
Sam Ko
0a697cf044
fix(route-handlers): make sure preflight has CORS headers (#63264)
## Why?

When we just have a POST route handler, it seems CORs is not working
properly. This is because we break out of the loop here
768a92b15b/packages/next/src/server/future/route-modules/app-route/helpers/auto-implement-methods.ts (L38)
when a `GET` isn't present before we add the correct headers and status
to the preflight `OPTION`.

- Closes https://github.com/vercel/next.js/issues/57999

Closes NEXT-2813

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2024-03-14 00:59:57 +00:00
JJ Kasper
8f09bc44f7
Fix middleware catch-all rewrite case (#63254)
This ensures we properly set the matched header when applying a
middleware skip optimization so that the client router has enough
context to finish resolving the dynamic route params.

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

Closes NEXT-2803
2024-03-13 14:14:04 -07:00
Steven
02a06175e3
feat: add deploymentId config (#63198)
This PR stabilizes an experimental feature that was added in a previous
PR https://github.com/vercel/next.js/pull/50470

It allows the user to set `deploymentId` in `next.config.js`, which is a
unique identifier for a deployment that will be included in each
request's query string or header.

This PR is easier to review with whitespace hidden:
https://github.com/vercel/next.js/pull/63198/files?w=1

Closes NEXT-2789
2024-03-13 16:46:50 -04:00
OJ Kwon
49004e3e15
feat(turbopack): emit well known error into cli (#63218)
### What

This is stopgap substitution to webpack's wellknownerrorsplugin. When
webpack compilation hits known errors kind it emits compilation errors
into cli (and dev overlay both) while turbopack currently only emits
into error overlay. PR simply detects if given issue is well known, and
then logs into std.

Probably a long term there should be proper wiring instead; but for now
this allows to make few things work out of the box.

Closes PACK-2727
2024-03-13 13:38:38 -07:00
Jiachi Liu
ed893fa0d3
Use SWC to valid client next/navigation hooks usage in server components (#63160)
### What

Use SWC to check invalid client hooks of `next/navigation` imports in
server components.
Follow up of #62456 

Remove the runtime error APIs for `next/navigation` rsc version.
Add `next/navigation` react-server version alias in turbopack.

This PR also refactored the invalid server layer APIs detection into a
map, where key is import path and value is an array of client APIs.
During the traversing we will get the import source easily, this makes
extending the logic much easier

### Why

Previously we're using the runtime error to check it, but it has to run
first then the error will be thrown. If we error first in build time
with this check it's much faster and we this align on both side between
webpack and turbopack.
2024-03-13 16:37:36 +01:00
Donny/강동윤
3e6720c364
build: Update turbopack (#63229)
# Turbopack

* https://github.com/vercel/turbo/pull/7719 <!-- Tobias Koppers - accept
css files outside of the project as virtual assets -->
* https://github.com/vercel/turbo/pull/7661 <!-- Tobias Koppers - more
efficient node.js process startup -->
* https://github.com/vercel/turbo/pull/7720 <!-- Tobias Koppers -
generate correct async module handling for side effects optimization -->
* https://github.com/vercel/turbo/pull/7718 <!-- Donny/강동윤 -
fix(turbopack): Fix CSS Modules class name for lightningcss mode -->

### What?

Update tests to make CSS Modules of `lightningcss` work with CSS grids.

### Why?

`lightningcss` enforces the class name to end with `[local]`.

See: https://lightningcss.dev/css-modules.html#css-grid


### How?

Closes PACK-2731
2024-03-13 10:13:56 +00:00
Vercel Release Bot
23759eff65
Update Turbopack test manifest (#63231)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-13 10:39:22 +01:00
Balázs Orbán
55714b4163
fix(error-overlay): show Turbopack indicator for any staleness level (#63130) 2024-03-13 00:37:27 +01:00
Zack Tanner
0312d4a1a9
fix revalidation issue with route handlers (#63213)
### What
When a route handler uses an API that opts it into dynamic rendering
(such as `no-store` on a fetch), and also specifies a `revalidate` time,
the `revalidate` time is ignored and route is treated as fully static.

### Why
`revalidate: 0` and `revalidate: false` have different semantic
meanings: `false` essentially means cache forever, whereas `0` means
it's dynamic. Since `0` is also falsey, the code we have to fallback
with a default `revalidate` value for route handlers is incorrectly not
marking the route as dynamic, and as a result, caching the route without
an expiration time.

### How
This updates the fallback handling for app routes respect a revalidation
value of `0`, so that the page can properly be marked dynamic.

### Test Explanation
This adds 2 new routes handlers: both have a revalidation time specified
& use `no-store` on a fetch, but only one of them specifies `export
const dynamic = 'force-static'`. The one that doesn't specify
`force-static` is correctly omitted from the prerender manifest. The one
that is `force-static` is correctly in the prerender manifest with the
right expiration time. An additional test case was added to verify that
this data refreshes after the specified interval.

Closes NEXT-2764
2024-03-12 15:57:36 -07:00
Balázs Orbán
8ff1fd8f71
fix(log): improve error when dynamic code eval is disallowed (#62999) 2024-03-12 23:31:32 +01:00
Shu Ding
977f5ff72e
fix: Loose Server Actions runtime check (#63200)
Addresses some feedback in #62821. This will re-allow implementations
like:

```js
'use server'

export const f = wrapper(async () => {})
```

Where `wrapper` creates a sync function that returns a promise. Although
it will still be silently converted to an async function under the hood.

Closes NEXT-2790
2024-03-12 22:03:29 +00:00
Tobias Koppers
18547d5fd0
add support for assets in edge (#63209)
### What?

add support for `new URL(..., import.meta.url)` assets in edge. e. g.
needed for og-image.

### Why?

### Turbopack Changes

* https://github.com/vercel/turbo/pull/7712 <!-- Tobias Koppers - allow
to use full urls in browser runtime -->

Closes PACK-2725
2024-03-12 21:37:16 +00:00
OJ Kwon
3c94875bf9
feat(next-core): apply invalid import assertion on the remaining contexts (#63146)
### What

This PR completes resolve plugin for the invalid import assertion, for
the server-only in client component + styld-jsx in server components.

Closes PACK-2707
2024-03-12 11:12:07 -07:00
JJ Kasper
aa7ae420c6
Fix generateMetadata race condition (#63169)
This ensures we properly catch/handle `generateMetadata` errors during
eager evaluating of nested `generateMetadata` functions in the tree.
Previously if we eager evaluated a child metadata function that threw an
error e.g. `notFound()` and but the parent metadata function took longer
the thrown error would be an unhandled rejection causing the process to
crash depending on the environment.

Fixes: NEXT-2588


Closes NEXT-2786
2024-03-12 17:23:02 +00:00
Vercel Release Bot
5278d82aa9
Update Turbopack test manifest (#63177)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2024-03-12 15:17:56 +00:00
Tim Neutkens
54adb71a8d
Ensure undefined values end up being replaced (#63138)
## What?

Follow-up to #63128

`JSON.stringify(undefined)` ends up with the value `undefined`. However
for Webpack/Turbopack to correctly inject `undefined` into the code it
has to be the string `'undefined'`. This change ensures the
serialization takes into account that case.

<!-- 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-2773
2024-03-12 16:04:50 +01:00
Zack Tanner
465109eab3
ensure mpa navigations to the same URL work after restoring from bfcache (#63155)
### What
When triggering an MPA navigation (also commonly referred to as a "hard
navigation"), and then restoring the previous page via the browser's
bfcache, subsequent requests to the same link wouldn't navigate until
reloading the page or performing a different navigation.

### Why
MPA navigations in app router are handled in a fairly unconventional
way: the router state is updated with an indication that an external URL
was clicked, and once the router sees the pending navigation, it kicks
off a `location.replace` or `location.push` with the specified URL **in
render**. The router then suspends indefinitely to prevent committing
the render. However, the router will only make the `replace`/`push`
request if there's not already a pending navigation to that same URL.

The pending check is needed to avoid continuously calling
`push`/`replace` when unrelated router state changes occur (for example,
if I hover over a link and trigger a prefetch action and the router
re-renders, it shouldn't make another `location.push` call to the same
URL that's pending)

However, the source of the bug is that the variable that holds this
pending state is also restored by the browser's cache, since it takes a
snapshot prior to exiting the page. This means that when clicking the
browser back button, `pendingMpaPath` would still be set to the URL we
just came from. When clicking the link again, it would see that the
requested URL is the same as the pending URL, and not perform any
history actions.

### How
This clears the pending value when the router is restored from bfcache.

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

-->

[slack
x-ref](https://vercel.slack.com/archives/C0676QZBWKS/p1710169967246929)

Closes NEXT-2781
Closes NEXT-2776
2024-03-11 14:55:04 -07:00
Vercel Release Bot
c860a2a4cd
Update Turbopack test manifest (#63125)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-11 14:24:45 -07:00
Karl Horky
dd536a51ec
Switch to .cjs PostCSS config (#58380)
<!-- 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?

Prevent confusing error messages when changing to `"type": "module"` in
`package.json`

```
./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./src/styles/index.css
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/my/repo/components/postcss.config.js from /path/to/my/repo/components/node_modules/next/dist/lib/find-config.js not supported.
Instead change the require of postcss.config.js in /path/to/my/repo/components/node_modules/next/dist/lib/find-config.js to a dynamic import() which is available in all CommonJS modules.
```

### Why?

Even though PostCSS itself [supports ESM and TypeScript configuration
files](https://github.com/postcss/postcss-load-config/issues/230),
Next.js itself does not (because of `next/lib/find-config`):

- https://github.com/vercel/next.js/issues/34448

### How?

By switching to `.cjs`, the config will stay recognized as CommonJS even
after switching to `"type": "module"` in `package.json`

cc @balazsorban44

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-11 14:19:50 -07:00
Apostolos Tsakpinis
a00458b5e9
fix typo in server/config.ts (#62795)
lager -> larger

---------

Co-authored-by: samcx <sam@vercel.com>
2024-03-11 19:12:00 +00:00
pacexy
0bad7143d7
Fix webpack HMR for pages on the edge runtime (#60881)
This fixes the issue that build error is not cleared correctly during
`next dev` even if the build succeeds, and we have to re-run `next dev`
to make it work.

It appears only when:

1. page runtime is `edge`
2. use webpack hot reloader
3. import components in the `edge` page

Reproduction:
https://github.com/pacexy/nextjs-edge-webpack-hmr-reproduction

I recorded a screenshot to make it easier to understand:


https://github.com/vercel/next.js/assets/32255488/0ddc21bf-2ea7-49ce-b682-c89dea757c61

Closes NEXT-2168

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-03-11 16:53:04 +01:00
Steven
560a584273
chore(test): add test for next/image in node_modules with app router (#63139)
This adds a test from PR https://github.com/vercel/next.js/pull/33559
that was testing Pages Router but makes sure the same test runs for App
Router.

Closes NEXT-2774
2024-03-11 16:38:57 +01:00
Wyatt Johnson
7057d1ebf5
[PPR] Support rewrites in middleware (#63071)
### What?

This fixes a special case where rewrites wouldn't work when resuming a
dynamic page.

### Why?

Previously, as routes would direct-match against entries in the cache,
this takes the `x-matched-path` as the source of truth for these
requests if the `x-now-route-matches` header is not present.
2024-03-11 09:05:26 -06:00
Tobias Koppers
b4b757c25d
ignore fully dynamic requests on server side (#62949)
### What?

make sure that we don't error for dynamic requests on server side.

It will throw at runtime when using a dynamic request.

### Why?

Not all packages are fully bundler compatible, but still work when only
using the parts that work. We don't want to block users from using them
by having an hard compile error.

### How?


Closes PACK-2675
2024-03-11 08:41:33 +00:00
Donny/강동윤
d55699d5f7
feat(turbopack): Enable lightningcss for turbopack by default (#62565)
# Turbopack

* https://github.com/vercel/turbo/pull/7682 <!-- Will Binns-Smith -
Turbopack HMR: url-encode sourceURLs -->
* https://github.com/vercel/turbo/pull/7524 <!-- Donny/강동윤 -
feat(turbopack): Enable lightningcss for turbopack by default -->


### What?

Enable lightningcss by default, for `--turbo` mode.

### Why?

It's time to do it 😄 

### How?

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


Closes PACK-2600
2024-03-11 06:49:43 +00:00
mattddean
6da6388b62
Correctly deserialize undefined unstable_cache data (#59126)
<!-- 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 #

-->

The value `undefined` can be saved to the incremental cache as
`undefined` (`JSON.stringify(undefined)`) with no errors, but when
retrieving it, we attempt to parse it as JSON using
`JSON.parse(undefined)`. This throws an error. We should instead
deserialize `undefined` as `undefined` when retrieving.

relevant discussion: #59087

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-08 22:07:09 -08:00
Dima Voytenko
b8d63702f3
OTEL: add next.rsc attribute for RSC requests (#63074)
`next.rsc: boolean` attribute to indicate whether it's a RSC request
2024-03-08 21:58:00 -08:00
OJ Kwon
42b42a6498
build(cargo): bump up turbopack (#63073)
### What

* https://github.com/vercel/turbo/pull/7684 <!-- OJ Kwon -
feat(resolve): skip alias to d.ts -->



Closes PACK-2702
2024-03-09 01:29:21 +00:00
Vercel Release Bot
94d613cc61
Update Turbopack test manifest (#63066)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-08 21:29:06 +00:00
Jiachi Liu
664073e86f
Fix metadata url cases should not append with trailing slash (#63050)
### What

Exclude the cases like external urls and relative urls with query from
appending trailing slash when it's needed.

The process is:
- If it's a uncertain string path (relative url, could start with `'./'`
or `/`), convert to relative that starts with `/`;
- then we covert the url (string or URL) to string url
- We do the check if we need to append the trailing slash

### Why

In #62109 we added functionality that can only append trailing slash
when we appended trailing slash to some metadata url like `canonical`
url and open graph url when the config is enabled.
For urls with queries, the trailing slash can also be omitted.
For the external urls (different origin comparing to `metadataBase`) we
don't need to append trailing slash as they're not the same web app.

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

Closes NEXT-2762
Closes NEXT-2753
2024-03-08 21:16:16 +01:00
OJ Kwon
daec5be052
test(scss): rename test suites (#63060)
### What

To verify manifest issues.


Closes PACK-2697
2024-03-08 10:57:02 -08:00
Wyatt Johnson
ea56c8f7ad
DX: add route context to dynamic errors for app routes (#62844)
Gives the users pathname context on routes that access Dynamic API's so
that if these errors are caught they can modify their code accordingly.
This is a followup to #61332.


Closes NEXT-2695
2024-03-08 11:35:24 -07:00
Zack Tanner
ff1d4cb3e7
fix dynamic api route test (#63027)
While looking at flakey tests I noticed that this test has a typo which
means the assertion was being skipped all together.

Closes NEXT-2760
<!-- 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-03-08 02:11:20 +00:00
Will Binns-Smith
bd72f39ca8
Turbopack + pages router: recover from runtime errors by reloading (#63024)
An iteration of #62359, this uses the module-local flag instead of a
shared dedicated module for flagging runtime errors, correctly reloading
the page when these occur.

Test Plan: See now-passing tests in the manifest.


Closes PACK-2690
2024-03-07 17:24:50 -08:00
Sam Ko
8c7f0dc960
Fix flaky test by removing unecessary NODE_OPTIONS='--inspect' (#63025)
## Why?

We have a flaky test with `NODE_OPTIONS='--inspect'` test in
https://github.com/vercel/next.js/blob/canary/test/integration/cli/test/index.test.js
because with Turbopack, we run several integration tests concurrently.

Our integration tests are ran concurrently, so anything that adds
`NODE_OPTIONS='--inspect'` can clash with another when `run-tests.js` is
ran. Hence, the result below.

-
https://github.com/vercel/next.js/actions/runs/8189378285/job/22394053022?pr=62999

You can confirm this locally by running `TURBOPACK=1 node run-tests.js
--test-pattern
"test\\/integration\\/(cli|config-mjs)\\/test\\/index\\.test\\.js"`.

## Changes

Both
https://github.com/vercel/next.js/blob/canary/test/integration/config-mjs/test/index.test.js
and
https://github.com/vercel/next.js/blob/canary/test/integration/config/test/index.test.js
add a now unnecessary `NODE_OPTIONS='--inspect'`, so we should be good
to remove them.

Closes NEXT-2759
2024-03-07 17:18:26 -08:00
Zack Tanner
7a7068cadb
fix transpile-packages test (#63023)
A recent `aws-sdk` publish broke the release. This adds a dependency to
unblock these tests from failing.

x-ref:
https://github.com/aws/aws-sdk-js-v3/issues/5866#issuecomment-1984616572
<!-- 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-2758
2024-03-08 00:36:42 +00:00
Zack Tanner
333d3ad768
fix flakey HMR test (#63022)
The "Compiled" HMR log is emitted as follows:

> Compiled in 54ms

When running this string through the matcher, we get:
```
> const matches = "Compiled in 54ms".match(/Compiled.*? in ([\d.]{1,})\s?(?:s|ms)/i) 
console.log(matches[1]); // 54
```

We correctly assign `compileTime` to `matches[1]`. However, we then
assign `compileTimeMs` to `parseFloat(compileTime[1])`. This is
definitely an error, as `compileTime[1]` would be `4` in the above
example.

This means that if the compilation time takes less than a single digit
value, it'd be coerced to NaN.

<!-- 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-2757
2024-03-07 23:49:12 +00:00
Zack Tanner
77f88004a8
fix flakey app-action test (#63021)
This test is flaking because the assertion before it triggers a redbox
error, and the HMR event to remove the redbox is occasionally happening
after we've moved onto the next test assertion. It also just checks for
"h1" which is heavily overloaded in this test suite for various UI
elements so I added a more specific selector.


[x-ref](https://github.com/vercel/next.js/actions/runs/8195295576/job/22413257207?pr=63019#step:27:1550)

<!-- 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-2756
2024-03-07 15:15:20 -08:00
Zack Tanner
e5ac6aeea8
fix broken create-next-app tests (#63019)
#62980 migrated `examples/basic-css` to use app router. A handful of our
create-next-app tests use this example when asserting the correct
project files are created, so we were asserting on a pages file existing
rather than an app dir page. This PR updates those tests.

<!-- 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-2754
2024-03-07 22:21:12 +00:00
OJ Kwon
2a6199c2d9
fix(next-core): honor basepath for the metadata property (#62846)
### What?

When we write path for the og metadata, basePath was omitted regardless
of config. (Actual asset emission was correct, just writing the path in
the metadata route)

PR updates template code to use config's basePath if exists.

Closes PACK-2655
2024-03-07 13:19:15 -08:00
Vercel Release Bot
6dc28b3148
Update Turbopack test manifest (#62981)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-07 14:31:55 +01:00
Jiachi Liu
27ed7820a8
[error overlay] move missing tags error inside error overlay (#62993)
### What

* Move missing html tags error into error overlay, from outside we don't
have to manually determine when to render a dummy component with runtime
missing tag error or error overlay.
* Add brackets `<>` to the html tags in the error



![image](https://github.com/vercel/next.js/assets/4800338/cd3467b7-74c2-477e-8516-c31761adb064)


### Why

In #62815, we're having throwing an missing required error, this will
trigger another runtime error. Then when error overlay caught it through
error event listener, it will render it as an unhandled runtime error:

You will see the below message in the overlay.
```
Unhandled Runtime Error
Error: The following tas are missing...

[Error stack]
```

This error message will bring a message that the error is happened on
client during runtime, but actually we already know that is a user side
mistake which doesn't have a error trace. This couldn't hmr as you fix
the error as well.

This PR moves the rendering into error overlay that we're aware of the
errors and can render the correct html on client, with the `html` tag
attached with error id and `body` wrapping the error overlay. We tell
overlay that there're missing tags through props, let it handle
everything inside.

It can also hmr once you fix the error. One drawback is that when you
re-introduce the error, it might trigger react DOM updates exception
(`Failed to execute 'removeChild' on 'Node': The node to be removed is
not a child of this node.`) instead of the "missing tags" message again.
Besides that the HMR works properly.

Closes NEXT-2741
2024-03-07 14:24:00 +01:00
Arian
5f3b13584c
chore: update pnpm version from 8.15.1 to 8.15.4 (#62979)
Update pnpm version from 8.15.1 to 8.15.4
pnpm 8.15.4 release note
https://github.com/pnpm/pnpm/releases/tag/v8.15.4

Previous comment form reviewer  
https://github.com/vercel/next.js/pull/62963#issuecomment-1982010314
2024-03-07 09:22:45 +00:00
Sam Ko
ee273c42bc
chore(next-font): update @capsize/metrics package to the latest (#62896)
## Why?

We need to be up-to-date with this package so our `next/font` is working
optimally. → https://github.com/seek-oss/capsize/releases.

Unlikely related to the latest
[comment](https://github.com/vercel/next.js/issues/47115#issuecomment-1979248754),
but a good reminder I need to check this regularly (or we should
automate it, or have a better solution).

Closes NEXT-2715
2024-03-06 12:04:20 -08:00
JJ Kasper
67eca23ae5
Upgrade to latest @edge-runtime packages (#62955)
This upgrades to the latest edge-runtime packages as it includes
exposing `performance`. This was reverted previously as our publishes
were failing with a specific change that has since been removed
upstream.

Closes NEXT-2730
2024-03-06 11:43:48 -08:00
Sukka
c206d89ec2
feat(eslint): enhance no-unwanted-polyfill w/ new endpoints (#62719)
The PR adds the new `polyfill.io` instance endpoint (from Fastly and
Cloudflare) to the `eslint-plugin-next`'s `no-unwanted-polyfillio`
rules, so these new endpoints can be detected by the rule.

---

`polyfill.io` was acquired by **a China-based CDN company** "Funnull",
see [the announcement from the `polyfill.io` domain owner's
Twitter](https://x.com/JakeDChampion/status/1761315227008643367) and
https://github.com/polyfillpolyfill/polyfill-service/issues/2834.
Despite Funnull's claims of operating in the United States, the
predominance of Simplified Chinese on its website suggests otherwise,
and it turns out that **"Funnull" is notorious for providing service for
the betting and pornography industries**.

[The original creator of the `polyfill.io` has voiced his concern on
Twitter](https://twitter.com/triblondon/status/1761852117579427975). And
since the acquisition, numerous issues have emerged
(https://github.com/polyfillpolyfill/polyfill-service/issues/2835,
https://github.com/polyfillpolyfill/polyfill-service/issues/2838,
https://github.com/alist-org/alist/issues/6100), rendering the
`polyfill.io` service **extremely unstable**. Since then, Fastly
([Announcement](https://community.fastly.com/t/new-options-for-polyfill-io-users/2540))
and Cloudflare
([Announcement](https://blog.cloudflare.com/polyfill-io-now-available-on-cdnjs-reduce-your-supply-chain-risk))
has hosted their own instances of `polyfill.io` service.

---------

Co-authored-by: Steven <steven@ceriously.com>
2024-03-06 16:42:53 +00:00
Donny/강동윤
3ed96f92cb
feat: Introduce lightningcss-loader for webpack users (#61327)
### What?

I'm recreating a PR because CI of
https://github.com/vercel/next.js/pull/58712 uses `lightningcss@1.14.0`
for an unknown reason.

Add an opt-in feature to use `lightningcss` instead of webpack
css-loader.

### Why?

In the name of performance.

### How?


This PR is largely based on https://github.com/fz6m/lightningcss-loader
by @fz6m.
(Thank you for nice work)

Closes PACK-1998
Closes PACK-2124

---------

Co-authored-by: OJ Kwon <1210596+kwonoj@users.noreply.github.com>
2024-03-06 17:07:53 +01:00
Balázs Orbán
0a73e89880
feat(error-overlay): version staleness in Pages Router (#62942) 2024-03-06 16:00:16 +00:00
Balázs Orbán
8f5107de16
feat(error-overlay): notify about missing html/body in root layout (#62815) 2024-03-06 10:59:53 +00:00
OJ Kwon
415cd74b9a
fix(next-api): correct font manifest generation (#62916)
### What

I noticed the font manifest generated by Turbopack was always empty.
Debugging showed that the path to the client_root was always incorrect
when calculating `get_font_paths_from_root`. And also fixed an issue
where for certain paths, the (`/index`) manifest key should contain the
original path.

Closes PACK-2666
2024-03-06 11:21:39 +01:00
Vercel Release Bot
57abed52dd
Update Turbopack test manifest (#62925)
This auto-generated PR updates the integration test manifest used when
testing Turbopack.
2024-03-06 11:19:55 +01:00
Will Binns-Smith
f9aec9005a
Turbopack: Trace edge runtime app render errors through source maps (#62901)
Similar to #62611, this implements error stack translation for edge
runtime app render errors.

Test Plan: `TURBOPACK=1 pnpm test-dev
test/development/app-render-error-log/app-render-error-log.test.ts`

Closes PACK-2665
2024-03-05 20:40:26 -08:00
Sam Ko
0d3481b6b2
test(integration-cli): fix test name (#62915)
- https://github.com/vercel/next.js/pull/62840#discussion_r1513648576

Closes NEXT-2720
2024-03-05 17:12:44 -08:00
Jiachi Liu
ced7339aa6
Fix: missing crossorigin property on manifest link (#62873)
We didn't set the property of manifest before, this PR fixes the missing
prop

> If the manifest requires credentials to fetch, the crossorigin
attribute must be set to use-credentials, even if the manifest file is
in the same origin as the current page.
x-ref: https://developer.mozilla.org/en-US/docs/Web/Manifest


Fixes NEXT-2706
2024-03-06 02:04:28 +01:00
Sam Ko
bdfe247b5e
chore(cli): fix allowRetry when using port 3000 (#62840) 2024-03-05 16:19:21 -08:00