1. 13 Apr, 2026 18 commits
    • nextjs-bot's avatar
      v16.2.1-canary.36 · bd5320f6
      nextjs-bot authored
      bd5320f6
    • Andrew Clark's avatar
      Fix prefetch hints not being loaded during revalidation (#92625) · d803902d
      Andrew Clark authored
      The prefetch hints manifest was not loaded during revalidation renders,
      causing all segments to fall back to PrefetchDisabled — effectively
      disabling prefetching for that route until the next full build.
      
      The app-page template handler constructs its own renderOpts from scratch
      without including prefetch-hints.json. Normal requests go through the
      server's renderOpts (which loads the manifest at startup), but
      background revalidation renders go through the template handler, so the
      hints were always empty.
      
      Load the manifest in the route module's loadManifests() and pass it
      through to renderOpts.
      
      Closes #92255
      
      ---------
      Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
      d803902d
    • nextjs-bot's avatar
      v16.2.1-canary.35 · 46181bc0
      nextjs-bot authored
      46181bc0
    • Tim Neutkens's avatar
      Revert "refactor: write pages router export files directly to server/pages/" (#92733) · 96338c31
      Tim Neutkens authored
      Reverts vercel/next.js#90018
      96338c31
    • nextjs-bot's avatar
    • Andrew Imm's avatar
      Compiler: Support boolean and number primtives in next.config defines (#92731) · efc0905d
      Andrew Imm authored
      Expand `config.compiler.define` to support number and boolean primitives
      as well.
      
      The support is already in Turbopack's rewrite engine, as well as
      Webpack's DefinePlugin. We just need to modify the zod schema to
      actually support passing numbers and bools.
      
      Added an E2E test that should check all supported types.
      efc0905d
    • zoomdong's avatar
    • Evan Yu's avatar
      chore: Bump reqwest to 0.13.2 (#92713) · efb699ac
      Evan Yu authored
      Fixes #91653
      
      Running `next dev` with the latest Turbopack fails to fetch fonts on
      Windows ARM machines, resulting in an `http2 feature is not enabled`
      error. This issue was fixed in `reqwest` v0.13.2:
      https://github.com/seanmonstar/reqwest/pull/2927
      efb699ac
    • Tobias Koppers's avatar
      turbo-tasks: Fix recomputation loop by allowing cell cleanup on error during recomputation (#92725) · fa60f505
      Tobias Koppers authored
      ### What?
      
      Fix an infinite recomputation loop in turbo-tasks by allowing cell
      cleanup to proceed during recomputation even when the task result is an
      error.
      
      ### Why?
      
      When a task errors during normal execution, cell cleanup is
      intentionally skipped. The rationale is that errors during normal
      execution are often transient eventual-consistency issues caused by
      reading stale inputs — keeping old cell data prevents "cell no longer
      exists" errors for dependent tasks that are reading those cells.
      
      However, during **recomputation** (a task re-executing without being
      marked dirty), nothing about its inputs has changed. Any error it
      produces is therefore not transient. If cell cleanup is skipped in this
      case, stale cells remain in place, which trigger further recomputations,
      which produce further errors, which skip further cleanups — creating an
      infinite loop.
      
      ### How?
      
      - Detect whether a task execution is a recomputation by checking
      `task.is_dirty().is_none()` at completion time (a recomputing task was
      not dirty when it started executing).
      - Propagate `is_recomputation` through
      `TaskExecutionCompletePrepareResult` to both
      `task_execution_completed_prepare` and
      `task_execution_completed_cleanup`.
      - In both places where cell cleanup is gated on `result.is_ok()` /
      `!is_error`, extend the condition to also allow cleanup when
      `is_recomputation` is true.
      
      This ensures that stale cells produced by a erroring recomputation are
      cleaned up, breaking the infinite loop.
      
      <!-- NEXT_JS_LLM_PR -->
      Co-authored-by: 's avatarClaude Opus 4.6 (1M context) <noreply@anthropic.com>
      fa60f505
    • Tobias Koppers's avatar
      Turbopack: Add import.meta.glob support (Vite compat) (#92640) · 38fdf0c0
      Tobias Koppers authored
      ## What?
      
      Adds support for [Vite's
      `import.meta.glob`](https://vite.dev/guide/features.html#glob-import) in
      Turbopack. This is a compile-time transform that resolves glob patterns
      into a map of module paths to lazy/eager imports.
      
      ## Why?
      
      This is a commonly used Vite feature for dynamically importing groups of
      files (e.g., all markdown files in a directory, all route modules
      matching a pattern).
      
      ## How?
      
      ### Core implementation (`import_meta_glob.rs`)
      
      1. **Analysis phase**: `import.meta.glob` is recognized as a well-known
      function via `WellKnownFunctionKind::ImportMetaGlob`. When called,
      arguments are statically analyzed to extract patterns and options.
      
      2. **File discovery**: Uses Turbopack's `read_glob` (with
      `Glob::can_match_in_directory` for efficient directory pruning) to find
      matching files. Negative patterns (prefixed with `!`) are applied via a
      separate `Glob` matcher.
      
      3. **Virtual module**: Each unique `import.meta.glob()` call generates a
      virtual `ImportMetaGlobAsset` module that exports an object mapping file
      paths to either:
      - **Lazy mode** (default): `() => import('./path')` thunks — resolved
      with `EcmaScriptModulesReferenceSubType::DynamicImport`
      - **Eager mode**: Direct `require('./path')` results — resolved with
      `EcmaScriptModulesReferenceSubType::Import`
      
      4. **Code generation**: The `import.meta.glob(...)` call site is
      replaced with `__turbopack_require__(virtual_module_id)`.
      
      ### Architecture
      
      - **`ImportMetaGlobAsset`** is the virtual module. It stores only the
      origin, patterns, and options — no `source` reference.
      - **`ImportMetaGlobAsset::map()`** is a `#[turbo_tasks::function]` that
      builds glob matchers, scans the filesystem, and resolves all matched
      files as ESM imports. Being a turbo-tasks function, the result is
      memoised. Both `references()` and `chunk_item_content()` call this
      single cached function.
      - **`ident()`** is derived from `AssetIdent::from_path(origin_path)`
      with a modifier encoding all glob options, so two `import.meta.glob()`
      calls with different options produce different module idents.
      - **Side effects**: Lazy mode → `SideEffectFree` (only exports thunks,
      nothing evaluated). Eager mode → `ModuleEvaluationIsSideEffectFree` (the
      virtual module itself has no side effects, but its synchronous requires
      trigger real module evaluations).
      
      ### Supported options
      
      | Option | Description |
      |--------|-------------|
      | `eager` | `boolean` — load modules synchronously (default: `false`) |
      | `import` | `string` — select a named export (e.g., `'default'`) |
      | `query` | `string` — append query to imports (e.g., `'?raw'`) |
      | `base` | `string` — base directory for glob scanning |
      
      ### Error handling
      
      Unsupported or invalid usage produces clear compile-time diagnostics
      (error code `TP1008`):
      - `as` option → "not supported, use `query` instead"
      - Unknown option keys → lists supported options
      - Non-constant `eager` → "must be a constant boolean"
      - Non-constant patterns → "must be string literals"
      
      ### Not supported (intentionally)
      
      - `import.meta.globEager()` (removed in Vite 3) — users should use `{
      eager: true }`
      - `as` option (deprecated in Vite 5) — users should use `query`
      
      ## Test Plan
      
      - [x] **Turbopack execution test**
      (`turbopack/crates/turbopack-tests/tests/execution/turbopack/resolving/import-meta-glob/`)
      - Lazy mode, eager mode, named import (`import: 'default'`), negative
      patterns
      - [x] **Turbopack snapshot tests**
      (`turbopack/crates/turbopack-tests/tests/snapshot/import-meta/glob/`)
        - Lazy glob, eager glob, named import
        - Negative patterns (`!**/bar.js`)
        - Multiple patterns (`['./dir/*.js', './other/*.js']`)
      - [x] **Turbopack snapshot error tests**
      (`turbopack/crates/turbopack-tests/tests/snapshot/import-meta/glob-error/`)
        - `as` option error, non-constant `eager` error, unknown option error
      - [x] **Next.js e2e tests** (`test/e2e/import-meta-glob/`)
        - Lazy/eager/named import modules, negative patterns, multi-pattern
      - Passes in both dev (`next dev`) and production (`next build && next
      start`) modes
      - Skipped under webpack (`IS_WEBPACK_TEST=1`) since this is a
      Turbopack-only feature
      
      <!-- NEXT_JS_LLM_PR -->
      
      ---------
      Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      Co-authored-by: 's avatarNiklas Mischkulnig <mischnic@users.noreply.github.com>
      38fdf0c0
    • Tim Neutkens's avatar
      test: use Turborepo pack task for test isolation (#92575) · 263dac30
      Tim Neutkens authored
      ### What?
      
      Eliminates the expensive temporary repo directory (`tmpRepoDir`) copy
      during isolated test setup by leveraging a Turborepo `pack` task with
      caching.
      
      ### Why?
      
      The previous test isolation flow copied the entire `packages/` directory
      to a temp location, mutated every `package.json` to rewrite workspace
      dependency references, and ran `pnpm pack` sequentially for each
      package. This added ~10s+ of overhead per test suite. With Turborepo
      caching, repeated runs are 500ms (and can still be improved).
      
      ### How?
      
      - Adds a `pack-for-isolated-tests` task to `turbo.json` (depends on
      `build`, outputs `packed.tgz`)
      - Adds a `pack-for-isolated-tests` script (`pnpm pack --out
      ./packed.tgz`) to every workspace package
      - Simplifies `linkPackages` in `repo-setup.js` to scan for pre-built
      tarballs instead of copying/rewriting/packing
      - Updates `create-next-install.js` to run `pnpm turbo run pack`
      (benefits from caching) and use package manager `overrides`
      (pnpm/npm/yarn) to resolve transitive workspace deps from local tarballs
      - Removes `tmpRepoDir` handling from `base.ts` and `run-tests.js`
      
      **Before:** `createNextInstall` ~16s (copy + sequential pack)
      **After:** `createNextInstall` ~5s (first run) / ~4s (cached)
      
      <!-- NEXT_JS_LLM_PR -->
      263dac30
    • Dmitrii's avatar
      fix(server-actions): skip type-only ExportNamed in pre-pass to prevent phantom… · cc5bbaad
      Dmitrii authored
      fix(server-actions): skip type-only ExportNamed in pre-pass to prevent phantom registerServerReference (#92494)
      cc5bbaad
    • Hamed's avatar
      docs: fix broken bun.sh Nextjs documentation link (#92698) · 82829bc5
      Hamed authored
      ### What?
      Update outdated bun.sh Next.js documentation link.
      
      ### Why?
      The previous link returned a 404.
      
      ### How?
      Replaced:
      https://bun.sh/docs/frameworks/nextjs
      
      With:
      https://bun.com/docs/guides/ecosystem/nextjsCo-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      82829bc5
    • Tim Neutkens's avatar
      bench: add A/B branch comparison workflow to BENCHMARKING.md (#92721) · 49dd9035
      Tim Neutkens authored
      ## What
      
      Adds a new "A/B branch comparison" section to `bench/BENCHMARKING.md`
      with practical guidance for comparing benchmark results across two
      branches.
      
      ## Why
      
      From running benchmarks comparing canary vs PR #92678, we identified
      several patterns that lead to noisy or misleading results:
      
      - Running the full route suite when only one route shows signal wastes
      time (~3 min per run)
      - The default 120 serial requests is too noisy for sub-2ms routes
      - Single runs can swing 10-15% on light routes
      - Percentage deltas from a single pair of runs can be misleading without
      absolute numbers
      
      ## What's in the new section
      
      - Start with a focused route, not the full suite
      - Increase request counts for fast routes (500 serial / 5000 load)
      - Run at least 3 times per side to average out noise
      - Compare absolute req/s, not just deltas
      - Watch for system state drift between runs
      - Full example workflow with checkout/build/run loop
      
      <!-- NEXT_JS_LLM_PR -->
      49dd9035
    • Tim Neutkens's avatar
      bench: improve render pipeline benchmark reliability (#92715) · 72461425
      Tim Neutkens authored
      ### What?
      
      Improves the render pipeline benchmark
      (`bench/render-pipeline/benchmark.ts`) for more reliable and accurate
      RPS measurement.
      
      ### Why?
      
      The benchmark had several issues that affected measurement accuracy:
      - V8 CPU profiler was on by default, adding 5-15% overhead to all
      numbers
      - 30 warmup requests was insufficient for V8 TurboFan JIT stabilization
      - No stddev made it impossible to tell signal from noise
      - Request errors crashed the whole benchmark instead of being tracked
      - No port cleanup delay between mode switches could cause bind failures
      - No option to isolate routes from cross-route GC/memory contamination
      - Closed-loop measurement model limitations were undocumented
      
      ### How?
      
      - Default `--capture-cpu` to `false` (use `--capture-cpu=true` for
      dedicated profiling runs)
      - Add `--warmup-until-stable` flag (default: true) that runs warmup in
      batches and stops when mean latency delta is <5% between consecutive
      batches
      - Add standard deviation to `computeStats` and print it in results
      - Track request errors in the under-load phase instead of aborting
      - Add 2s sleep between mode switches when `--stream-mode=both`
      - Add `--isolate-routes` flag to restart the server between routes
      - Document the closed-loop measurement model in code and README
      - Add minimal-server scenario documentation to README and benchmarking
      playbook
      
      <!-- NEXT_JS_LLM_PR -->
      72461425
    • Niklas Mischkulnig's avatar
      Turbopack: properly remove unused TS enums with scope hoisting (#88205) · cd1b55b0
      Niklas Mischkulnig authored
      Needs https://github.com/swc-project/swc/pull/11777
      
      https://github.com/swc-project/swc/pull/10560 added `Files.map_raw_pos` which can be used to translate BytePos before generating the sourcemap.
      
      The same is also needed in `SourceMapper`, so that the `pos.is_pure()` in `emit_leading_comments` uses the decoded BytePos.
      
      This came up in https://github.com/vercel/next.js/pull/88205 where my BytePos re-encoding mechanism caused `BytePos::PURE` to not codegen the pure comment anymore.
      
      Closes https://github.com/vercel/next.js/issues/88009
      Closes https://github.com/vercel/next.js/pull/90004
      Closes PACK-6424
      cd1b55b0
    • Sebastian "Sebbie" Silbermann's avatar
      [test] Stop using `baseUrl` (#92469) · d6000df6
      Sebastian "Sebbie" Silbermann authored
      `baseUrl` is deprecated. This PR removes it from tests that don't explicitly test `baseUrl` resolution. Tests that relied on `baseUrl` were migrated to use `paths`. Tests specifically for `baseUrl` were migrated in https://github.com/vercel/next.js/pull/92277 to use TypeScript 5.9.
      d6000df6
    • Vercel Release Bot's avatar
      Update font data (#92704) · fda35057
      Vercel Release Bot authored
      This auto-generated PR updates font data with latest available
      Co-authored-by: 's avatarnextjs-bot <it+nextjs-bot@vercel.com>
      fda35057
  2. 12 Apr, 2026 5 commits
    • nextjs-bot's avatar
      v16.2.1-canary.34 · 4c62bb11
      nextjs-bot authored
      4c62bb11
    • Luke Sandberg's avatar
      turbo-tasks: Drop output_dependent on immutable task completion (#92683) · 75a12436
      Luke Sandberg authored
      ### What?
      
      Extend the `cleanup_after_execution` macro codegen to support
      `drop_on_completion_if_immutable` on **inline** collection fields
      (previously only lazy fields were supported), and apply it to
      `output_dependent` in the task storage schema.
      
      ### Why?
      
      `output_dependent` tracks which tasks depend on a given task's output,
      used for invalidation and leaf distance propagation. For immutable
      tasks:
      
      - **No invalidation needed** — the output never changes, so dependents
      never need to be dirtied via this edge.
      - **No new readers added** — `try_read_task_output` already guards with
      `!task.immutable()` at `mod.rs:742`, so the set is frozen after
      completion.
      - **Leaf distance propagation** — immutable tasks can be treated as
      non-participants in the leaf distance graph; propagation simply stops at
      immutable nodes.
      
      This matches the existing treatment of `cell_dependents`, which already
      has `drop_on_completion_if_immutable` for the same reasons (immutable
      tasks' cells don't change).
      
      ### How?
      
      **Macro change**
      (`turbo-tasks-macros/src/derive/task_storage_macro.rs`):
      
      The `generate_cleanup_after_execution` function previously only handled
      `shrink_on_completion` for inline fields. Now it also handles
      `drop_on_completion_if_immutable`: when the task is immutable, it emits
      `typed.field_name = Default::default()` which replaces the `AutoSet`
      with an empty one, releasing any heap allocation (`Box<HashMap>` or
      spilled `SmallVec` buffer). When mutable, it falls back to
      `shrink_to_fit()`.
      
      Note: unlike lazy fields which are physically removed from
      `Vec<LazyField>`, inline fields always occupy their struct slot — but
      `Default::default()` ensures zero heap overhead (the `SmallVec<[_; 1]>`
      reverts to inline storage).
      
      **Schema change** (`turbo-tasks-backend/src/backend/storage_schema.rs`):
      
      Added `drop_on_completion_if_immutable` to the `#[field(...)]` attribute
      on `output_dependent`.
      
      <!-- NEXT_JS_LLM_PR -->
      
      ---------
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      75a12436
    • Joseph's avatar
      docs(cli): clarify that `--debug-build-paths` requires route group folders in paths (#92618) · db0fdc30
      Joseph authored
      <!-- CURSOR_AGENT_PR_BODY_BEGIN -->
      ### What?
      
      Adds a note to the `--debug-build-paths` section of the CLI docs
      clarifying that [route
      groups](https://nextjs.org/docs/app/building-your-application/routing/route-groups)
      must be included in file paths.
      
      ### Why?
      
      When using `--debug-build-paths`, users need to include route group
      folders (e.g., `(marketing)`) in the file paths they pass. This isn't
      obvious from the existing documentation — route groups are stripped from
      URLs at runtime but must be present in file paths for this CLI option to
      work correctly.
      
      Addresses feedback from a docs comment noting that "Route groups are
      also necessary, should be inferred from file paths, but it is not
      straightforward from reading this."
      
      ### How?
      
      Added a "Good to know" callout with an example showing how to reference
      a page inside a route group:
      
      ```bash
      next build --debug-build-paths="app/(marketing)/about/page.tsx"
      ```
      
      <!-- NEXT_JS_LLM_PR -->
      <!-- CURSOR_AGENT_PR_BODY_END -->
      
      [Slack
      Thread](https://vercel.slack.com/archives/C07ND110MMF/p1775828588791049?thread_ts=1775828588.791049&cid=C07ND110MMF)
      
      <div><a
      href="https://cursor.com/agents/bc-3a58eac7-35a3-56ab-aff2-f4cf2dd1ca9b"><picture><source
      media="(prefers-color-scheme: dark)"
      srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
      media="(prefers-color-scheme: light)"
      srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
      alt="Open in Web" width="114" height="28"
      src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
      href="https://cursor.com/background-agent?bcId=bc-3a58eac7-35a3-56ab-aff2-f4cf2dd1ca9b"><picture><source
      media="(prefers-color-scheme: dark)"
      srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
      media="(prefers-color-scheme: light)"
      srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
      alt="Open in Cursor" width="131" height="28"
      src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>
      
      ---------
      Co-authored-by: 's avatarCursor Agent <cursoragent@cursor.com>
      Co-authored-by: 's avatarJoseph <icyJoseph@users.noreply.github.com>
      db0fdc30
    • Tim Neutkens's avatar
      Node.js streams: Add forkpoint for error recovery (#92457) · cd07aa37
      Tim Neutkens authored
      ## What?
      
      Building on top of the changes in
      https://github.com/vercel/next.js/pull/92252. This PR implements similar
      fork points for the `catch` path.
      cd07aa37
    • Luke Sandberg's avatar
      Delete some dead turbo task functions (#92596) · a05035f3
      Luke Sandberg authored
      Removes a handful of dead code discovered while exploring deletion of the `ValueDefault` trait. That larger change turned out not to be worth it from a binary size perspective, so it was backed out — but the dead code found along the way is worth keeping.
      
      **Removed:**
      - `impl ValueDefault for VersionedContentMap` (not tagged with `#[turbo_tasks::value_impl]`, never a turbo-tasks singleton)
      - `impl ValueDefault for Body` in `turbopack-dev-server` (same — plain Rust impl, no callers via `Vc::default()`)
      - `EmotionTransformConfig::default_private()` and `impl ValueDefault for EmotionTransformConfig` (unused)
      - `StyledComponentsTransformConfig::default_private()` and `impl ValueDefault for StyledComponentsTransformConfig` (unused)
      - `EmittedEvaluatePoolAssetsWithEffects` struct in `evaluate.rs` (defined but never referenced)
      - `OutputAsset::size_bytes()` default trait method (no call sites)
      
      <!-- NEXT_JS_LLM_PR -->
      a05035f3
  3. 11 Apr, 2026 7 commits
    • nextjs-bot's avatar
      v16.2.1-canary.33 · 2f7f4d7d
      nextjs-bot authored
      2f7f4d7d
    • Matt Mastracci's avatar
      Disable sccache temporarily (#92657) · 6a563d82
      Matt Mastracci authored
      The cache server is returning 500s -- disable sccache while we sort that
      out.
      6a563d82
    • Tim Neutkens's avatar
      Perf: Only instrument clientComponentLoadTimes when used (#91385) · 184aad95
      Tim Neutkens authored
      ## What?
      
      Currently time spent requiring client components is always tracked, but
      if the instrumentation hook for it is disabled it's not relevant, so
      skipping the instrumentation is better.
      184aad95
    • Tim Neutkens's avatar
      Fix segment explorer file pill accessibility (#92608) · 8e5a36f6
      Tim Neutkens authored
      ### What?
      
      Make the segment explorer file pills keyboard-accessible by rendering
      them as buttons and preserving their pill styling.
      
      ### Why?
      
      The pills launch files in the editor, but they were rendered as
      clickable spans, so they were not exposed as interactive controls for
      keyboard and assistive technology users.
      
      ### How?
      
      - replace the clickable span with a button element
      - add an accessible label and hide decorative icons from assistive
      technology
      - add pointer and focus-visible styles so the control remains
      recognizable and keyboard accessible
      
      Closes NEXT-
      Fixes #
      
      <!-- NEXT_JS_LLM_PR -->
      8e5a36f6
    • Niklas Mischkulnig's avatar
    • Tobias Koppers's avatar
      feat(turbopack): change DiskFileSystem root to Vc<RcStr> for portable cache (#92603) · 143d9ca1
      Tobias Koppers authored
      ### What?
      
      Changes the `root` parameter of `DiskFileSystem::new`,
      `DiskFileSystem::new_with_denied_paths`, and the internal
      `DiskFileSystem::new_internal` from `RcStr` to `Vc<RcStr>`.
      
      ### Why?
      
      Part of the effort to make the Turbopack persistent cache portable when
      the absolute path of the project directory changes. By accepting the
      root as a `Vc<RcStr>` instead of a plain `RcStr`, the path is tracked as
      a turbo-tasks value. This allows the cache to remain valid even when the
      project root moves (e.g. on a different machine, a different CI working
      directory, or a relocated checkout), since the value can be substituted
      independently without invalidating unrelated cached computations.
      
      ### How?
      
      - `new_internal` is now an `async fn` that awaits the `Vc<RcStr>` to
      extract the underlying `RcStr` for constructing `DiskFileSystemInner`.
      It returns `Result<Vc<Self>>` accordingly.
      - `new` and `new_with_denied_paths` (the public constructors, which are
      not `#[turbo_tasks::function]` themselves) are updated to accept
      `Vc<RcStr>` and forward it to `new_internal`.
      - All 23 call sites across the codebase are updated to wrap their root
      string with `Vc::cell(...)` before passing it.
      
      Verified with `cargo clippy --all-targets` (clean), `cargo test -p
      turbo-tasks-backend` (all pass), and `cargo test -p turbopack-tests`
      (all 89 pass).
      
      <!-- NEXT_JS_LLM_PR -->
      
      ---------
      Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      143d9ca1
    • Tobias Koppers's avatar
      feat(turbopack): add LocalPathOrProjectPath PostCSS config resolution (#91338) · 74cdcde8
      Tobias Koppers authored
      ### What?
      
      Adds a new `experimental.turbopackLocalPostcssConfig` option and
      corresponding `PostCssConfigLocation::LocalPathOrProjectPath` variant so
      Turbopack can resolve `postcss.config.js` starting from the CSS file's
      directory first, falling back to the project root.
      
      Also fixes an issue that surfaces when multiple per-directory
      `postcss.config.js` files are used:
      
      **Evaluate pool asset name collisions** — output file names for the
      Node.js evaluate pool are now derived from an xxh3 hash of the full
      module ident rather than the bare file name, so multiple
      `postcss.config.js` files in different directories no longer collide.
      
      ### Why?
      
      Currently Turbopack uses `ProjectPathOrLocalPath` which checks the
      project root first, then falls back to the local directory. This means
      per-directory `postcss.config.js` files cannot override the root config
      — the root config always wins. For projects that need different PostCSS
      transforms in different directories (e.g. a monorepo with multiple apps
      or style directories), the more specific config should take precedence.
      
      ### How?
      
      **Turbopack PostCSS resolution**
      (`turbopack/crates/turbopack-node/src/transforms/postcss.rs`):
      - Added `PostCssConfigLocation::LocalPathOrProjectPath` enum variant
      with doc comments on all variants
      - Refactored `find_config_in_location()` to express the search order as
      a `Vec<FileSystemPath>` built from a single `match`, making each
      variant's strategy immediately clear
      
      **Evaluate pool asset file naming**
      (`turbopack/crates/turbopack-node/src/evaluate.rs`):
      - Replaced file-name-based output path derivation with a deterministic
      xxh3 hash of the full module ident
      - Adds `turbo-tasks-hash` dependency to `turbopack-node`
      - Eliminates name collisions when multiple entries share the same file
      name (e.g. per-directory `postcss.config.js` files)
      
      **Next.js config flag** (`packages/next/src/server/config-shared.ts`,
      `config-schema.ts`):
      - Added `experimental.turbopackLocalPostcssConfig: boolean` option
      (opt-in, default `false`)
      - Wired through `crates/next-core/src/next_config.rs` → both client and
      server contexts (`next_client/context.rs`, `next_server/context.rs`)
      - When `true`, uses `LocalPathOrProjectPath`; when `false`/unset, uses
      the existing `ProjectPathOrLocalPath` (no behavior change by default)
      
      **E2E test** (`test/e2e/app-dir/turbopack-postcss-multiple-configs/`):
      - Runs in both **Turbopack dev and production modes** — skips webpack
      only (webpack does not support function-valued PostCSS plugins and the
      `turbopackLocalPostcssConfig` flag is Turbopack-specific)
      - 5 style directories, each with its own `postcss.config.js` passing a
      **unique color option** (`blue`, `purple`, `orange`, `cyan`, `magenta`)
      to a shared PostCSS plugin, proving that per-directory config resolution
      produces distinct results rather than all sharing the same transform
      - Root `postcss.config.js` is a no-op — if only the root config were
      used, CSS would remain unmodified
      - Test validates all 15 elements (5 dirs × 3 files) render with CSS
      module classes
      - Test collects all CSS (inline `<style>` tags for dev, linked `.css`
      files for production) and asserts each directory's expected color is
      present and `color: red` is absent
      
      **Documentation**
      (`docs/01-app/03-api-reference/05-config/01-next-config-js/turbopackLocalPostcssConfig.mdx`,
      `docs/01-app/03-api-reference/08-turbopack.mdx`):
      - New dedicated reference page for
      `experimental.turbopackLocalPostcssConfig` covering usage, behavior
      table, and a directory-tree example
      - Added to the experimental options table in the Turbopack API reference
      
      ## Test plan
      
      - [x] `cargo check -p turbo-tasks-backend` passes
      - [x] `cargo check -p turbopack-node` and `cargo check -p next-core`
      pass
      - [x] E2E test `turbopack-postcss-multiple-configs` validates
      per-directory PostCSS config resolution across 5 directories with
      distinct per-directory colors (Turbopack dev and production modes)
      - [x] Test correctly skips in webpack mode and deployment
      - [x] Documentation page and experimental options table updated
      
      <!-- NEXT_JS_LLM_PR -->
      
      ---------
      Co-authored-by: 's avatarClaude <noreply@anthropic.com>
      Co-authored-by: 's avatarTobias Koppers <sokra@users.noreply.github.com>
      74cdcde8
  4. 10 Apr, 2026 10 commits
    • Luke Sandberg's avatar
      Remove a ton of turbo task functions from Issue trait items (#92623) · 35b55826
      Luke Sandberg authored
      ## What?
      
      Remove `#[turbo_tasks::function]` from all methods on the `Issue` value_trait, following the same pattern as #92593 which did the same for `ValueDebug`.
      
      The `Issue` trait previously had 8 methods decorated with `#[turbo_tasks::function]`, which caused the turbo-tasks machinery to generate `NativeFunction` statics, task registration, vtable entries, and scheduling/caching infrastructure for each method on each of the ~48 `impl Issue for` types in the codebase — most of which are trivially synchronous (returning a constant string, enum variant, or stored struct field).
      
      ## How?
      
      - Change all 8 `Issue` trait methods to plain methods. Methods that are always synchronous become direct return-type methods (`severity`, `stage`, `source`, `documentation_link`). Methods that are genuinely async on at least one impl use `Pin<Box<dyn Future<Output = Result<T>> + Send + '_>>` for object safety.
      - Callers that need to invoke trait methods on a `Vc<Box<dyn Issue>>` use `issue.into_trait_ref().await?` to get a `TraitRef<Box<dyn Issue>>` and call methods directly on that.
      - `PlainIssue::from_issue` (the sole hot caller that materializes all fields) resolves one `trait_ref` and calls all methods on it, similar to the `ValueDebug` pattern.
      - `ResolvingIssueWithLocation` (which wraps an inner `ResolvedVc<Box<dyn Issue>>`) eagerly copies `severity`, `stage`, `documentation_link`, and `source` at construction time rather than delegating async calls to the inner issue.
      - Delete `OptionIssueSource` and `OptionStyledString` wrapper types, which existed solely as `Vc<T>` return type wrappers for the old turbo-tasks methods.
      
      ## Tradeoffs
      
      **Lost per-call caching:** Previously each `Issue` method was a turbo-tasks task, so results were cached per `(Vc<Issue>, method)`. In practice this caching was useless — issues are emitted once and their fields read once by `PlainIssue::from_issue`, so there was never a second call to hit the cache. The only real cost is that `IssueFilter::matches` previously cached per `(filter, issue)` pair; that caching is preserved because `matches` itself remains a `#[turbo_tasks::function]` and now calls `into_trait_ref().await?` once at the top.
      
      **`ResolvingIssueWithLocation` eagerly reads inner fields:** Instead of lazily delegating to the inner issue, `stage` and `documentation_link` are copied at construction. This is a minor semantic change (the values are snapshotted rather than live), but in practice these fields are always constant values so it makes no difference.
      
      ## Binary size impact (darwin-arm64, compared against #92593)
      
      | Metric | #92593 baseline | This PR | Delta |
      |---|---|---|---|
      | Unstripped dylib | 124.6 MB | 124.0 MB | **-0.6 MB (-0.5%)** |
      | Stripped | 84.7 MB | 84.4 MB | **-0.3 MB (-0.4%)** |
      | Stripped + gzip (npm) | 29.2 MB | 29.1 MB | **-0.1 MB (-0.3%)** |
      
      Smaller savings than `ValueDebug` (~2.5 MB stripped) because there are ~48 `Issue` impls vs. one `ValueDebug` impl per every `#[turbo_tasks::value]` type. But real and cumulative.
      
      <!-- NEXT_JS_LLM_PR -->
      35b55826
    • nextjs-bot's avatar
      v16.2.1-canary.32 · 39199204
      nextjs-bot authored
      39199204
    • Matt Mastracci's avatar
      fix(ci): improve Docker image caching and native build skip optimization (#92633) · dd2b8fd7
      Matt Mastracci authored
      ## Summary
      
      - **turbo-cache.mjs**: Increase stream buffer from 16KB to 16MB (fixes
      throughput stalls when piping large artifacts). Add transfer stats
      tracking with 5s stall warning. `getToFile()` now returns `{ ok, stats
      }`.
      - **docker-image-cache.js**: Switch from `docker save/load` to
      `export/import` (drops redundant base image layers). Use `zstd
      --long=27` for better compression. Add 3x retry logic. Add arch-aware
      cache key to prevent cross-arch cache poisoning. Add download stats
      logging.
      - **native-cache.js**: Consume new `getToFile()` return shape, log
      download stats.
      - **build_and_deploy.yml**: Reorder to try native binary cache restore
      BEFORE Docker image restore. On cache hit, skip the expensive Docker
      image download entirely.
      dd2b8fd7
    • Ben Gubler's avatar
      refactor: write pages router export files directly to server/pages/ (#90018) · 42b2a625
      Ben Gubler authored
      ## Summary
      - write pages-router export artifacts directly into `.next/server/pages`
      during `buildExport` instead of writing to `dist/export` and moving
      afterward
      - simplify build finalization by updating `pages-manifest` entries
      directly and removing the export temp directory move/cleanup flow
      - keep prerender behavior aligned by deleting `notFound` artifacts from
      `server/pages` and pointing static export copy logic at the new
      pages-router output location
      
      ---------
      Co-authored-by: 's avatarZack Tanner <1939140+ztanner@users.noreply.github.com>
      42b2a625
    • Niklas Mischkulnig's avatar
      Turbopack: cut number of client references in half (#92607) · e934009e
      Niklas Mischkulnig authored
      Currently, every client reference exists twice, but one of them is always dead code.
      
      This shouldn't have an impact on the responses sent to the browser, but the server code is smaller. Doesn't have a measureable impact on cold build time.
      
      For one page, this shrank page_client-reference-manifest.js from 979k to 742k
      
      ```js
      "[project]/app/[slug]/counter-2.js [app-rsc] (client reference proxy) <module evaluation>", ((__turbopack_context__) => {
      "use strict";
      
      // UNUSED
      __turbopack_context__.s(["default",()=>__TURBOPACK__default__export__]);
      var reactDom = __turbopack_context__.i("react-server-dom-turbopack-server.js [app-rsc] (ecmascript)");
      const __TURBOPACK__default__export__ = (0, reactDom["registerClientReference"])(function() {
          throw new Error("Attempted to call the default export of [project]/app/[slug]/counter-2.js <module evaluation> from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");
      }, "[project]/app/[slug]/counter-2.js <module evaluation>", "default");
      
      }),
      "[project]/app/[slug]/counter-2.js [app-rsc] (client reference proxy)", ((__turbopack_context__) => {
      "use strict";
      
      __turbopack_context__.s(["default",()=>__TURBOPACK__default__export__]);
      var reactDom = __turbopack_context__.i("react-server-dom-turbopack-server.js [app-rsc] (ecmascript)");
      const __TURBOPACK__default__export__ = (0, reactDom["registerClientReference"])(function() {
          throw new Error("Attempted to call the default export of [project]/app/[slug]/counter-2.js from the server, but it's on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.");
      }, "[project]/app/[slug]/counter-2.js", "default");
      
      }),
      "[project]/app/[slug]/counter-2.js [app-rsc] (ecmascript)", ((__turbopack_context__) => {
      "use strict";
      
      
      // UNUSED:
      var client__reference__proxy$29$__$3c$module__evaluation$3e$__ = __turbopack_context__.i("[project]/app/[slug]/counter-2.js [app-rsc] (client reference proxy) <module evaluation>");
      // Only this is exported
      var client__reference__proxy$29$__ = __turbopack_context__.i("[project]/app/[slug]/counter-2.js [app-rsc] (client reference proxy)");
      ;
      __turbopack_context__.n(client__reference__proxy$29$__);
      }),
      
      "[project]/app/[slug]/page.js [app-rsc] (ecmascript)", ((__turbopack_context__) => {
      
      var counter = __turbopack_context__.i("[project]/app/[slug]/counter-1.js [app-rsc] (ecmascript)");
      
      ```
      and also twice in the manifest
      ```js
          '[project]/bench/client-refs/app/[slug]/counter-1.js <module evaluation>': {
            id: '[project]/bench/client-refs/app/[slug]/counter-1.js [app-client] (ecmascript)',
            name: '*',
            chunks: [
              '/_next/static/chunks/2li6a5uw43ak2.js',
              '/_next/static/chunks/08svqy8591o8a.js',
            ],
            async: false,
          },
          '[project]/bench/client-refs/app/[slug]/counter-1.js': {
            id: '[project]/bench/client-refs/app/[slug]/counter-1.js [app-client] (ecmascript)',
            name: '*',
            chunks: [
              '/_next/static/chunks/2li6a5uw43ak2.js',
              '/_next/static/chunks/08svqy8591o8a.js',
            ],
            async: false,
          },
      ```
      e934009e
    • zoomdong's avatar
      chore(turbopack): upgrade qfiler to v0.3.0-alpha.4 (#92558) · 21933bc8
      zoomdong authored
      utoopack upgrade to crate dependencies of turbopack, this dependenices
      will upgrade to `0.3.0-alpha.4` and cause api build error.
      
      it seems we can just upgrade it:
      https://github.com/arthurprs/qfilter/pull/24/changes#diff-b1a35a68f14e696205874893c07fd24fdb88882b47c23cc0e0c80a30c7d53759
      
      ---------
      Co-authored-by: 's avatarBenjamin Woodruff <benjamin.woodruff@vercel.com>
      21933bc8
    • Niklas Mischkulnig's avatar
    • Luke Sandberg's avatar
      Turbopack: fix filesystem watcher config not applying follow_symlinks(false) (#92631) · 9fb4c752
      Luke Sandberg authored
      ## Summary
      
      - The notify `Config` uses a builder pattern where `with_follow_symlinks()` consumes `self` and returns a new `Config`, but the return value was being discarded — so `follow_symlinks` remained at its default (`true`).
      - The `RecommendedWatcher` branch was also passing `Config::default()` instead of the configured `config` object, ignoring the config entirely.
      
      ## Test plan
      
      - [x] `cargo check -p turbo-tasks-fs` passes
      - Behavioral: symlinks under the watched root will now trigger events for the symlink itself rather than the target, matching the intent of the existing comment.
      
      <!-- NEXT_JS_LLM_PR -->
      9fb4c752
    • Zack Tanner's avatar
      [partial fallbacks]: enable by default (#92627) · 8a1316e2
      Zack Tanner authored
      This makes `experimental.partialFallbacks` the default when
      `cacheComponents` is enabled.
      
      For routes that prerender only a subset of params via
      `generateStaticParams`, requests for unknown params used to either
      suspend to a nearby fallback or block until the full route finished
      rendering. In the cases where the route could already produce a
      contentful shell because param access happened below a Suspense
      boundary, the old default still served that generic shell on every
      request.
      
      With `partialFallbacks` enabled by default, the first request still
      receives the best shell available for that route, but Next.js now
      revalidates in the background using the newly discovered param values.
      That allows subsequent requests to reuse a more specific cached result:
      - If the route becomes fully static for those params, later requests get
      the fully prerendered page.
      - If the leaf remains dynamic, Next.js upgrades the shell as far as it
      can, filling in the newly known static params while the dynamic portion
      continues to stream.
      
      This also fixes a bug that was caught now that we ran this flag against
      the entire CI. A concrete path like `/optional-catchall` could match the
      generic `/optional-catchall/[[...slug]]` shell and incorrectly serve
      fallback-shell behavior even though that exact path was already
      prerendered. This change keeps concrete prerendered paths serving their
      concrete result instead of downgrading back to the generic shell.
      
      This PR also removes redundant `partialFallbacks: true` test config and
      adds coverage for the explicit opt-out behavior (`partialFallbacks:
      false`).
      8a1316e2
    • Luke Sandberg's avatar
      Drop turbo_tasks::function from ValueDebug trait items (#92593) · af83b4b3
      Luke Sandberg authored
      ## What?
      
      Simplify the `ValueDebug` trait in turbo-tasks by removing turbo-tasks function overhead from `dbg` and `dbg_depth`.
      
      ## Why?
      
      Every `#[turbo_tasks::value]` and `#[turbo_tasks::value_trait]` type previously generated two `#[turbo_tasks::function]` implementations of `dbg` and `dbg_depth`. These are debugging utilities that are almost never called in production, but the turbo-tasks function machinery (task registration, vtable entries, `NativeFunction` statics, inline extension traits) was emitted for every type regardless — contributing to binary bloat.
      
      ## How?
      
      - Change `dbg` and `dbg_depth` on the `ValueDebug` trait from `#[turbo_tasks::function]` methods to plain methods returning `Pin<Box<dyn Future<...>>>` (required for object safety without `async_trait`)
      - Add a default `dbg` implementation on the trait itself that delegates to `dbg_depth(usize::MAX)`, so derived impls only need to implement `dbg_depth`
      - Remove `ValueDebugString` wrapper type — callers now get a plain `String` back
      - Callers use `vc.into_trait_ref().await?` then call `.dbg()` / `.dbg_depth()` directly on the trait ref
      - Update the four macro locations that generate `ValueDebug` impls: `value_debug_macro.rs`, `value_macro.rs`, `primitive_macro.rs`, and the call site in `vc/mod.rs`
      - `#[turbo_tasks::value_impl]` is kept on the generated `impl ValueDebug for T` blocks so that `Upcast`/`UpcastStrict` and `CollectableTraitCastFunctions` (needed for `into_trait_ref`) are still registered
      
      ## Binary size impact (darwin-arm64, compared against canary)
      
      | Metric | Canary | This PR | Delta |
      |---|---|---|---|
      | Unstripped dylib | 128.6 MB | 124.6 MB | **-4.0 MB (-3.1%)** |
      | Stripped | 87.2 MB | 84.7 MB | **-2.5 MB (-2.9%)** |
      | Stripped + gzip (npm) | 29.6 MB | 29.2 MB | **-0.4 MB (-1.4%)** |
      
      <!-- NEXT_JS_LLM_PR -->
      af83b4b3