Documentation
¶
Index ¶
Constants ¶
const ( KindTypeError = "type_error" KindModuleNotFound = "module_not_found" KindSyntaxError = "syntax_error" KindClientOnlyInServer = "client_api_in_server_component" KindServerOnlyInClient = "server_api_in_client_component" KindDynamicServerUsage = "dynamic_server_usage" KindMissingSuspense = "missing_suspense_boundary" KindPrerenderError = "prerender_error" KindOutOfMemory = "out_of_memory" KindBuildError = "build_error" )
Diagnostic kinds.
const CaptureLimit = 512 * 1024
CaptureLimit is how much build output is kept for diagnosis.
Variables ¶
This section is empty.
Functions ¶
func IsTurbopackOutput ¶
IsTurbopackOutput reports whether the given Next.js standalone tree was produced by Turbopack rather than Webpack.
Detection signal: Turbopack emits chunks named `[turbopack]_*.js` and `[root-of-the-server]__*._.js` under `.next/server/chunks/ssr/`. Webpack-mode standalone output never produces these filenames.
standaloneDir is the path to the extracted standalone tree (the directory containing server.js + .next/). For a not-yet-extracted build, point at the project root and the function will look at `.next/server/chunks/`.
Returns false (no error) when the tree doesn't exist — callers that need to distinguish "not built" from "built with Webpack" should stat the path themselves.
Types ¶
type BuildError ¶ added in v1.3.0
type BuildError struct {
Err error
Diagnostics []Diagnostic
}
BuildError is returned when `next build` exits non-zero. It keeps the parsed diagnostics so callers up the stack (ship --json, MCP, the agent trace) can report them, while still wrapping the original exec error.
func NewBuildError ¶ added in v1.3.0
func NewBuildError(err error, output, projectDir string) *BuildError
NewBuildError wraps err with the diagnostics found in output.
func (*BuildError) Error ¶ added in v1.3.0
func (e *BuildError) Error() string
func (*BuildError) Unwrap ¶ added in v1.3.0
func (e *BuildError) Unwrap() error
type Diagnostic ¶ added in v1.3.0
type Diagnostic struct {
Kind string `json:"kind"`
File string `json:"file,omitempty"` // relative to the project
Line int `json:"line,omitempty"`
Column int `json:"column,omitempty"`
Route string `json:"route,omitempty"` // for prerender errors
Code string `json:"code,omitempty"` // e.g. TS2322
Message string `json:"message"`
Hint string `json:"hint,omitempty"`
DocsURL string `json:"docs_url,omitempty"`
}
Diagnostic is one build failure pulled out of `next build` output, in a shape an agent (or a person skimming CI) can act on without reading the log.
func Diagnose ¶ added in v1.3.0
func Diagnose(output, projectDir string) []Diagnostic
Diagnose extracts build failures from `next build` output (Next 14-16, Turbopack and webpack). It returns nil when it recognizes nothing.
func (Diagnostic) String ¶ added in v1.3.0
func (d Diagnostic) String() string
type TailBuffer ¶ added in v1.3.0
type TailBuffer struct {
// contains filtered or unexported fields
}
TailBuffer is an io.Writer that keeps only the last max bytes written. The interesting part of a failed build is at the end, and builds can be chatty.
func NewTailBuffer ¶ added in v1.3.0
func NewTailBuffer(max int) *TailBuffer
func (*TailBuffer) String ¶ added in v1.3.0
func (t *TailBuffer) String() string