Open-Source Wikis

/

Next.js

/

Crates

/

Other crates

vercel/next.js

Other crates

Smaller crates in crates/ that don't merit a full page on their own.

next-build

crates/next-build/src/ is the build orchestration crate. Two files only:

  • lib.rs — entrypoint
  • build_options.rs — typed build options

The crate is small because most build orchestration runs JS-side in packages/next/src/build/index.ts. next-build is the Rust counterpart used by the Turbopack build path: it takes the Project from next-api and walks every entrypoint to emit chunks and manifests.

Used by crates/next-build-test.

next-build-test

crates/next-build-test/src/ is a CLI-style test harness for the Rust build pipeline:

  • lib.rs — library entry (~11 KB)
  • main.rs — CLI binary (~7.5 KB)

Useful for running the Turbopack build outside of Node.js, for benchmarking, profiling (pnpm dev-trace-turbopack), and integration testing. Not shipped to users.

Compiled by pnpm dev-trace-turbopack to drive trace collection for development debugging.

next-code-frame

crates/next-code-frame/src/ is the source-mapped error frame formatter, used both at compile time and at runtime to produce nice multi-line errors.

File Size Role
frame.rs 19.5 KB Frame formatting (line/column with source snippets)
highlight.rs 59 KB Token-aware syntax highlighting for the snippet
tests.rs 26 KB Snapshot tests
bin/ Standalone test binary

The highlight module is large because it contains a hand-written tokenizer for JavaScript/TypeScript/JSX/TSX/MJS/CJS (color-coded for terminals).

Consumed by crates/next-napi-bindings/src/code_frame.rs.

next-error-code-swc-plugin

crates/next-error-code-swc-plugin/ is built separately from the workspace (it's in the exclude list in the root Cargo.toml) because SWC plugins are compiled to wasm.

build-and-move.sh builds the plugin to wasm-wasi and copies it into packages/next/src/error-code-swc-plugin/. The plugin rewrites internal errorOnce() / error() helper calls so each one carries an integer error code that maps to the framework's documented error registry.

The error registry lives at errors/index.json and is referenced by the nextjs.org/docs/messages site. The SWC plugin keeps the registry in sync with the source.

next-taskless

crates/next-taskless/src/:

  • lib.rs (8 KB)
  • mdx.rs (small)

A tiny crate hosting Next.js's local helpers for the Taskless integration (or similar — the README isn't pinned). Shows up as part of pnpm test:rust but is not user-facing.

wasm

crates/wasm/src/:

  • lib.rs (11.5 KB)
  • constants.rs, patterns.rs

The wasm-bindgen wrapper that exposes a subset of the SWC compiler as a wasm module. Built via pnpm swc-build-wasm (scripts/build-wasm.sh). Used as a fallback when no platform-specific .node binary is available (e.g., on platforms with no published @next/swc-{platform} package).

The wasm wrapper exposes the same transform, minify, and parse operations as the napi binding, but not the Turbopack Project API (Turbopack requires native threads which wasm doesn't have).

When to touch which crate

  • Adding a JS-callable Rust functionnext-napi-bindings (and possibly wasm).
  • Adding a build orchestration step → likely JS in packages/next/src/build/index.ts; in Rust only if it must run inside the Turbopack pipeline (next-build).
  • Changing how errors rendernext-code-frame.
  • Adding a new internal error codeerrors/index.json + the next-error-code-swc-plugin build script.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Other crates – Next.js wiki | Factory