Commit Graph

23 Commits

Author SHA1 Message Date
Janka Uryga 55b26f96ab [PPF] Scaffold unstable_prefetch() (#97618)
Scaffolds a new API, `unstable_prefetch()`. It's only allowed in server
code, so we ban it from being imported in the client.
Implementation follows upstack. Intended to be merged together.
2026-08-21 13:50:23 +02:00
Janka Uryga 2cc3694fda [PPF] Scaffold unstable_navigation() (#97236)
Scaffolds a new API, `unstable_navigation()`. It's only allowed in
server code, so we ban it from being imported in the client.
Implementation follows upstack. Intended to be merged together.
2026-08-20 15:27:11 +02:00
Hendrik Liebau cdf5c37d84 Scope app-entry export validation to files inside the app directory (#97350)
Adopts #97150. Closes #97150.

Fixes #96859

### What?

Since 16.3.0, builds fail for pages-router files named `sitemap` or
`robots` that export `getStaticProps`/`getServerSideProps`:

```
Error: "getStaticProps" is not supported in app/.
```

This is a regression from #94962, which added the metadata conventions
(`sitemap`, `robots`, `manifest`, `icon`, …) to the app-entry filename
regex in `ReactServerComponentValidator::assert_invalid_api`. The regex
only looks at the filename, so a file like `pages/sitemap.js` is now
mistaken for an app entry and rejected for exporting `getStaticProps`.

### How?

A file is only treated as an app entry when it's inside `appDir`,
reusing the gate `assert_server_filename` already applies to `error.js`.
The pages compilation context has no `appDir`, so pages-router files are
never validated as app entries.

On the test side:

- The fixtures that exercise the app-entry checks moved under
`app-dir/`, since the test harness derives `appDir` from the fixture
path. Their contents are unchanged.
- A new fixture (plus a `sitemap.js` fixture glob) asserts that a
pages-style `sitemap.js` compiles without errors.
- A new e2e suite, `test/e2e/pages-metadata-filenames`, covers
`pages/sitemap.js` with `getStaticProps` and `pages/robots.js` with
`getServerSideProps`. It fails without the fix under Turbopack (build
and dev) and passes with it under both Turbopack and webpack.

Supersedes #96873 (same approach, closed by its author) and closes
#96967.

---------

Co-authored-by: Rodrigo Arias <rodrigo@arias.me>
2026-08-14 11:53:24 +02:00
Josh Story d424aa8ec4 Stabilize unstable_instant (#94578)
This API has experimental modes for build validation but the dev
validation is going to be stable in the next release.
2026-06-09 13:50:25 -07:00
Jiwon Choi 66478522a8 Improve RSC error messages (#90702)
Improve the RSC error messages to be more comprehensive.

x-ref:
https://github.com/vercel/next.js/pull/89688#discussion_r2865847895

---------

Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
2026-03-17 14:37:26 +01:00
Josh Story 410c65808a Add static error when unstable_instant is used without cacheComponents (#90793)
`unstable_instant` requires `cacheComponents` to function — without it,
validation is entirely skipped and the config silently does nothing.
This adds a compile-time error in the SWC transform that catches the
misconfiguration early, matching the existing pattern used for segment
configs like `revalidate` that are incompatible with `cacheComponents`
(but inverted — `unstable_instant` requires it rather than being
incompatible with it). The error points directly to the export in the
user's source file.
2026-03-03 00:35:56 +00:00
Tim Neutkens ae17e48bbf Update generateMetadata in client component error (#88172)
## What?

Improves the error shown when `generateMetadata` or `metadata` is
exported from a Client Component.

Also updated the documentation to further explain why it can only be
used in a server component and the steps to follow to resolve the error.
2026-01-07 09:45:44 +01:00
Zack Tanner b1ce6042be add compilation error for taint when not enabled (#88173)
Using `taint` APIs from React without enabling `experimental.taint` will
error at runtime because it needs to bundle experimental React, making
it hard to catch and potentially leading to downtime. This updates our
transform to throw an error if we detect that it's imported but `taint`
isn't enabled.

Fixes NAR-690
2026-01-06 11:57:46 -08:00
Hendrik Liebau 5bd7c6fec0 [test] Add missing test fixtures for cacheLife & cacheTag in client (#85872)
Importing `cacheLife` and `cacheTag` in Client Components yields build errors. This adds test fixtures to cover these scenarios.

In addition, we're duplicating the test fixtures that have different error messages between `app/` and `pages/` directories to ensure both cases are covered.
2025-11-11 14:37:43 +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
Jiwon Choi 28b64e2f8d [Breaking] Remove deprecated unstable_rootParams (#84373)
This PR removed the deprecated `unstable_rootParams`. This feature was
not documented.
2025-10-01 18:49:49 +02:00
Wyatt Johnson 8abbb3dc2e refactor: rename experimental.dynamicIO to experimental.cacheComponents (#81562)
## What?

Rename `experimental.dynamicIO` to `experimental.cacheComponents` across
the Next.js codebase.

## Why?

We're going to be merging the functionality of the `ppr`, `dynamicIO`
and `useCache` experimental flags into the singular `cacheComponents`
flag to reduce complexity of the codebase and simplify adoption for
users wanting to experiment with experimental features.

## How?

- Renamed the configuration option from `experimental.dynamicIO` to
`experimental.cacheComponents`
- Added deprecation handling with automatic migration for the old option
name
- Updated all documentation, tests, and internal references
- Updated Rust code in SWC transforms and Turbopack
- Maintained backward compatibility with deprecation warnings

NAR-158
2025-07-17 19:30:28 -06:00
Josh Story 7e44fe350e disallow unstable_rootParams in client components (#79471)
unstable_rootParams is a server component API and should not be allowed
to be accessed from client components. This change adds a compiler error
if this import is detected within the client module graph.
2025-05-21 13:49:58 -07:00
Jiwon Choi fd438787f3 misc: use correct capitals for React terms (#78445)
- `Client/Server Component`
- `React Hooks`

---------

Co-authored-by: Sebastian "Sebbie" Silbermann <sebastian.silbermann@vercel.com>
2025-04-23 21:50:55 +09:00
Jude Gao 8db39d6c00 fix: client-only error message format (#75446)
Looking at the test file change should convince you that this fixes the formatting issue.

https://linear.app/vercel/issue/NDX-671/error-from-client-only-package-is-malformed
2025-01-29 19:33:59 -05:00
Hendrik Liebau 7aa61377fb Emit build error when useCache is enabled and Edge runtime is used (#75279)
The `"use cache"` directive is not compatible with the Edge runtime.

When the `experimental.useCache` flag is enabled, we now emit a build
error for pages with `export const runtime = 'edge'`. This is analogous
to using the `experimental.dynamicIO` flag.

The other route segment configs that are forbidden when `dynamicIO` is
enabled, are currently still allowed for `useCache`:

- `dynamicParams`
- `dynamic`
- `fetchCache`
- `revalidate`
2025-01-24 17:33:24 +00:00
Hendrik Liebau bc3e597ae5 Fix export statement validations for app router pages (#75278)
Fixes all issues related to the current export statement validation for
app router pages, as highlighted in #75277.
2025-01-24 17:55:26 +01:00
Hendrik Liebau 958b9669fb Add test fixtures demonstrating export statement validation bugs (#75277)
The issues with the current export statement validation for app router
pages are documented in the added fixtures, see also the inline comments
in the diff.
2025-01-24 17:24:02 +01:00
Jam Balaya 3c3710bef4 chore: update getting-started/react-essentials path (#72250)
## Description
At #51579, react-essentials.mdx was deleted.
Some URLs doesn't navigate right pages due to this change.
Then I update to correct path.

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

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-11-12 16:07:47 -08:00
Donny/강동윤 5fd1d537c1 feat(next-swc): lint for ssr: false in server components (#70378)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2024-09-25 20:40:33 +02:00
Donny/강동윤 e40574b0ae fix: Fix syntax context usage and add PURE comments in server actions (#70014)
### What?

Fix usages of `SyntaxContext` in server actions transform.

### Why?

This is part of [the tree-shaking PR](https://github.com/vercel/next.js/pull/69344).

### How?
2024-09-13 03:59:45 +00:00
Donny/강동윤 ca90723191 feat: Add a lint for deprecated APIs (#69772)
### What?

Add a linter for importing `ImageResponse` from `next/server`.

### Why?

It's deprecated .

### How?

Closes PACK-3237
2024-09-10 14:56:33 +02:00
hrmny cad3a51049 refactor: move rust crates to the repo root directory (#67780)
### Why?
In preparation for moving all turbopack crates

Also makes them easier to work with in general.

Closes PACK-3164
2024-07-22 18:41:27 +02:00