Inspect route trace artifacts in .next/server for module inclusions
When debugging user bundle regressions where internal Node-only helpers are unexpectedly bundled, inspect route trace artifacts at .next/server/.../page.js.nft.json. Then inspect traced server chunks for forbidden internals like next/dist/server/stream-utils/node-stream-helpers.js and node:stream/promises.
Enable webpack.profile to emit detailed bundle statistics
In next.config.js, set config.profile = true within the webpack() config function to enable webpack profiling. Then use stats.toJson({ modules: true, chunks: true, reasons: true }) to emit detailed webpack stats. This gives concrete inclusion reasons showing which module required specific dependencies, more reliable than analyzer HTML alone.
NEXT_SKIP_ISOLATE environment variable skips packing next.js
Set NEXT_SKIP_ISOLATE=1 to skip packing next.js during debugging. For module-resolution validation, always rerun tests without this flag set.
next-code-frame features
next-code-frame supports caller-provided output width (no terminal detection via sans-io), syntax highlighting for JS, TS, JSX, TSX, graceful degradation for non-JS files or parsing errors, ANSI color support matching babel-code-frame aesthetics, and support for single-line and multi-line error ranges.
next-code-frame byte-level skip for long lines
When the visible window starts far into a long line (>200 bytes from line-level scan start), the heuristic additionally scans backwards from the visible start for a semicolon (;) and restarts the tokenizer there. This is critical for minified files where the entire source may be a single line.
next-code-frame byte-level skip limitation with semicolons in strings
The semicolon scan for long lines can land inside a string literal, causing an unbalanced quote that cascades incorrect highlighting across the visible window. In practice minified code has frequent semicolons between statements so this rarely triggers, and the consequence is only incorrect highlighting, never a failure.
next-code-frame Rust crate purpose
The next-code-frame crate provides fast, scalable code frame rendering for Next.js error reporting, written in Rust. It offers functionality similar to @babel/code-frame with improvements for scalability, long line handling, and syntax highlighting.
next-code-frame design principles
The next-code-frame crate follows the next-taskless pattern with no dependency on turbo-tasks, allowing use in webpack/rspack codepaths. It is compilable to WASM for environments without native bindings and follows sans-io patterns where the library accepts file content as arguments rather than performing IO.
code_frame CLI binary usage
The code_frame binary is included for testing. Usage: cargo run -p next-code-frame --bin code_frame -- [options] filename line:column [end_line:end_column]. Positions are 1-indexed line:column format. Options include -m for error message. Examples: highlight single position at 10:5, highlight range from 10:5 to 10:20, or add error message with -m "Unexpected token".
next-code-frame syntax highlighting tokenizer
The highlighter uses a single compiled regex pass over visible content to tokenize strings, comments, numbers, regex literals, and identifiers. Keywords are identified via a compile-time perfect hash set (phf). Syntax highlighting is supported for JS, TS, JSX, and TSX files.
next-code-frame skip-scan heuristic for large files
For large files, extract_highlights() walks backwards from the visible window looking for a blank line and starts the scan there. A blank line is a safe restart point for single-line constructs (strings, line comments, regex literals) because they cannot span blank lines. This avoids expensive scanning from byte 0.
next-code-frame skip-scan limitation with multi-line constructs
The skip-scan heuristic can produce incorrect highlighting when a multi-line construct (block comment or template literal) contains a blank line that falls between the scan start and the visible window. The scanner may miss the opening delimiter and the closing delimiter or trailing code may lose expected coloring. This is a deliberate tradeoff since blank lines inside block comments or template literals spanning the window boundary are rare in practice.
@next/swc-darwin-arm64 binary platform
@next/swc-darwin-arm64 is the aarch64-apple-darwin binary for @next/swc.
@next/swc-darwin-x64 package purpose
@next/swc-darwin-x64 is the x86_64-apple-darwin binary for @next/swc.