nextbuild

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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.

View Source
const CaptureLimit = 512 * 1024

CaptureLimit is how much build output is kept for diagnosis.

Variables

This section is empty.

Functions

func IsTurbopackOutput

func IsTurbopackOutput(standaloneDir string) bool

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.

func Run

func Run(ctx context.Context, opts Opts) error

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 Opts

type Opts struct {
	ProjectDir string

	Target Target

	Log *shared.Logger

	ExtraArgs []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

func (*TailBuffer) Write added in v1.3.0

func (t *TailBuffer) Write(p []byte) (int, error)

type Target

type Target string
const (
	TargetCloudflareWorker Target = "cloudflare-worker"
	TargetAWSLambda        Target = "aws-lambda"
	TargetVPS              Target = "vps"
	TargetGeneric          Target = "generic"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL