next.js
23cd1def - [Experiment] Scan and validate Go packages

Commit
59 minutes ago
[Experiment] Scan and validate Go packages 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. Importing a `.go` file from a page on the native RSC runtime now imports the file's whole package, and the build scans it. Every exported function becomes an export of the module, so one that can't be called with JSON arguments and results is a build error at its position, not silently skipped. Arguments and results can be booleans, numbers, strings, and slices, arrays, string-keyed maps, structs, and pointers built from those, including types the package declares. A function can return nothing, a value, an error, or a value and an error. A function whose first parameter is a `context.Context` is async. Types from other packages, interfaces, channels, funcs, and variadic and generic functions are rejected. The scanner is a small Go program that type-checks the package without reading its dependencies. Dot imports are rejected, because the scanner can't tell which package a dot-imported type comes from. It runs as a second host tool next to route.go's, in the same session pool. The package isn't compiled yet, so a clean package is still a build error, now listing its exports. ### Test plan The build errors suite covers a clean package, including files excluded by build constraints and async exports; each kind of unsupported export; and packages that can't be scanned at all. turbopack-go's live tests run the scanner on a fixture package.
Author
Committer
Parents
Loading