next.js
ce87cf79 - [Experiment] Native RSC runtime layer; reject Go imports elsewhere

Commit
58 minutes ago
[Experiment] Native RSC runtime layer; reject Go imports elsewhere 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. Pages on the native RSC runtime now compile in a layer of their own, `app-native-rsc`, so that only these pages can import native code. The first native code will be Go: a page will import a Go package and call its exported functions. This and the next steps build that up. For now the layer compiles exactly like `app-rsc`. The new context type is listed next to `AppRSC` everywhere it's matched, so each place that diverges later does so explicitly. A module that both kinds of page import compiles once per layer. With `experimental.nativeRscRuntime` on, importing a `.go` file is a build error. From any other layer, the error says only pages on the native RSC runtime can import Go. From the runtime's layer, it says Go imports aren't implemented yet; the next step replaces that. With the flag off, apps that already handle `.go` files build as before. Server actions aren't collected from the new layer. That doesn't matter yet, because the runtime answers a POST with a 405 before the page renders. ### Test plan The build errors suite covers Go imports from a page on the runtime, an App Router page, a client component, a route handler, and a module that both kinds of page import. With the flag off, a page that references a `.go` file still builds.
Author
Committer
Parents
Loading