adapter

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 20 Imported by: 0 modules, 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

Overview

Package adapter compiles and bundles Next.js standalone builds for Cloudflare Workers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildWorkerBundle

func BuildWorkerBundle(
	ctx context.Context,
	standaloneDir string,
	meta *nextcore.NextCorePayload,
	cfg *config.NextDeployConfig,
	log *shared.Logger,
) (string, error)

BuildWorkerBundle adapts a Next.js standalone build into a single Cloudflare Worker module bundle.

Pipeline:

  1. Run nextcompile.Compile against the standalone tree + nextcore payload. This produces <standaloneDir>/.nextdeploy-cf/_nextdeploy/{manifest.json, dispatch.mjs, action_manifest.json, worker_entry.mjs}, extracts the embedded JS runtime, and (when RSC is used) vendors react-server-dom-webpack.
  2. Log the capability summary so operators see what the bundle supports before it deploys.
  3. Invoke the in-process esbuild Go API (`api.Context` / `Rebuild`) to bundle worker_entry.mjs + all compiled Next modules it transitively imports into a single ESM Worker bundle.
  4. Return the final bundle path.

Everything runs in-process in Go (no Node or npx subprocess required).

`meta` may be nil for the static-export path (DeployCompute skips early in that case), but every Worker-deploy call path supplies it.

Types

type CapabilityStatus added in v1.2.2

type CapabilityStatus string

CapabilityStatus distinguishes detected app usage from actual adapter support.

const (
	CapabilityUnused      CapabilityStatus = "unused"
	CapabilitySupported   CapabilityStatus = "supported"
	CapabilityConditional CapabilityStatus = "conditional"
	CapabilityUnsupported CapabilityStatus = "unsupported"
)

type CompatibilityReport added in v1.2.2

type CompatibilityReport struct {
	Engine                  string                 `json:"engine"`
	NextVersion             string                 `json:"next_version,omitempty"`
	ReactVersion            string                 `json:"react_version,omitempty"`
	MinCompatibilityDate    string                 `json:"min_compatibility_date"`
	ConfiguredCompatDate    string                 `json:"configured_compatibility_date,omitempty"`
	RequiredCompatFlags     []string               `json:"required_compatibility_flags"`
	BundleSHA256            string                 `json:"bundle_sha256"`
	BundleBytes             int64                  `json:"bundle_bytes"`
	BundleGzipBytes         int64                  `json:"bundle_gzip_bytes"`
	CompileDurationMS       int64                  `json:"compile_duration_ms"`
	EsbuildDurationMS       int64                  `json:"esbuild_duration_ms"`
	TotalDurationMS         int64                  `json:"total_duration_ms"`
	Features                []FeatureCapability    `json:"features"`
	NativeBuiltins          []string               `json:"native_builtins,omitempty"`
	PartialBuiltins         []string               `json:"partial_builtins,omitempty"`
	StubbedAppModules       []ModuleClassification `json:"stubbed_app_modules,omitempty"`
	StubbedFrameworkModules []ModuleClassification `json:"stubbed_framework_modules,omitempty"`
	TrimmedPackages         []ModuleClassification `json:"trimmed_packages,omitempty"`
	Warnings                []string               `json:"warnings,omitempty"`
}

CompatibilityReport is written to <outDir>/_nextdeploy/compat-report.json after bundling so CI, CLI diagnostics, and agents can inspect exact runtime requirements, stubbed dependencies, capability statuses, and bundle metrics.

type FeatureCapability added in v1.2.2

type FeatureCapability struct {
	Feature  string           `json:"feature"`
	Detected bool             `json:"detected"`
	Status   CapabilityStatus `json:"status"`
	Note     string           `json:"note,omitempty"`
}

FeatureCapability describes one Next.js capability for a given engine build.

type ModuleClassification added in v1.2.2

type ModuleClassification struct {
	Specifier         string   `json:"specifier"`
	Category          string   `json:"category"` // "native_builtin", "stubbed_builtin", "trimmed_package"
	FrameworkInternal bool     `json:"framework_internal"`
	Importers         []string `json:"importers,omitempty"`
}

ModuleClassification records how a Node built-in or trimmed package was handled during bundling so operators have full visibility into compatibility.

Jump to

Keyboard shortcuts

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