1. 10 Mar, 2026 16 commits
    • nextjs-bot's avatar
      v16.2.0-canary.91 · c44558be
      nextjs-bot authored
      c44558be
    • Luke Sandberg's avatar
      [turbopack] Encode task storage directly during persistence (skip clone) (#89412) · 9cee46cd
      Luke Sandberg authored
      # Don't clone TaskStorage objects when snapshotting the database
      
      ## What
      
      Instead of cloning `TaskStorage` objects when preparing to snapshot, we directly encode from a reference to the `TaskStorage` in the backend storage map.
      
      ## Why
      
      From a performance profile of `save_snapshot`, I observed that ~22% of the time was spent in `clone_meta_snapshot` or `clone_data_snapshot`, while ~28% of the time was spent in `encode_task_data`. The whole reason we are cloning is so we can drop the lock on the dashmap shard while encoding. In principle this makes sense, however:
      
      * We are only holding *read* locks on the dashmap, so we don't block other encoding threads
      * Holding the read locks for slightly longer will just slow down racing writing threads, but those are rare and already incur a high cost due to the extra cloning in `track_modification`. So slowing them down isn't too risky.
      
      ## Perf
      
      On a vercel-site cold build i don't actually see a real change in persistence time
      
      
      Before: 6.6s 7.8s 7.1s
      After: 6.9s 6.6s 7.2s
      
      So we are saving cpu time and allocations from this change but the overall task is bound on IO, so we should really only expect a win on more CPU constrained systems.
      9cee46cd
    • Luke Sandberg's avatar
      [turbopack] Add support for fixed key blocks (#90844) · f1f83236
      Luke Sandberg authored
      ## What?
      
      Adds fixed-size key block types to turbo-persistence SST files. When all entries in a key block share the same key size and value type, the 4-byte-per-entry offset table is eliminated entirely. Entry positions become a direct arithmetic calculation: `header_size + index * stride`.
      
      Also fixes a bug in `sst_inspect` where value blocks were misidentified as key blocks (value blocks have no type header, so their raw data could coincidentally match a key block type byte).
      
      ## Why?
      
      Many turbo-persistence tables have uniform key and value sizes. For example, TaskCache stores 4-byte task ID keys with 4-byte inline values — every single entry is identical in structure. The existing variable-size key block format stores a 4-byte offset table entry per entry (1B type + 3B position) to support variable-length entries. For uniform blocks, this offset table is pure overhead in both space and read-path indirection (binary search must chase offset table pointers at each step).
      
      ## How?
      
      **New block types 3 and 4** (parallel to existing types 1/2 for hash/no-hash):
      
      ```
      Variable: [1B type][3B count][4B offset × count][entries...]
      Fixed:    [1B type][3B count][1B key_size][1B value_type][entries...]
      ```
      
      The 2 extra header bytes (key_size + value_type) are amortized across all entries since we save 4 bytes per entry from removing the offset table. Break-even at 1 entry.
      
      **Writer changes:**
      - `KeyBlockFormat` enum with state machine (`Unknown → Fixed → Variable`) tracks uniformity as entries are added to the accumulator
      - `FixedKeyBlockBuilder` writes the compact 6-byte header + contiguous entries with no offset table
      - Falls back to variable-size automatically when entries aren't uniform
      - `ValueRef::write_value_to()` shared across both builder types to avoid duplication
      
      **Reader changes:**
      - `lookup_fixed_key_block()` — binary search using stride arithmetic (pure arithmetic, zero conditional branching per step)
      - `get_fixed_key_entry()` — direct index calculation instead of offset table indirection
      - Iterator refactored with `CurrentKeyBlockKind` enum (Variable vs Fixed variants)
      
      **sst_inspect fix:** Reads the index block first to determine which block indices are key blocks, rather than guessing from the first byte of block data.
      
      ### Real-world impact (vercel-site .next cache, ~9.5M entries per family)
      
      | Family | Fixed Blocks | Variable Blocks | Key Block Size | Notes |
      |--------|-------------|----------------|---------------|-------|
      | **TaskCache** | **16,274 (100%)** | 0 | **108.82 MB** (was 145 MB, **-25%**) | All inline 4B values |
      | TaskMeta | 10,078 (72%) | 3,877 (28%) | 118.86 MB (was ~145 MB) | Variable blocks contain rare medium values |
      | TaskData | 39 (0.3%) | 13,943 (99.7%) | 144.45 MB | Medium values spread across most blocks |
      | Infra | 0 | 1 | 25 B | Mixed inline sizes |
      
      This also saves 73M (2%) of the overall cache size
      
      ### Read-path benchmarks (`static_sorted_file_lookup`, 8B keys + 4B values)
      
      | Benchmark | Canary | Fixed Blocks | Change |
      |---|---|---|---|
      | **1Ki hit/cached** | 534 ns | 510 ns | **-4.5%** |
      | **10Ki hit/cached** | 559 ns | 556 ns | ~0% |
      | **100Ki hit/cached** | 566 ns | 503 ns | **-11.1%** |
      | **1Mi hit/cached** | 573 ns | 519 ns | **-9.4%** |
      | 1Ki miss/cached | 571 ns | 571 ns | ~0% |
      | 10Ki miss/cached | 613 ns | 556 ns | **-9.3%** |
      | 100Ki miss/cached | 639 ns | 593 ns | **-7.2%** |
      | 1Mi miss/cached | 791 ns | 702 ns | **-11.3%** |
      | 1Ki hit/uncached | 4.07 µs | 3.81 µs | **-6.4%** |
      | 10Ki hit/uncached | 5.33 µs | 5.03 µs | **-5.6%** |
      | 100Ki hit/uncached | 5.55 µs | 5.24 µs | **-5.6%** |
      | 1Mi hit/uncached | 8.47 µs | 8.31 µs | **-1.9%** |
      | 1Ki miss/uncached | 3.37 µs | 3.19 µs | **-5.3%** |
      | 10Ki miss/uncached | 3.87 µs | 3.41 µs | **-11.9%** |
      | 100Ki miss/uncached | 4.15 µs | 3.70 µs | **-10.8%** |
      | 1Mi miss/uncached | 6.98 µs | 6.66 µs | **-4.6%** |
      
      Consistent **5-11% improvement** on cached lookups (the hot path in production), where the binary search dominates and offset table elimination matters most. Uncached lookups also improve 2-12% due to smaller blocks and faster binary search.
      f1f83236
    • nextjs-bot's avatar
      v16.2.0-canary.90 · 36698c94
      nextjs-bot authored
      36698c94
    • JJ Kasper's avatar
      Revert "Address review feedback: extract modules, clean up imports" (#91159) · a2551c49
      JJ Kasper authored
      This is causing issues in unit tests so reverting to avoid regression
      there.
      
      Reverts vercel/next.js#90813
      a2551c49
    • Joseph's avatar
      docs: Streaming guide (#90779) · 69f53fd9
      Joseph authored
      - [x] update links to demo
      - [x] minor polishing identified by AI
      - [x] update links (dep: docs-unify-caching-story)
      - [x] check the implementation details vs actionable info balance
      - [x] how (and when) to block streaming?
      https://github.com/vercel/next.js/pull/90450
      - [x] INP and the hydrate me later trick link to demo
      
      ---------
      Co-authored-by: 's avatarDelba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
      69f53fd9
    • Joseph's avatar
    • Dmitrii's avatar
      fix(css): rewrite MiniCssExtractPlugin insert function to ES5 to support legacy browsers (#90556) · ae9c9d6c
      Dmitrii authored
      ## What?
      
      Rewrite the `insert` function passed to `MiniCssExtractPlugin` in
      `packages/next/src/build/webpack/config/blocks/css/index.ts` to use only
      ES5-compatible syntax.
      
      ## Why?
      
      The `insert` option of `mini-css-extract-plugin` serialises the function
      via `Function#toString()` and injects the resulting string directly into
      the webpack runtime chunk. This string **bypasses all subsequent
      transpilation** — it is not processed by Babel/SWC, and is not subject
      to the project's `browserslist` or `output.environment` webpack config.
      
      The current function contains:
      
      ```js
      const { href, onload, onerror } = linkTag   // ES2015 destructuring
      onload?.call(linkTag, ...)                  // ES2020 optional chaining
      ```
      
      When the project targets legacy browsers (e.g. `chrome >= 45`) pages
      crash on load with:
      
      > **Unexpected token {**
      
      before any CSS has been applied.
      
      ## How?
      
      Replace the destructuring with individual `var` declarations and replace
      optional chaining with explicit `if` null-checks:
      
      **Before:**
      ```js
      const { href, onload, onerror } = linkTag
      // ...
      () => onload?.call(linkTag, { type: 'load' } as Event),
      () => onerror?.call(linkTag, {} as Event)
      ```
      
      **After:**
      ```js
      var href = linkTag.href
      var onload = linkTag.onload
      var onerror = linkTag.onerror
      // ...
      function () { if (onload) onload.call(linkTag, { type: 'load' } as Event) },
      function () { if (onerror) onerror.call(linkTag, {} as Event) }
      ```
      
      Runtime behavior is identical in all environments. The `var` style was
      intentionally chosen (over splitting `const` declarations) since
      `no-var` is disabled in the project ESLint config.
      
      Fixes #90518
      Co-authored-by: 's avatarsleitor <sleitor@users.noreply.github.com>
      Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
      ae9c9d6c
    • JJ Kasper's avatar
      Exclude partial fallback for deploy mode (#91163) · e3417906
      JJ Kasper authored
      This feature isn't rolled out so needs to be disabled.
      e3417906
    • Benjamin Woodruff's avatar
      fix: Use a pnpm preinstall script to fix catch-22 in next binary creation (#91016) · 1eab3361
      Benjamin Woodruff authored
      We've had a longstanding issue where you'd have to run `pnpm i` _twice_ on a fresh checkout because `pnpm` wouldn't set up binary symlinks until after the binary exists, but the binary wouldn't exist until after `pnpm build` was done:
      
      https://github.com/vercel/next.js/blob/canary/.github/workflows/build_reusable.yml#L303-L311
      
      This solves that problem using a pnpm preinstall script that creates stub binaries for these files if they don't exist yet (because we haven't run `pnpm build`).
      
      ## Test Plan
      
      ```
      git clean -fxd
      pnpm i
      pnpm build
      pnpm test-start test/e2e/app-dir/next-image/
      pnpm test-start-turbo test/e2e/app-dir/next-image/
      ```
      
      I tested this both locally and inside of a fresh ubuntu VM.
      
      Running `pnpm next` after `pnpm i` but before `pnpm build` gives a helpful error message:
      
      <img width="946" height="125" alt="Screenshot 2026-03-06 at 9 37 14 PM" src="https://github.com/user-attachments/assets/4517e8bd-60ca-44f2-a34c-f7f3ec56c634" />
      1eab3361
    • nextjs-bot's avatar
      v16.2.0-canary.89 · 110ed228
      nextjs-bot authored
      110ed228
    • Will Binns-Smith's avatar
      Trace upload: add git and environment info (#91124) · 51797dbd
      Will Binns-Smith authored
      This adds the following to uploaded trace data:
      
      - Git branch/ref name
      - Whether the trace was uploaded from a Vercel environment
      - Prefers Vercel git environment variable data over running git
      
      Test Plan: Ran a manual test app with EXPERIMENTAL_FLAGS_DEBUG=1, set
      the corresponding environment variables and confirmed they were
      reflected
      51797dbd
    • Steven's avatar
      chore(docs): mention behavior of redirects and remotePatterns (#91151) · bfb8cc7a
      Steven authored
      Some users have been confused by the relationship of
      `images.remotePatterns` and `images.maximumRedirects` so lets document
      it.
      
      This behavior is expected since you might allowlist something like
      `https://github.com/styfle.png` and that can redirect to whatever it
      needs to redirect to (assuming maximumRedirects > 0). For example, it
      currently redirects to
      `https://avatars.githubusercontent.com/u/229881?v=4` but you can imagine
      in the future if the redirect was changed, you wouldn't want your app to
      break.
      
      Regardless of redirects, the final response must be an image.
      
      ---------
      Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
      bfb8cc7a
    • Sam Selikoff's avatar
      Updates to Instant Navs devtools functionality (#91005) · 19a19a39
      Sam Selikoff authored
      Updates the Instant Navs devtools functionality to use a panel and show
      you two options for capturing the SSR shell or the prefetch for a Client
      navigation.
      
      Replaces current functionality where clicking Instant Navs changed the
      devtools indicator to a blue pending state awaiting the user's next
      navigation.
      
      
      https://github.com/user-attachments/assets/de5c5a40-e836-4719-9517-6d5c6b0aef2c
      19a19a39
    • nextjs-bot's avatar
      v16.2.0-canary.88 · 4271c8b8
      nextjs-bot authored
      4271c8b8
    • Niklas Mischkulnig's avatar
      Turbopack: introduce `ReferenceTypeCondition` (#91101) · c4457849
      Niklas Mischkulnig authored
      Previously, we used `RuleCondition::ReferenceType(ReferenceType)`. But there are some problem with using the type itself as a matcher:
      
      1. the sub types' Undefined variant (like `CssReferenceSubType::Undefined`) always matched all possible variants. So it was actually impossible to match exactly `CssReferenceSubType::Undefined`
      2. variants with more complex types were also impossible to match against, like `ReferenceType::Inner(ResolvedVc<...>)`
      c4457849
  2. 09 Mar, 2026 19 commits
    • nextjs-bot's avatar
      v16.2.0-canary.87 · 92b854dd
      nextjs-bot authored
      92b854dd
    • Benjamin Woodruff's avatar
      docs(turbopack): Copy over turbopack-trace-server docs (#91111) · ae6406af
      Benjamin Woodruff authored
      **Rendered:** https://github.com/vercel/next.js/blob/dd1cc6fba3cff5fbc38dac3ff4426b481bfcbcb5/contributing/turbopack/tracing.md
      
      This is the content from https://turbopack-rust-docs.vercel.sh/tracing_turbopack.html with some minor updates:
      
      - Use GitHub Flavored Markdown for the warning block
      - Some grammar fixes/tweaks
      - Add an extra note about `--release` being important
      - Add a mention of `pnpm next internal trace`
      - Add a link to @timneutkens's youtube video
      - Change the filepath from the old confusingly named `.next/trace.log` to `.next/trace-turbopack`
      - Add a link to https://trace.nextjs.org/
      ae6406af
    • nextjs-bot's avatar
      v16.2.0-canary.86 · 2ecfbfc1
      nextjs-bot authored
      2ecfbfc1
    • Zack Tanner's avatar
      fix: app-page URL normalization (#91121) · 4e2353ed
      Zack Tanner authored
      ## Summary
      
      Fix an App Router request normalization gap where app-page route-module
      requests could keep internal RSC/segment-prefetch URLs in `req.url`.
      
      This could leak paths like:
      
      - `.../.segments/_tree.segment.rsc`
      - `.../__PAGE__.segment.rsc`
      
      into App Router render state and surface through `usePathname()` during
      server rendering.
      
      ## What changed
      
      - Normalize `req.url` in the app-page route-module path after `.rsc` and
      `.segments/*.segment.rsc` pathname normalization.
      
      ## Why
      
      `base-server` already keeps `req.url` in sync after RSC normalization
      ([ref](https://github.com/vercel/next.js/blob/5e11e67759fa38fe67f70790d7bba8c9ff9ba5fd/packages/next/src/server/base-server.ts#L676-L680)),
      but the app-page route-module path only updated `parsedUrl.pathname`.
      
      Since App Router render state seeds its canonical URL from `req.url`,
      that desync could cause internal segment-prefetch paths to be treated as
      the current pathname.
      4e2353ed
    • Zack Tanner's avatar
      partial fallbacks: gate behind experimental flag (#91123) · c0bf4b6f
      Zack Tanner authored
      This puts the partial fallback upgrading feature introduced in
      https://github.com/vercel/next.js/pull/89063 behind a flag to make it
      easier to test the rollout/eventual stabilization in isolation.
      c0bf4b6f
    • Will Binns-Smith's avatar
      Turbopack: Pass hmr_enabled to ImportMetaBinding (#91118) · 5e11e677
      Will Binns-Smith authored
      `is_hot_module_replacement_enabled` was removed from ChunkingContexts.
      Instead, pass it through from CompileTimeInfo when constructing
      ImportMetaBinding during analysis.
      
      Test Plan: CI
      5e11e677
    • Benjamin Woodruff's avatar
      docs(contributing): Update setup in contributing/core/developing.md (#91018) · 15d9b717
      Benjamin Woodruff authored
      A lot of stuff here was slightly out-of-date or not as helpful as it could be.
      
      For the Linux bits, I tested with a fresh Ubuntu image in LXD.
      15d9b717
    • Tobias Koppers's avatar
      Turbopack: implement module.hot.accept(deps, cb) and module.hot.decline(deps) (#90443) · 014b9987
      Tobias Koppers authored
      ### What?
      
      Implements dependency-level HMR accept and decline for Turbopack,
      covering both ESM (`import.meta.turbopackHot`) and CJS (`module.hot`)
      modules.
      
      Previously Turbopack only supported self-accept (`module.hot.accept()`
      with no arguments) and self-decline. This PR adds the full
      dependency-targeted API:
      
      - `module.hot.accept(dep, cb)` / `import.meta.turbopackHot.accept(dep,
      cb)` — single dep
      - `module.hot.accept([depA, depB], cb)` /
      `import.meta.turbopackHot.accept([depA, depB], cb)` — array of deps
      - `module.hot.decline(dep)` / `import.meta.turbopackHot.decline(dep)` —
      single dep
      - `module.hot.decline([depA, depB])` /
      `import.meta.turbopackHot.decline([depA, depB])` — array of deps
      
      ### Why?
      
      Libraries like `react-refresh` and user code often need to accept
      updates for specific dependencies rather than self-accepting the entire
      module. Without this, those HMR patterns fall back to full page reloads
      in Turbopack.
      
      ### How?
      
      **Runtime** (`turbopack-ecmascript-runtime`):
      - Extended `HotState` with `acceptedDependencies`,
      `acceptedErrorHandlers`, and `declinedDependencies` maps (keyed by
      `ModuleId`)
      - Updated `hot.accept()` and `hot.decline()` to handle string and array
      signatures
      - Updated `getAffectedModuleEffects` to check accepted/declined
      dependencies when propagating updates through the module graph
      - Added `'declined'` effect type that throws an `UpdateApplyError`
      - Track `outdatedDependencies` (map of parent → set of updated deps)
      alongside `outdatedModules`
      - In the apply phase, invoke per-dependency accept callbacks with the
      correct outdated deps
      - Use `Set` for `outdatedDependencies` dedup (O(1) vs O(n) lookups)
      
      **Compiler** (`turbopack-ecmascript`):
      - Added `ModuleHotReferenceAssetReference` — a single asset reference
      type for both accept and decline deps, with shared resolve logic for ESM
      (`esm_resolve`) and CJS (`cjs_resolve`)
      - Added `ModuleHotReferenceCodeGen` — generates code that replaces dep
      string literals with resolved module IDs at compile time
      - ESM binding auto-update: when an ESM module accepts a dependency that
      it also `import`s, the compiler wraps the accept callback to re-import
      the namespace variable (`__TURBOPACK__imported__module__<id> =
      __turbopack_import__(<id>)`) before the user callback runs, so ESM
      bindings reflect updated values without needing `require()`
      - Added `import.meta.turbopackHot` as the ESM equivalent of
      `module.hot`, with TypeScript type declarations in
      `packages/next/types/global.d.ts`
      - Static analysis extracts dep strings from
      `module.hot.accept`/`decline` calls; non-analyzable deps emit a warning
      with distinct error codes (`TP1204` for accept, `TP1205` for decline)
      
      **HMR gating** (`CompileTimeInfo`):
      - Added `hot_module_replacement_enabled` flag to `CompileTimeInfo` to
      gate recognition of `module.hot` and `import.meta.turbopackHot` as
      well-known objects
      - Without this flag, production builds would recognize
      `module.hot.accept(...)` and generate HMR-specific code, leading to
      runtime errors
      - Flag set to `true` for dev servers and `false` for production builds
      across Next.js and turbopack-cli entry points
      - `import.meta.turbopackHot` getter is only emitted when HMR is enabled
      
      **Server HMR** (`next-api`, `next-core`):
      - Server-side `compile_time_info` now also sets
      `hot_module_replacement_enabled` so that `module.hot` /
      `import.meta.turbopackHot` are recognized during analysis of server
      modules
      - Server HMR requires the `--experimental-server-fast-refresh` CLI flag;
      the flag is passed through `ProjectOptions` to the Rust side so
      `server_compile_time_info` only enables HMR when appropriate
      
      **Tests** (`test/development/app-dir/hmr-dep-accept/`):
      - ESM single dep accept — verifies parent module is not re-evaluated,
      accept callback fires, ESM bindings auto-update
      - ESM array dep accept — same as above with `accept(['./dep-a',
      './dep-b'], cb)`
      - CJS `module.hot.accept` — pure CJS dep observer pattern with `.cjs`
      files
      - Single dep decline — verifies full page reload occurs
      - Array dep decline — verifies full page reload with
      `decline(['./dep-a', './dep-b'])`
      014b9987
    • Tobias Koppers's avatar
      Improve unsafe code safety documentation in turbo-tasks-backend (#90755) · 6a733742
      Tobias Koppers authored
      ### What?
      
      Improves safety documentation for all `unsafe` code in the
      `turbo-tasks-backend` crate (6 files, comment-only changes).
      
      ### Why?
      
      A comprehensive audit of all 14 files containing `unsafe` code in
      `turbo-tasks-backend` found **no soundness bugs**, but identified
      several safety comments that were incorrect, misleading, or missing
      entirely. Correct safety documentation is critical for maintaining
      unsafe code over time — reviewers and future contributors rely on these
      comments to understand invariants.
      
      ### How?
      
      **Fixes applied (comment-only, no behavior changes):**
      
      1. **`backend/operation/mod.rs`** — Fixed transmute safety comment that
      referenced wrong lifetime names (`'a`/`'l` → `'e`/`'tx`)
      2. **`database/read_transaction_cache.rs`** — Fixed reference to wrong
      struct name (`LmdbBackingStorage` → `ReadTransactionCache`); added
      struct-level doc explaining the field-ordering invariant required for
      drop safety
      3. **`database/startup_cache.rs`** — Added struct-level doc explaining
      the self-referential pattern and field-ordering invariant; improved
      inline safety comment
      4. **`utils/dash_map_multi.rs`** — Added safety justification for
      `unsafe impl Send/Sync` on `RefMut` explaining bucket pointer
      exclusivity
      5. **`backing_storage.rs`** — Added `// Safety:` comments to 6 `unsafe`
      blocks in the `Either` impl that were missing them
      6. **`kv_backing_storage.rs`** — Made the `flush()` safety comment more
      specific about what "finished processing" means
      
      **Audit summary (14 files reviewed):**
      
      | Risk | Category | Files | Verdict |
      |------|----------|-------|---------|
      | HIGH | Lifetime transmutation | 3 | Sound ✓ — comments fixed |
      | MEDIUM | DashMap raw bucket access | 3 | Sound ✓ — Send/Sync docs
      added |
      | LOW | Unsafe trait method contracts | 8 | Sound ✓ — missing comments
      added |
      | NEGLIGIBLE | Test code | 1 | No issues |
      6a733742
    • Tobias Koppers's avatar
      Fix preview tarball script to include @next/swc-linux-x64-gnu (#91099) · 9c939729
      Tobias Koppers authored
      ### What?
      
      Adds `@next/swc-linux-x64-gnu` to the preview tarball patching script
      (`scripts/patch-preview-tarball.mjs`):
      
      1. Adds the package to the `PACKAGES_TO_PATCH` list so its tarball URL
      is fetched.
      2. Adds the package as an explicit dependency in the patched
      `package.json`, in addition to the overrides/resolutions.
      
      ### Why?
      
      The `@next/swc-linux-x64-gnu` native binary package is an optional
      dependency of `next` and may not be installed automatically depending on
      the platform/package manager. When testing preview tarballs (e.g., in CI
      or on Linux environments), the SWC binary needs to be explicitly present
      for Next.js to function correctly. Without this change, preview tarball
      testing on Linux x64 could fail because the native binary isn't resolved
      from the preview build.
      
      Adding it as a direct dependency (not just an override/resolution)
      ensures the package manager actually installs it, since optional
      dependencies from overridden tarballs may not be auto-resolved.
      
      ### How?
      
      - Added `'@next/swc-linux-x64-gnu'` to the `PACKAGES_TO_PATCH` array so
      the script fetches its tarball URL.
      - After writing overrides/resolutions, the script now also adds
      `@next/swc-linux-x64-gnu` as an explicit entry in `pkg.dependencies`
      pointing to the tarball URL.
      Co-authored-by: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
      9c939729
    • Kowyo's avatar
      example: remove duplicate items in .dockerignore (#91079) · 5a226232
      Kowyo authored
      Removed duplicate entries for cache and temporary directories.
      
      ```diff
      - # Cache directories and temporary data
      - .cache/
      - .parcel-cache/
      - .eslintcache
      - .stylelintcache
      - .turbo/
      - .tmp/
      # Cache directories and temporary data
      .cache/
      .parcel-cache/
      .eslintcache
      .stylelintcache
      .swc/
      .turbo/
      .tmp/
      .temp/
      ```
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      5a226232
    • Ethan (Taehoon) Lee's avatar
      docs(localFont): enhance details about using the localFont function (#88189) · 5e4a54ea
      Ethan (Taehoon) Lee authored
      ### What?
      Enhance the documentation about how to use the `localFont` function.
      
      ### Why?
      The Next.js documentation about [local
      fonts](https://nextjs.org/docs/app/getting-started/fonts#local-fonts)
      has insufficient information about where to store the font files and how
      to reference them with the `localFont` function. The lack of detail
      causes confusion like this issue:
      https://github.com/vercel/next.js/issues/76573.
      
      ### How?
      I created a [demo](https://nextjs-localfont-demo.vercel.app/) to
      investigate the behavior of the `localFont` function (source:
      https://github.com/ethn1ee/nextjs-localfont-demo). I confirmed that the
      font files can be located anywhere inside the project, including at
      root, the `src` directory, the `app` directory, and the `public`
      directory, and that they must all be referenced using relative paths.
      
      Fixes #76573
      
      ---------
      Co-authored-by: 's avatarEthan Lee <48551278+ethn1ee@users.noreply.github.com>
      Co-authored-by: 's avatarJoseph <sephxd1234@gmail.com>
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      5e4a54ea
    • Joseph's avatar
      fix: run lerna on a branch (#91092) · 762bff65
      Joseph authored
      Trying to fix: `lerna ERR! ENOGIT Detached git HEAD, please checkout a
      branch to choose versions.` on `set-preview-version.js`
      
      [Slack
      thread](https://vercel.slack.com/archives/C02CDC2ALJH/p1773051154649349)
      762bff65
    • Niklas Mischkulnig's avatar
      Turbopack: don't panic due to eventual consistency in module merging (#91088) · 1ead596c
      Niklas Mischkulnig authored
      Turn into bail to handle eventual consistency more gracefully
      1ead596c
    • Tobias Koppers's avatar
      Fix pr-status script missing failed jobs on page 2+ of API results (#91087) · 3ba53df7
      Tobias Koppers authored
      ## Summary
      
      `getFailedJobs()` in `scripts/pr-status.js` used jq's `select(.conclusion == "failure")` filter during GitHub API pagination. When a page had 100 jobs but none were failures, jq returned empty output, and the `if (!output.trim()) break` check terminated the pagination loop early — never fetching page 2+ where actual failures existed.
      
      For example, on PR #90755 (129 total jobs), all 100 jobs on page 1 were success/skipped, while the 2 failures (`test unit windows (22) / build` and `thank you, next`) were on page 2 (jobs 101-129). The script reported "Found 0 failed jobs" when there were actually 2.
      
      ## Fix
      
      `getFailedJobs()` now delegates to `getAllJobs()` (which fetches all jobs without jq filtering, so pagination works correctly) and filters for failures in JavaScript afterward. This is simpler and avoids the class of bug where jq pre-filtering interacts badly with pagination.
      
      ## Test Plan
      
      - Ran `node scripts/pr-status.js 90755` before fix: reported 0 failed jobs
      - Ran `node scripts/pr-status.js 90755` after fix: correctly reported 2 failed jobs (`test unit windows (22) / build` and `thank you, next`)
      3ba53df7
    • Tobias Koppers's avatar
      Add script to patch project with preview tarball URLs (#91057) · 5e965bbb
      Tobias Koppers authored
      ### What?
      
      Adds a new script `scripts/patch-preview-tarball.mjs` that patches a
      target project's `package.json` to use Next.js preview tarballs from
      `vercel-packages.vercel.app`.
      
      ### Why?
      
      When testing unreleased Next.js changes against external projects (e.g.,
      reproducing bugs, verifying fixes), there's no convenient way to point a
      project at a specific Next.js commit's build artifacts. This script
      automates the process of wiring up preview tarball URLs into a project's
      dependency overrides.
      
      ### How?
      
      The script:
      
      1. **Resolves a commit SHA** via one of three methods:
         - `--commit <sha>` — use an explicit commit
      - `--branch <name>` — look up the branch tip via the GitHub API (`gh`)
         - *(default)* — use the local `git rev-parse HEAD`
      
      2. **Builds tarball URLs** for `next`, `@next/mdx`, `@next/env`, and
      `@next/bundle-analyzer` using the
      `vercel-packages.vercel.app/next/commits/<sha>/<pkg>` pattern.
      
      3. **Verifies** that the preview tarball exists (HEAD request to the
      `next` tarball URL).
      
      4. **Patches `package.json`** in the target project (or its workspace
      root) by setting both `overrides` (npm/pnpm) and `resolutions` (yarn)
      for the packages.
      
      **Usage:**
      
      ```bash
      node scripts/patch-preview-tarball.mjs --project <path> [--commit <sha> | --branch <name>]
      ```
      5e965bbb
    • Niklas Mischkulnig's avatar
      Turbopack: correctly use ChunkGroup::Shared (#90978) · fda324e2
      Niklas Mischkulnig authored
      I don't think we have any tests that the server utility chunking actually works.
      But I can't actually properly remember why we added it in the first place: https://github.com/vercel/next.js/pull/70461
      fda324e2
    • Tobias Koppers's avatar
      Improve webpack loader error messages and handling (#89698) · 60f903c7
      Tobias Koppers authored
      ## What?
      
      This PR improves error reporting for webpack loaders by:
      
      1. **Preserving loader paths in error messages**: Modified the webpack
      message formatter to rewrite "Module build failed" headers to preserve
      the loader path information while removing the verbose prefix. This
      makes errors more readable in both CLI output and error overlays.
      
      2. **Better error wrapping for non-Error throws**: When loaders throw
      non-Error values (strings, objects, etc.), the error is now wrapped with
      loader path information in the stack trace, making it easier to identify
      which loader caused the error.
      
      3. **Catching deferred loader errors**: Added handling for errors that
      occur after loader completion (e.g., unhandled Promise rejections,
      setTimeout throws) by:
         - Adding an `unhandledRejection` handler in the IPC layer
      - Delaying resolution in webpack-loaders transform to allow error
      handlers to fire before sending the 'end' message
      
      4. **Conditional `(from ...)` annotation**: The `(from
      /path/to/loader.js)` annotation is only added when the loader path is
      **not already visible** in the error's stack trace. This avoids
      redundant noise for errors that already include the loader in their
      stack, while still providing the annotation for errors without loader
      context (string throws, errors without stacks, etc.).
      
      5. **Hiding internal Next.js loader paths**: Internal Next.js loader
      paths (under `next/dist/`) are filtered from error messages since
      they're noise for users. Only user-authored loader paths are shown.
      
      6. **Comprehensive test coverage**: Added e2e tests covering various
      error scenarios (Error throws, string throws, Promise rejections,
      setTimeout errors, no-stack errors, filesystem errors) with verification
      of both CLI output and error overlay display.
      
      ## Why?
      
      Webpack loader errors were previously difficult to debug because:
      - The verbose "Module build failed" prefix obscured the actual error
      message
      - Non-Error throws lost their context and loader information
      - Deferred errors (Promise rejections, async throws) were not properly
      surfaced
      - Error overlays didn't clearly show which loader caused the problem
      - The `(from ...)` annotation was always added, even when the loader
      path was already in the stack trace (addressed per review feedback)
      
      ## How?
      
      - **format-webpack-messages.ts**: Changed from filtering out loader
      headers to rewriting them, preserving the `(from ./loaders/...)`
      information. Internal Next.js loader paths are hidden.
      - **webpack-loaders.ts**: Added error wrapping for non-Error values,
      deferred resolution to catch async errors, and conditional `(from ...)`
      annotation that checks `err.stack` before appending. Resolves loader
      paths into an array, then checks if any path appears in the stack before
      deciding to annotate.
      - **ipc/index.ts**: Added `unhandledRejection` handler to surface
      Promise-related errors.
      - **Test loaders**: `error-loader.js` and `fs-error-loader.js` delegate
      to a `create-error.js` helper that creates errors and invokes the loader
      callback inside `setTimeout`. This ensures the loader file path is
      absent from the stack trace, exercising the conditional `(from ...)`
      annotation path. Other loaders (string-error, promise-error,
      timeout-error, no-stack-error) test different error scenarios directly.
      - **Test suite**: Comprehensive e2e tests verify CLI output and error
      overlay for each error type. Turbopack-specific tests cover promise
      rejections, timeout errors, no-stack errors, and filesystem errors.
      
      ---------
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      60f903c7
    • Tobias Koppers's avatar
      Turbopack: show specific SWC error messages as error titles (#91022) · 1287f9a0
      Tobias Koppers authored
      ### What?
      
      Changes Turbopack's error overlay to show specific SWC diagnostic
      messages as the error title instead of generic messages like "Parsing
      ecmascript source code failed" or "Ecmascript file had an error".
      
      ### Why?
      
      Previously, all SWC parse/analysis errors in Turbopack showed a generic
      title (e.g. "Parsing ecmascript source code failed") in the redbox
      header, with the actual specific error message buried in the description
      below the code frame. This made it harder for developers to quickly
      understand what went wrong.
      
      **Before:**
      ```
      Parsing ecmascript source code failed
      > 1 | export default () => <div/
          |                           ^
      Expected '>', got '<eof>'
      ```
      
      **After:**
      ```
      Expected '>', got '<eof>'
      > 1 | export default () => <div/
          |                           ^
      Parsing ecmascript source code failed
      ```
      
      ### How?
      
      **Core change** in
      `turbopack/crates/turbopack-swc-utils/src/emitter.rs`:
      
      When the `IssueEmitter` has a `self.title` set (the generic title like
      "Parsing ecmascript source code failed"), the SWC diagnostic message is
      now used as the issue title, and the generic title is demoted to the
      description. When `self.title` is not set, the existing behavior is
      preserved (first line of message becomes title, rest becomes
      description).
      
      **Test updates** across ~15 test files:
      
      Updated all `isTurbopack` branches in test expectations to reflect the
      swapped title/description. Only Turbopack-specific branches were
      modified; webpack and rspack expectations are unchanged.
      
      **New test suite** (`test/development/app-dir/ecmascript-error-title/`):
      
      Dedicated tests verifying that both syntax errors (e.g. `Expected '>',
      got '<eof>'`) and analysis errors (e.g. `the name 'Table' is defined
      multiple times`) show the specific SWC message as the redbox title.
      
      **Turbopack snapshot updates:**
      
      4 snapshot files renamed to reflect new titles (e.g. `Parsing ecmascript
      source code failed-*.txt` → `Expression expected-*.txt`).
      
      ---------
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      1287f9a0
  3. 07 Mar, 2026 4 commits
  4. 06 Mar, 2026 1 commit