next.js
eccbcfce - [Experiment] Parse the experimental_nativeRscRuntime segment export

Commit
1 day ago
[Experiment] Parse the experimental_nativeRscRuntime segment export Scaffolding for an experiment: the native RSC runtime, a highly experimental runtime for rendering React Server Components on the server. None of it is usable yet: the first phase supports one shape of page, a page directly inside the root layout, and leaves everything else out on purpose. A page opts into the native RSC runtime with `export const experimental_nativeRscRuntime = true`. Turbopack reads it by static analysis, like `runtime`: it inherits from layouts and is App Router only. Unlike `runtime`, it has to be a literal `true` on a `const` export, the one form the build's static info also reads, so Turbopack and the build agree on which form of the export counts. The built-in not-found and global-error pages don't inherit it from the root layout: not-found and error renders stay on App Router for now. A `not-found.tsx` or `global-not-found.tsx` that sets the export itself is still a build error. A parallel slot's `default.tsx` that sets it opts the route in on Turbopack, which reads the whole loader tree; the build's static info reads only the page and its layouts, the same as for `runtime`. The page's entry for the runtime is deliberately left for a later step, so for now a page that sets the export is always a build error, never a silent fallback to App Router: without `experimental.nativeRscRuntime` it says the flag is required, and with it, that the native RSC runtime isn't implemented yet. The step that serves the page removes the second error. Route handlers and metadata routes can't set the export. Other bundlers would ignore the field and render the page on App Router, so the TypeScript segment config schema and the editor plugin accept it, and a page or layout that sets it fails the build without Turbopack. The e2e suite runs these builds the way the Go route handler suite runs its build errors. Its fixture sets the export on the root layout, so the page reaches the runtime by inheritance.
Author
Committer
Parents
Loading