Commit Graph

134 Commits

Author SHA1 Message Date
Sebastian "Sebbie" Silbermann 6ba71046b0 [test] Move the harness off node-fetch (#98195)
Node.js ships with a built-in `fetch` now so `node-fetch` is no longer
necessary. Mostly motivated by tracing Node.js deprecation warnings
which originated from `node-fetch` by calling the deprecated
`url.parse`.

Call sites keep working through a compatibility type on `fetchViaHTTP`
that translates node-fetch-only options: Instead of `agent` we pass to
`http(s)` directly, `timeout` becomes `AbortSignal.timeout`, and Node.js
readable streams are accepted as bodies with `duplex: 'half'` set
automatically.

The `abort-controller` polyfill is dropped since its signal type
predates the current AbortSignal and undici would not honor it.
`node-fetch` stays installed because `scripts/generate-release-log.mjs`,
`scripts/reset-project.mjs`, and `scripts/update-google-fonts.js` still
import it (follow-up material). Fixture apps will be migrated
separately.
2026-09-10 13:50:35 +02:00
Jude Gao 1cad9e989a Rename experimental.useExperimentalReact to blockingSSR (#94869)
`experimental.useExperimentalReact` names the React *build* it pulls in
rather than the feature it's there for. Rename it to `blockingSSR` — the
actual capability (React's blocking SSR, which emits `<link
rel="expect">` to hold first paint until the streamed shell is coherent)
— mirroring React's own feature flag so it's clear why the experimental
channel got enabled when grepping.

<!-- NEXT_JS_LLM_PR -->
2026-06-17 10:35:07 -04:00
Jude Gao 71b70e01b8 Add experimental.useExperimentalReact to opt into React's experimental channel (#94861)
Opting into React's experimental channel — which emits `<link
rel="expect">` to hold first paint until the streamed shell is coherent,
avoiding flicker from partially-streamed HTML — currently requires
enabling an unrelated feature like `experimental.taint` as a side
effect, which is confusing. This adds
`experimental.useExperimentalReact` as a direct opt-in.

It feeds the existing `needsExperimentalReact` aggregation and the
matching Turbopack `react_channel` switch, selecting the
`react@experimental` build the same way `taint`, `transitionIndicator`,
and `gestureTransition` do. It's opt-in only: an explicit `false` can't
disable the channel when one of those still requires it (the taint APIs
only exist in the experimental build), so `assignDefaults` warns on that
contradiction. Covered by a webpack e2e test mirroring the existing
`taint` channel test.

<!-- NEXT_JS_LLM_PR -->
2026-06-16 15:08:47 -04:00
Niklas Mischkulnig 02af7ed3a4 test: Improve test assertions to prepare for dpl query string (#90463)
*This doesn't enable skew protection for any new tests, only preparation*

Prepare a lot of test assertions so that they work correctly when a `?dpl=123` query param is present:
- some regexes should accept the query
- some places assumed that the `<script>`'s `src` is a valid pathname, whereas it might have a query param that has to be stripped before removing the path
- some hardcoded build ids instead of `next.buildId`
2026-02-25 12:16:10 +01:00
Niklas Mischkulnig eb14325ed4 Turbopack: remove deployment id suffix from client reference manifest chunks (#88741)
Closes PACK-6539

When `experimental.runtimeServerDeploymentId` is enabled, read the `process.env.NEXT_DEPLOYMENT_ID` and append to the chunks when evaluating the `client-reference-manifest.js`

Originally, I tried to do it after the manifest is loaded (in `loadComponents` or in the `RouteModule.prepare`) to "hydrate" the manifest, but that is too late because the manifest needs to be initialized immediately to make module-evaluation-time server actions work (which need the manifest immediately)
2026-01-20 16:11:24 +01:00
Zack Tanner 85c3d20a91 [cache components]: move flag out of experimental (#85035)
This moves `experimental.cacheComponents` to a top level config. As part
of this, I disabled some tests in `build-output-prerender` that assert
on `cacheComponents` appearing in the experimental list. In a separate
PR, I'm going to show that Cache Components is enabled next to the
bundler info.

This also updates some docs pages to remove "experimental" language.
2025-10-18 14:13:44 -07:00
Wyatt Johnson 3630146458 Add validation for missing default.js in parallel routes (#84702)
### What?

Adds build-time validation to require explicit `default.js` files for
all parallel route slots (except the implicit "children" slot). This
validation is implemented in both Webpack and Turbopack bundlers.

### Why?

Parallel routes without `default.js` files currently cause silent 404
errors when users navigate to those routes. This creates confusion and
hard-to-debug issues because the routes appear to be configured
correctly but fail at runtime without any indication of what went wrong.

By making this validation explicit at build time, developers get
immediate feedback about missing required files with clear error
messages and documentation links, catching configuration mistakes before
deployment.

### How?

**Rust/Turbopack** (`crates/next-core/src/app_structure.rs`): Added
`MissingDefaultParallelRouteIssue` that emits a build error when a
parallel route slot is missing its `default.js` file. The validation is
skipped for the "children" slot since it's implicit and doesn't require
a default file.

**Webpack**
(`packages/next/src/build/webpack/loaders/next-app-loader/index.ts`):
Added validation that throws `MissingDefaultParallelRouteError` when
`default.js` cannot be resolved. The "children" slot falls back to the
existing `PARALLEL_ROUTE_DEFAULT_PATH` behavior for backward
compatibility.

**Error Class**
(`packages/next/src/shared/lib/errors/missing-default-parallel-route-error.ts`):
New error type with helpful messaging that includes the slot path,
explanation of the requirement, and a link to documentation.

**Migration Path**: Users who want the previous 404 behavior can
explicitly create a `default.js` that calls `notFound()`, or return
`null` for empty slots:

```tsx
import { notFound } from 'next/navigation'

export default function Default() {
  notFound()
}
```

Users can also run the following Deno script to generate the default
files for them:
https://gist.github.com/wyattjoh/ba7263ecb637ef399d3e3e4db63ffbd6

**Breaking Change**: This is a breaking change timed for Next.js 16
beta. Builds will now fail if parallel route slots are missing required
`default.js` files.
2025-10-09 15:20:52 -06:00
Wyatt Johnson d81ef2691c feat(breaking): Hard Deprecate PPR Configuration (#84280)
This hard deprecates the `experimental.ppr` configuration, requiring
users to opt-in instead via `experimental.cacheComponents`. This does
mean that the previous `experimental.ppr = "incremental"` will no longer
be supported.

NAR-433
2025-10-08 19:55:52 -06:00
Jiwon Choi c388db43dc CI: Enable experimental.isolatedDevBuild for test-dev (#84562)
Enabling `experimental.isolatedDevBuild` required many changes to the
current workflow, so we will incrementally roll out to the tests.

Enabling on test-dev instead of test-experimental-dev because
`-experimental` CIs are filtered via `experimental-tests-manifest.json`
and they don't cover all tests. We want to enable this feature by
default so we should ensure this incremental rollout is covered on all
test cases.

The flag was enabled for `test-experimental-dev` at
https://github.com/vercel/next.js/pull/84099, and this PR moves the flag
to the `test-dev` job.

1. ~~test-experimental-dev
([link](https://github.com/vercel/next.js/pull/84099))~~
2. test-dev (here)
3. test-prod
4. test-integration
5. test-unit
6. Enable by default, remove the flag, and update the rest

x-ref: https://github.com/vercel/next.js/pull/84043
2025-10-07 00:44:08 +02:00
Sebastian "Sebbie" Silbermann caffa0d866 [test] Resolve elementByCSS and waitForElementByCSS once visible (#83301) 2025-09-03 09:47:35 +00:00
Zack Tanner 7dc7c98e02 fix dynamic param extraction in edge-ssr-app (#83081)
Fixes edge runtime pages with dynamic routes returning 500 errors when
the URL segment literally contains bracket syntax that matches the
folder name (e.g., accessing `/[id]` for a route defined as
`/[id]/page.tsx`).

The removal of web-server.ts in #81389 modified how route params were
extracted for dynamic routes. The route matcher in prepare() was being
created with the full internal page path (e.g., /[id]/page) which
generated a regex expecting /page at the end. However, actual URL
pathnames don't include the /page suffix, causing the matcher to fail
when trying to extract params. This issue specifically manifested when
the URL contained literal brackets (like /[id]), as the fallback param
extraction would fail and leave params empty, leading to the error.

This PR normalizes the page path using before creating the route matcher
in prepare(). This ensures the regex pattern matches the actual URL
pathname format (without /page suffix).

Fixes NEXT-4698
2025-08-27 06:26:59 -07:00
Janka Uryga ee284b8ba1 refactor: lowercase app router header values (#82169)
we define most of the app router headers with capital letters, like
this:
```ts
export const NEXT_ROUTER_PREFETCH_HEADER = 'Next-Router-Prefetch' as const
```
which means we have to keep lowercasing the header everywhere when
checking for its presence, because node and other intermediate layers
normalize all headers to lowercase:
```ts
if (req.headers[NEXT_ROUTER_PREFETCH_HEADER.toLowerCase()]) { ... }
```
this seems pretty pointless -- we can just define the headers in
lowercase form, and skip all those `toLowerCase()` calls.

(all the above sentences have been normalized to lowercase to match the
spirit of this pr)
2025-07-30 13:42:16 +02:00
Jude Gao 6fd6ed1ea2 Check cache busting search params on all RSC requests (#80669)
For all RSC requests, we require the `_rsc` search param to match the
hash of its corresponding RSC headers. In the case where the match
fails, we respond with a redirect to the correct search param. This hash
check only applies to `next start` mode for now.
2025-06-25 12:46:29 -04:00
Janka Uryga d35f80b8fa test: ignore streaming metadata in toBeEmpty assertions (#78456)
Some tests in `rsc-basic` asserts that certain nodes should be empty,
but streaming metadata can get in there and break that expectation.

- i switched the test to use a full browser. this is better than
checking the raw html, because then react gets rid of any `<template>`
tags inside the div (which are used for streaming SSR things)
- we're also now only asserting that the inner text of the node should
be empty, which avoids failures because of a `<div hidden>` inserted by
streaming metadata. this is a slightly weaker assertion than "this node
has no children at all" but it should be enough for our purposes here.

also reverts #78449 and #78424, they were meant for debugging this issue
2025-04-23 15:17:35 +00:00
Janka Uryga f42ba511e6 test: flake debugging - avoid logs being eaten by jest (#78449)
follow up to #78424. annoyingly, it appears that the console.log output
gets swallowed by jest somehow, so i'm using `require('console')`
instead which jest doesn't instrument.
2025-04-23 13:24:34 +02:00
Janka Uryga 98e61efee0 test: log html output for a flaky test to debug it (#78424)
this test has been flaky recently but we don't know why and can't repro
locally. this PR adds a log to inspect the full HTML when it fails

x-ref: https://vercel.slack.com/archives/C05KYT5S9FF/p1745259844464719
2025-04-22 19:03:01 +00:00
Janka Uryga 4282bc6f91 remove BrowserInterface (#78308)
rip. you served a purpose once, but now you're just getting in the way. this improves typesafety quite a bit, because `BrowserInterface` had a whole bunch of random `any`s everywhere

also
- removes `evalAsync`. no idea why that was needed, but we're happily using promises in normal eval, so it can be dropped
- adds more safety to `chain`
2025-04-18 11:16:15 -07:00
Jiachi Liu 3e24bdc789 [test] separate rsc-basic tests (#78038) 2025-04-11 01:36:20 +02:00
Janka Uryga 8370d498cc test: attempt to de-flake rsc-basic (#77934)
I've been seeing this test flake with some regularity:

---
● app dir - rsc basics › should be able to navigate between rsc routes

```
request.allHeaders: Target page, context or browser has been closed

  168 |         page.on('request', (request) => {
  169 |           requestsCount++
> 170 |           return request.allHeaders().then((headers) => {
      |                          ^
  171 |             if (
  172 |               headers['RSC'.toLowerCase()] === '1' &&
  173 |               // Prefetches also include `RSC`

  at Page.allHeaders (e2e/app-dir/rsc-basic/rsc-basic.test.ts:170:26)
```
---

[Example test run
here](https://github.com/vercel/next.js/actions/runs/14313872710/job/40115445718?pr=77898#step:33:3431)

The error is actually unrelated to `should be able to navigate between
rsc routes`, and is coming from async operations (that haven't completed
in time) in another test in the same suite, `should reuse the inline
flight response without sending extra requests` .

I've de-asyncified the test's `page.on('request')` handler -- we don't
need the async `allHeaders()`, `headers()` is enough.
(I verified this by adding a client component that manually sends a
request with `RSC: 1`, and that does indeed trigger our request
listener).
I've also added a `waitForIdleNetwork` to hopefully make it complete all
requests before the test ends.
2025-04-08 17:38:49 +02:00
Jiachi Liu 47753fe7b3 [metadata] enable streaming metadata by default (#76221) 2025-02-23 17:56:42 +01:00
Vercel Release Bot 07634b2747 Remove experimental.reactOwnerStack flag (#76021)
Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
2025-02-14 17:58:47 +01:00
Zack Tanner 1c85b755b5 [DevOverlay]: enable by default (#75882)
- `newDevOverlay: true` by default (enables experimental React builds on
canary until owner stacks progress further)
- `run-tests` now sets the env var for tests that were relying on it for
forking behavior
- PPR runners now run with the flag disabled to help catch regressions
in the old overlay until we remove it
- Fixed a number of tests that had outdated snapshots or missed forking
behavior because they weren't running in CI
- Disabled a test that was failing in Turbopack + Experimental React
that is unrelated to the overlay (see:
https://github.com/vercel/next.js/pull/75989)

---------

Co-authored-by: devjiwonchoi <devjiwonchoi@gmail.com>
2025-02-13 10:57:32 -08:00
Jiachi Liu 461f0be27f [metadata] Remove deadcode and extract separate test suite (#75528) 2025-02-03 22:47:09 +00:00
Vercel Release Bot 983fd271de Upgrade React from 372ec00c-20241209 to 518d06d2-20241219 (#74155) 2024-12-19 23:02:44 +01:00
Sebastian "Sebbie" Silbermann 3c3fd7367e Use React 19 stable in Pages Router (#73562) 2024-12-05 21:19:20 +01:00
Hendrik Liebau c376f39172 Use registerClientReference for ESM client component modules (#71968) 2024-10-28 23:04:38 +01:00
Jiachi Liu f91cdec44d test: migrate rest async api usage in tests (#71663) 2024-10-23 02:36:20 +02:00
Vercel Release Bot 2f7a48fa4d Upgrade React from 2d16326d-20240930 to 70fb1363-20241010 (#71118)
Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
2024-10-11 17:03:27 +00:00
Wyatt Johnson 55950d37e4 refactor: added more strict app segment config parsing (#70479)
This enhances the current parsing completed by Next.js of configuration
from app segments. Previously a collection of fragile checks was used to
parse the different segment configuration options which performed no
validation on the inputs.

This uses the `zod` library (which we already use internally) to perform
validation on the configuration exported. A followup PR #70480 will add
more verbose error logging around the validation errors.
2024-09-30 21:02:12 -07:00
Josh Story 05f159dffc [Breaking] Update Dynamic APIs to be async (#68812)
Next.js has a number of dynamic APIs that aren't available during
prerendering. What happens when you access these APIs might differ
depending on the mode you are using, for instance if you have PPR turned
on or the newly introduced `dynamicIO` experimental mode. But regardless
of the mode the underlying API represents accessing something that might
only be available at render time (dynamic rendering) rather than
prerender time (build and revalidate rendering)

Unfortunately our current dynamic APIs make certain kinds of modeling
tricky because they are all synchronous. For instance if we wanted to
add a feature to Next.js where we started a dynamic render before a
Request even hits the server it would be interesting to be able to start
working on everything that does not rely on any dynamic data and then
once a real Request arrives we can continue the render and provide the
associated Request context through our dynamic APIs.

If our dynamic APIs were all async we could build something like this
because they represnt a value that will eventually resolve to some
Request value. This PR updates most existing dynamic APIs to be async
rather than sync. This is a breaking change and will need to be paired
with codemods to realistically adopt. Additionally since this change is
so invasive I have implemented it in a way to maximize backward
compatibility by still allowing most synchronous access. The combination
of codemods, typescript updates, and backward compat functionality
should make it possible for projects to upgrade to the latest version
with minimal effort and then follow up with a complete conversion over
time.

#### `cookies()`
`cookies()` now returns `Promise<ReadonlyRequestCookies>`. Synchronous
access to the underlying RequestCookies object is still supported to
facilitate migration.
```tsx
// ------------ preferred usage

// async Server Component
const token = (await cookies()).get('token')

// sync Server Component
import { use } from 'react'
//...
const token = use(cookies()).get('token')

// ------------ temporarily allowed usage

// javascript, dev warning at runtime
const token = cookies().get('token')

// typescript, dev warning at runtime
import { type UnsafeUnwrappedCookies } from 'next/headers'
// ...
const token = (cookies() as unknown as UnsafeUnwrappedCookies).get('token')
```

#### `headers()`
`headers()` now returns `Promise<ReadonlyHeaders>`. Synchronous access
to the underlying Headers object is still supported to facilitate
migration.
```tsx
// ------------ preferred usage

// async Server Component
const header = (await headers()).get('x-foo')

// sync Server Component
import { use } from 'react'
//...
const header = use(headers()).get('x-foo')

// ------------ temporarily allowed usage

// javascript, dev warning at runtime
const header = headers().get('x-foo')

// typescript, dev warning at runtime
import { type UnsafeUnwrappedHeaders } from 'next/headers'
// ...
const header = (headers() as unknown as UnsafeUnwrappedHeaders).get('x-foo')
```


#### `draftMode()`
`draftMode()` now returns `Promise<DraftMode>`. Synchronous access to
the underlying DraftMode object is still supported to facilitate
migration.
```tsx
// ------------ preferred usage

// async Server Component
if ((await draftMode()).isEnabled) { ... }

// sync Server Component
import { use } from 'react'
//...
if (use(draftMode()).isEnabled) { ... }

// ------------ temporarily allowed usage

// javascript, dev warning at runtime
if (draftMode().isEnabled) { ... }

// typescript, dev warning at runtime
import { type UnsafeUnwrappedDraftMode} from 'next/headers'
// ...
if ((draftMode() as unknown as UnsafeUnwrappedDraftMode).isEnabled) { ... }
```

#### `searchParams`
`searchParams` is now a `Promise<{...}>`. Synchronous access to the
underlying search params is still supported to facilitate migration.
```tsx
// ------------ preferred usage

// async Page Component
export default async function Page({
  searchParams
}: {
  searchParams: Promise<{ foo: string }>
}) {
  const fooSearchParam = (await searchParams).foo
}

// sync Page Component
import { use } from 'react'
export default function Page({
  searchParams
}: {
  searchParams: Promise<{ foo: string }>
}) {
  const fooSearchParam = use(searchParams).foo
}

// ------------ temporarily allowed usage

// javascript, dev warning at runtime
export default async function Page({ searchParams}) {
  const fooSearchParam = searchParams.foo
}

// typescript, dev warning at runtime
import { type UnsafeUnwrappedSearchParams } from 'next/server'
export default async function Page({
  searchParams
}: {
  searchParams: Promise<{ foo: string }>
}) {
  const syncSearchParams = (searchParams as unknown as UnsafeUnwrappedSearchParams<typeof searchParams>)
  const fooSearchParam = syncSearchParams.foo
}
```



#### `params`
`params` is now a `Promise<{...}>`. Synchronous access to the underlying
params is still supported to facilitate migration. It should be noted
that while params are not usually dynamic there are certain modes where
they can be such as fallback prerenders for PPR.
```tsx
// ------------ preferred usage

// async Segment Component
export default async function Layout({
  params
}: {
  params: Promise<{ foo: string }>
}) {
  const fooParam = (await params).foo
}

// sync Segment Component
import { use } from 'react'
export default function Layout({
  params
}: {
  params: Promise<{ foo: string }>
}) {
  const fooParam = use(params).foo
}

// ------------ temporarily allowed usage

// javascript, dev warning at runtime
export default async function Layout({ params}) {
  const fooParam = params.foo
}

// typescript, dev warning at runtime
import { type UnsafeUnwrappedParams } from 'next/headers'
export default async function Layout({
  params
}: {
  params: Promise<{ foo: string }>
}) {
  const syncParams = (params as unknown as UnsafeUnwrappedParams<typeof params>)
  const fooSearchParam = syncParams.foo
}
```

### Typescript Changes
When using typescript with Next.js currently it is up to you to author
types for Pages, Layouts and other Segment components that recieve props
like `params` and `searchParams`.

Next comes with some build-time type checking to ensure you have not
improperly typed various top level module exports however the current
type assertions for `params` and `searchParams` is `any`. This isn't
very helpful because it allows you to erroneously type these props.

`searchParams` is tricky because while the default type is a dictionary
object parsed using node.js url parsing it is possible to customize when
running a custom Next.js server. However we can ensure that you
correctly type the prop as a Promise so with this change the validated
type for `searchParams` will be `Promise<any>`.

In the long run we will look at updating the `searchParams` underlying
type to be URLSearchParams so we can move away from supporting
customized parsing during rendering and we can get even more explicit
about valid types.

`params` is more straight forward because the framework controls the
actual `params` prop implementation and no customization is possible. In
the long run we want to enforce you are only typing params that are
valid for the Layout level your file is located in but for now we are
updating the allowed type to be `Promise<{[key: string]: string |
string[] | undefined }>`.

These new type restrictions may also require fixes before being able to
successfully build a project that updates to include these breaking
changes. These changes will also not always be codemodable because it is
valid to type the entire component using an opaque type like `Props`
which our codemods may not have an ability to introspect or modify.
2024-09-25 15:44:37 -07:00
Sebastian "Sebbie" Silbermann 1cb6faaee1 Extend support of Pages router to React 18 (#70219) 2024-09-25 19:08:13 +02:00
Niklas Mischkulnig 1e759399d9 Add test for TLA in client references (#70022)
Fixes PACK-3246
2024-09-24 10:52:17 +02:00
Tim Neutkens 69f07b680c Revert "Support React 18 in Pages Router" (#69911)
Reverts vercel/next.js#69484
2024-09-10 10:20:27 +02:00
Sebastian "Sebbie" Silbermann 0f2845d2d8 Support React 18 in Pages Router (#69484)
Pages router (`/pages`) will continue to support React 18 not the React
19 RC. Current thinking is that we'll add support for React 19 in Pages
Router once 19 is stable.

This does not affect App Router (`/app`) which continues to use the
latest React Canary (i.e. React 19).

https://github.com/vercel/next.js/pull/65058 is required reading to
understand the changes in this PR

---------

Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
2024-09-09 15:26:08 -07:00
Sebastian "Sebbie" Silbermann 55ff46bc5e Stop testing react-dom/server in RSCs (#69139) 2024-08-22 23:16:39 +00:00
Sebastian "Sebbie" Silbermann 532345f048 Ensure assertion failures include all versions in rsc-basic tests (#69138) 2024-08-21 17:35:58 +02:00
Zack Tanner 6dff88531a ensure component tree is only rendered once during SSG/revalidations (#67680)
### What
When statically generating a page, Next.js will attempt to render the
application tree twice, resulting in unexpected calls to upstream APIs
and also slowing down the application during build as it needs to make 2
passes for the same data.

### Why
Next.js currently calls React's `renderToReadableStream` API in two
spots: once for the HTML render, and again for the Flight render. This
is because we want to generate a `.rsc` output for statically generated
pages, so that on navigation, we don't need to call the server to
retrieve the flight payload.

### How
Rather than calling `renderToReadableStream` twice, this refactors the
approach to instead only perform it once. This introduces a new type to
describe the response from calls to `createFromFetch`: `RSCPayload`,
including a set of utils to access the relevant payload data, as it can
change depending on calling context.

- During the initial SSR response & when statically generating the
flight payload, this will be an object containing the top-level props
that are used to render `<AppRouter />`
- For dynamic pages, this will only return the diffed component tree,
which is computed by `walkTreeWithFlightRouterState` traversing the
provided `next-router-state-tree` (from the client) to determine where
to start rendering (**this is unchanged from today**)
- For server actions, this will return the action result, in addition to
the same payload as above (**this is also unchanged**)

Fixes #58736
Fixes #43254
Fixes #60562

Closes NDX-17
2024-07-17 06:51:15 -07:00
Jiachi Liu 62e8c9dd45 test: add name re-export from client components as page case (#66760)
### What

Add new test case where a named export from client component is being
exported as page

### Why

We found this case while investigating the errors triggered introduced
by #66286 , adding this test to avoid future regression
2024-06-11 18:42:10 +00:00
Tim Neutkens 95d1bb2cac Split webpack specific test into separate test suite (#66328)
## What?

Ensures `next build` does not fail with Turbopack on
`test/e2e/app-dir/rsc-basic/rsc-basic.test.ts`. Gets 36 extra tests
passing 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 #

-->
2024-05-30 12:29:18 +02:00
Sebastian Silbermann a25e7d2fe9 Update React from 04b058868c to 81c5ff2e04 (#65869) 2024-05-22 14:46:57 +02:00
Jiachi Liu afe4f2fe13 Fix the runtime for rsc layer (#65850)
### What

Fix a bug introduced in #65694 , use app-page runtime for app router
layers

### Why

This is basically reverted the route context picking up logic we had
before.

During the test we found the error thrown
> Module not found: shared-runtime module router-context cannot be used
in rsc layer

Which is caused by a `next/router` imports in rsc page. Decided to
revert to what it was before as the most safe way to load share module
contexts.

It's caused by `next-contentlayer` usage that they're using
`next/router` in server component MDX, but we cannot lint error that
from node_modules. (We actually can, but disabled that due to various
mis-usage of server/client hooks we had before)
2024-05-16 18:27:35 +02:00
Ethan Arrowood d0d22ac625 Promote and rename server bundling options serverComponentsExternalPackages and bundlePagesExternals (#65421)
This PR promotes and renames experimental configuration options related
to server bundling:
- `serverComponentsExternalPackages` -> `serverExternalPackages`
- `bundlePagesExternals` -> `bundlePagesRouterDependencies`

Existing docs for `serverComponentsExternalPackages` was changed. 
New docs for `bundlePagesRouterDependencies` were added.

Closes NEXT-3332
2024-05-07 11:19:35 -06:00
Sebastian Silbermann 2c31c79ac8 Support React 19 in App and Pages router (#65058)
Closes NEXT-3218

---------

Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-05-07 18:18:32 +02:00
Wyatt Johnson c6320ed87a Replace createNextDescribe with nextTestSetup (#64817)
<!-- 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 #

-->

I took some time and [wrote a
codemod](https://gist.github.com/wyattjoh/0d4464427506cb02062a4729ca906b62)
that replaces the old usage of the `createNextDescribe` with the new
`nextTestSetup`. You'll likely have to turn on hiding of whitespace in
order to review, but this should primarily introduce no changes to the
test structure other than using the new mechanism now.

Closes NEXT-3178
2024-04-25 12:06:12 -06:00
Donny/강동윤 014b212388 Update swc_core to v0.87.28 (#60876)
# Turbopack

* https://github.com/vercel/turbo/pull/7027 <!-- Donny/강동윤 - Update `swc_core` to `v0.87.28` -->

---

### What?

Update swc crates

### Why?

Required for #57718.
`styled-jsx` crate now has a hook to transform CSS code using a
Rust-side API

### How?

Fixes #57718



Closes PACK-2256
2024-01-24 08:05:05 +00:00
Andrew Clark 377c5eb80c Fix CI: Skip test in PPR dev mode, too (#59817)
In #59725 I skipped this test in PPR prod mode, but not dev because CI
wasn't failing for dev. The idea was to investigate the failure
post-merge because it wasn't block-worthy.

But the test did fail in dev mode when CI ran on canary. So this updates
the guard to skip in dev, too.

Will follow up with a PR to fix the test itself.

Closes NEXT-1913
2023-12-20 14:22:30 -05:00
Jiachi Liu d14410ce32 Optionally bundle legacy react-dom/server APIs based on usage (#59737) 2023-12-20 16:50:06 +01:00
Zack Tanner 809164d776 Enable PPR tests for test suites (#59030)
Cherry-picks #58708 without the dependency on https://github.com/vercel/next.js/pull/58779

Co-authored-by: Wyatt Johnson <633002+wyattjoh@users.noreply.github.com>
2023-11-29 03:22:45 +00:00
Jimmy Lai 3e7f96e16a revert "Apply react-server condition for pages api (#57459)" (#57500)
This reverts commit 6b18f397cb.

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

## For Contributors

### Improving Documentation

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

### Adding or Updating Examples

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

### Fixing a bug

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

### Adding a feature

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


## For Maintainers

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

### What?

### Why?

### How?

Closes NEXT-
Fixes #

-->
2023-10-26 04:37:13 -07:00
Jiachi Liu 6b18f397cb Apply react-server condition for pages api (#57459)
Apply react-server condition and related API checks for pages API.

if you're doing react SSR with renderToString in middleware it should be disallowed. Imaging it could send the rendered html code to client and you display it in browser. But it might require hydration so it can be broken.

Follow up for #57448 , same reason explained in #57448
Closes NEXT-1653
2023-10-26 02:07:27 +00:00