Commit Graph

9 Commits

Author SHA1 Message Date
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 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
Sebastian "Sebbie" Silbermann 0c0dc4865e [sourcemaps] Ensure codeframe when calling Client Functions from Server (#81918)
We just need to give a special name to that module so that we can ignore-list it later.

For Webpack I chose the same approach as https://github.com/vercel/next.js/pull/81229. Turbopack already sourcemapped the generated module.

Closes https://linear.app/vercel/issue/NAR-234

RSPack team is informed. Their compat layer doesn't implement `createFilename`
2025-07-22 18:29:39 +02:00
Sebastian "Sebbie" Silbermann 4699f8416e [test] Add dedicated test for error when client functions are called from server components (#81930)
We have a more specific one for `use cache`. This is the counterpart for the default environment.
2025-07-22 18:07:41 +02: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
Hendrik Liebau 750d7ea633 Bypass source map dev middleware for client chunks (#72581)
A multi-zone Next.js app might have complex rewrites for its client
assets. For these apps, resolving a source map through the
`/__nextjs_source-map` dev middleware might fail because the asset might
belong to a different app.

Instead of trying to resolve those rewrites (i.e. using `fetch` instead
of `fs`), we can just bypass the source map dev middleware for client
chunks. Because we control how those source maps are generated, we can
safely assume that the `sourceMappingURL` is relative to the filename,
with an added `.map` extension. The browser can just request this file,
and it gets served through the normal dev server, without the need to
route this through the source map dev middleware.

reverts #72258
2024-11-12 11:17:57 +01:00
Hendrik Liebau 927749c6b2 Strip assetPrefix when resolving external source maps of client chunks (#72258)
When using Turbopack, and importing a server action into a client
component, the source map for the client chunk will be requested if
devtools are open. The filename for this source map request might be
`/_next/static/chunks/[project]__800ed2._.js`, for example. This
scenario was already handled by the dev middleware.

However, it didn't consider that there might also be an `assetPrefix`
defined in the `next.config.js`. In this case, the filename would be
`/some-asset-prefix/_next/static/chunks/[project]__800ed2._.js`. When
resolving the external source map for this file, we need to strip the
asset prefix.

Again, this can only be tested manually.
2024-11-04 12:33:06 +01:00
Hendrik Liebau c54b8a3a36 Assign proper function names to server actions (#71478)
This PR adjusts the server action transforms to assign proper function names for the generated server reference proxies.

- If the original function has a name, this name is used.
- If a function expression is assigned to a variable, the variable's name is used.
- If an anonymous function expression is assigned to a prop, the prop's name is used.

In addition, this PR simplifies the output for exported functions, avoiding unnecessary `registerServerReference` calls.

It also fixes the source mapping of default exported server actions.

**Before:**

<img width="890" alt="before" src="https://github.com/user-attachments/assets/a3d6a5f8-d48e-474d-8f03-b49306fb704f">

**After:**

<img width="890" alt="after" src="https://github.com/user-attachments/assets/8f332690-6c26-46f1-9eef-7680f47ea578">

Next up, we will do the same for `'use cache'` functions.
2024-10-19 00:53:21 +02:00
Hendrik Liebau 490704430b Add source map support for server components/actions in the browser (#71042)
This PR adds support for showing the original server sources of server
components and server actions in the browser's developer tools.

To accomplish that, we're building on top of #69190, #70563, and #70564,
in which we prepared the proper generation of the source maps.

This PR completes the feature, by wiring up `findSourceMapURL` (see
https://github.com/facebook/react/pull/30741) with a new dev server
middleware that serves those source map files to the browser.

Another change we had to make is disabling the dead-code elimination of
server actions in client bundles (see #70103), but only in development
mode. This optimization is primarily intended for production bundles, so
the change should not pose a problem.

With that, it's now possible to jump directly into the server sources
from the browser's dev tools, e.g. for component stacks of server logs
that are replayed in the browser, or when inspecting server action props
in the React DevTools.
2024-10-11 13:53:39 +00:00