1. 03 Sep, 2025 25 commits
    • nextjs-bot's avatar
      v15.5.1-canary.25 · c181f356
      nextjs-bot authored
      c181f356
    • Jakob Klotz's avatar
      Docker example using bun (#83040) · f41c8093
      Jakob Klotz authored
      ### What?
      
      Expanded the `with-docker` example for usage with `bun` and added build
      instructions to the README.
      
      ### Why?
      
      The existing example supports npm, yarn and pnpm, but not bun. 
      
      ### How?
      
      - Add a separate Dockerfile.bun placed next to the existing Dockerfile,
      which is more sensible for the existing solution.
      - Dockerfile.bun uses the official oven/bun base image (different
      runtime/tooling than node:18-alpine), so a separate file should be
      clearer.
      - Existing Docker commands in the README remain unchanged, because
      Docker still uses the existing Dockerfile by default.
      - The bun example can be built with: `docker build -f Dockerfile.bun -t
      nextjs-docker .`
      
      Related to #78465, #82998
      
      ---------
      Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
      Co-authored-by: 's avatarvercel[bot] <35613825+vercel[bot]@users.noreply.github.com>
      Co-authored-by: 's avatarJoseph <sephxd1234@gmail.com>
      f41c8093
    • Niklas Mischkulnig's avatar
      test: Refactor edge-runtime-dynamic-code test (#83390) · 7861621f
      Niklas Mischkulnig authored
      This test is about `eval`
      But it also used a non-static middleware `matchers` config, which is going to break once we are more strict about this and throw a build error.
      7861621f
    • Hendrik Liebau's avatar
      [test] Do not use sandboxes for hydration error tests (#83398) · c2d3e654
      Hendrik Liebau authored
      The sandboxes used in the `Error overlay for hydration errors in App
      router` test suite frequently lead to timeout errors in CI
      ([DD](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.type%3A%22nextjs%22%20%40test.status%3A%22fail%22%20%40git.branch%3Acanary%20%40test.suite%3A%22Error%20overlay%20for%20hydration%20errors%20in%20App%20router%22&agg_m=count&agg_m_source=base&agg_t=count&currentTab=overview&eventStack=&fromUser=false&index=citest&start=1755633071704&end=1756929071704&paused=false))
      and also make it unnecessarily complicated to run the scenarios locally
      with `pnpm next dev`. I also have a suspicion that the sandboxes are not
      properly cleaning up after themselves, leading to test interference.
      
      By saving the inlined layouts and pages to actual files, we can avoid
      the issues caused by sandboxes and make the tests faster, more reliable,
      and easier to debug.
      c2d3e654
    • Jiachi Liu's avatar
      [metadata] refactor metadata loaders (#83304) · 51350aa1
      Jiachi Liu authored
      51350aa1
    • Benjamin Woodruff's avatar
      Turbopack: Remove undocumented `turbopack.conditions` configuration (#83237) · 1446fc5a
      Benjamin Woodruff authored
      This syntax was undocumented, and as far as I can tell, there are no OSS external users of this API: https://sourcegraph.com/search?q=context:global+/turbopack:%28.%7C%5Cn%29*conditions:/&patternType=keyword&sm=0
      
      https://github.com/vercel/next.js/pull/82857 provides a better syntax for defining these conditions that we intend to document.
      1446fc5a
    • Luke Sandberg's avatar
      [turbopack] Remove a useless try_join. (#83391) · d73ab9d5
      Luke Sandberg authored
      This is leftover from when FileSystem operations were made synchronous
      d73ab9d5
    • Tim Neutkens's avatar
      Turbopack: Skip manifest loading in server when using route modules (#82903) · 3efa21aa
      Tim Neutkens authored
      ## What?
      
      When using Turbopack we'd try to load these files even when they don't
      exist, which adds latency because of the retrying. This PR ensures the
      files are skipped from loading where possible, which moves the place
      where it starts loading the manifest to the route modules instead. The
      exception to this is the static generation steps as those don't rely on
      route modules yet. This is something still being worked on.
      3efa21aa
    • Sebastian "Sebbie" Silbermann's avatar
    • nextjs-bot's avatar
    • yiminghe's avatar
      458605e6
    • Sebastian "Sebbie" Silbermann's avatar
    • Jiachi Liu's avatar
      93e1a4c7
    • Jiachi Liu's avatar
    • Cong-Cong Pan's avatar
      45b4a985
    • Hendrik Liebau's avatar
      [Cache Components] Fix revalidation of prerendered route handlers (#83375) · c316c79a
      Hendrik Liebau authored
      When a prerendered and deployed route handler is revalidated, we can not
      rely on having a cache handler that does in-memory caching. So we need
      to provide a prerender resume data cache (RDC) instead, to ensure that
      the revalidation doesn't fail with the following error:
      
      ```
      Error: Dynamic server usage: Route / couldn't be rendered statically because it used IO that was not cached.
      ```
      
      Route handlers are never resumed, so it's counter-intuitive to use an
      RDC for this scenario. However, we need the data cache to store cached
      results in memory during the prospective prerender, so that they can be
      retrieved during the final prerender within microtasks.
      
      In a follow-up, we should replace the `prerenderResumeDataCache` and
      `renderResumeDataCache` with a single `dataCache` property that is
      conceptually not tied to resuming, and also avoids the unnecessary
      complexity of using a mutable and an immutable resume data cache.
      
      closes NAR-350
      c316c79a
    • Sebastian "Sebbie" Silbermann's avatar
    • Jiachi Liu's avatar
      6ffc0c70
    • Joseph's avatar
      docs: relative links that were absolute (#83317) · d373280a
      Joseph authored
      Certain relative links were absolute, which renders them with the ->
      external arrow - might have been a decision per case, but AFAIK, this is
      only helpful for those links that are now redirecting to other content
      d373280a
    • Wyatt Johnson's avatar
      fix(ppr): fix prerender info matching for rewritten paths (#83359) · 886f543a
      Wyatt Johnson authored
      ## What?
      
      Fixed prerender info matching for rewritten paths in App Router by using
      `resolvedPathname` instead of `parsedUrl.pathname` in the app-page
      template.
      
      ## Why?
      
      Previously, the app-page template used `parsedUrl.pathname` to match
      against `prerenderManifest` routes. However, when middleware rewrites
      paths, `parsedUrl.pathname` contains the original (unrewritten) path,
      while `resolvedPathname` contains the actual path that should be used
      for prerender lookup.
      
      This mismatch caused incorrect prerender behavior for routes that were
      rewritten by middleware, as the handler would look up prerender info
      using the wrong path.
      
      This handling is special cased for when not handling an interception
      route when cache components is not enabled. This work is being tracked
      in NAR-335.
      
      ## How?
      
      - **Modified `packages/next/src/build/templates/app-page.ts`**: 
        - Removed unused `parsedUrl` parameter from handler function
      - Updated prerender info matching to use `resolvedPathname` instead of
      `parsedUrl.pathname`
      - Added explanatory comment about why `resolvedPathname` is the correct
      choice
      
      - **Added comprehensive test suite** in
      `test/e2e/app-dir/sub-shell-generation-middleware/`:
        - Tests various middleware rewrite scenarios
        - Validates sub-shell generation behavior with nested dynamic routes
        - Tests both static and dynamic prerender scenarios
      - Includes middleware that rewrites paths to different route structures
      
      - **Enhanced deploy testing** in `test/lib/next-modes/next-deploy.ts`:
        - Added `stderr: 'inherit'` to provide earlier deployment feedback
        - Improves debugging experience for deployment-related tests
      
      The fix ensures that prerender info lookup works correctly for all
      paths, whether they're rewritten by middleware or not, providing
      consistent behavior across different routing scenarios.
      
      Fixes #83354
      886f543a
    • Sebastian "Sebbie" Silbermann's avatar
    • Luke Sandberg's avatar
      [turbopack] Remove build scripts and register functions (#83156) · 4a85aab0
      Luke Sandberg authored
      ## What
      
      #83074 migrated us to use `inventory` for registration, this obsoleted the build scripts and `register` functions.  So, delete them!
      
      ## Why?
      
      Simplification, keeping registration and definition next to each other will make it easier to maintain.
      
      I was also optimistic about build performance.  unscientifically i ran `cargo clean` and then timed `pnpm turbo build-native` with and without this PR (closed VSCode and other copies of rustc)
      
      CHANGE:
      real	3m30.220s
      user	34m41.703s
      sys	1m44.112s
      
      HEAD:
      real	3m31.017s
      user	34m47.691s
      sys	1m47.096s
      
      😢  So yeah, not much of an effect, im guessing the build.rs scripts had good parallelism in the build or were just dwarfed by wasmer
      4a85aab0
    • Jesse Hall's avatar
      examples(with-mongodb): upgrade to tailwind v4 (#83225) · cce01bad
      Jesse Hall authored
      Upgraded to tailwind 4 and updated react version and dependencies.
      
      ---------
      Co-authored-by: 's avatarCopilot <175728472+Copilot@users.noreply.github.com>
      Co-authored-by: 's avatarJiwon Choi <devjiwonchoi@gmail.com>
      Co-authored-by: 's avatarMichael Arguin <michael.arguin@vercel.com>
      cce01bad
    • Luke Sandberg's avatar
      [turbopack] Adopt inventory for our registry (#83074) · 099b1e35
      Luke Sandberg authored
      ## What?
      
      Leverage the `inventory` crate to automatically register turbo tasks objects using specialized linker sections.  See https://docs.rs/inventory/0.3.21/inventory/ for details
      
      For NativeFunction and TraitType objects this was trivial and simplified the registry, for example.
      
      * functions only need the global registry during PC _deserialization_ so many builds can skip the cost.
          * Even when we do allocate it, we can use a normal `HashMap` instead of a `DashMap` which should be a minor performance benefit on its own (no locks, smaller in ram)
      
      * TraitType objects achieve similar benefits. 
      
      The tricky part of course was trait impls:
       * Every `ValueType` needs to know all the trait methods it implements
          * To support calling `turbo_tasks::functions` on `Vc<Box<dyn T>>`
      * every `TraitType` needs to know all the structs that implement it
          * To support dereferencing a trait ref, aka `TraitRef<Box<dyn T>>` -> `&dyn T` to support calling non-turbotasks functions
      
      This required two more registries which more or less followed the existing pattern.  One benefit of the new `inventory` approach is that the `VTableRegistry` drops its interior mutability (and associated locks).  Constructing VTableRegistry objects also becomes lazy which is useful since many are not needed.
      
      So overall this should be equivalent but slightly better and it allows us to drop the build scripts (See #83156 )
      
      One interesting note is determinism of `TraitTypeId` and `ValueTypeId`. Previously  the values assigned were determined by the order of registrations in the build script.  With inventory they are registered in an undefined order (im guessing it is deterministic based on linker input order, but inventory makes no guarantees).  As far as i can tell, this does not matter, but in the interest of determinism i have sorted the values based on their names.  In the future we can use this determinism to optimize persistence
      
      ## Why?
      
      By colocating registration with the proc macros we can simplify the registration logic.  Switching to 'pull' based registration also simplifies a number of datastructures and allows us to drop some RWLocks
      
      ## Interesting consequences
      
      All the global type names are changing, dropping the `@TODO::`
      
      This `TODO` was a placeholder for a content hash of the current crate.  This is to support a hypothetical idea where at least some of the persistent cache could survive turbopack updates.  However based on team discussions we don't currently see a clear solution here.  If we want to do this in the future i think we could still leverage hashes in names but we would need to compose them in a different way (e.g. `build.rs` script sets an `env` var that the proc macro reads with the `env!` macro)
      099b1e35
    • Benjamin Woodruff's avatar
      Turbopack: Implement `TaskInput` for `ReadRef`, use a `ReadRef` input for… · 10e70b61
      Benjamin Woodruff authored
      Turbopack: Implement `TaskInput` for `ReadRef`, use a `ReadRef` input for `AssetIdent::new` (#83356)
      
      @lukesandberg and I noticed this opportunity.
      
      ### Hypothesis
      
      `AssetIdent::new` is a dummy constructor function used for caching value with unique `Vc`s. It is called frequently. The `AssetIdent` struct is large and contains three different `Vec`s, so it's likely non-trivial to clone.
      
      - When an uncached turbo task function is called, its argument is boxed and cloned once to be used as cache key. There's two copies of the argument at this point: A cache key, and a local copy for the about-to-be-executed function.
      - This function immediately constructs a cell, which moves its local copy of the argument into a `triomphe::Arc`, preserving it.
      
      So we end up with two persistent copies of the task input. This doesn't matter when the struct is small and cheap to clone, but it does matter here.
      
      The solution is to wrap `AssetIdent` in a `ReadRef` before passing it to a `turbo_tasks::function`. `ReadRef` does not impact equality (defers to inner value), it's cheap to clone, and `ReadRef::cell` provides a fast-path that re-uses the inner `triomphe::Arc` for the newly constructed cell:
      
      https://github.com/vercel/next.js/blob/5cf762235a1e9f02443f45a69a7afd1880317f77/turbopack/crates/turbo-tasks/src/read_ref.rs#L247-L262
      
      ### Tradeoffs
      
      If there's a cache hit, this approach constructs and throws away a temporary `Arc`, that the original implementation wouldn't. So in cases where there's a very high cache hit rate, or where the `Clone` would've been very cheap, this may come with a CPU time tradeoff. That doesn't seem to be the case here (cache hits are about 30%).
      
      ### Rough Benchmark
      
      Does not save a measurable amount of memory
      
      ```
      cargo run --release -p next-build-test -- generate ~/shadcn-ui/apps/v4/ > ~/shadcn-ui/apps/v4/project_options.json
      cd ~/shadcn-ui/apps/v4/
      pnpm i
      command time -v ~/next.js/target/release/next-build-test run sequential 1 1 '/sink'
      ```
      
      maxrss (kbytes) before (5 runs):
      ```
      2355284
      2325432
      2320960
      2281920
      2385740
      ```
      
      maxrss (kbytes) after (5 runs):
      ```
      2361084
      2323468
      2364040
      2353300
      2388904
      ```
      
      This shows it's slightly worse, but only 1%, so it's easily within margin-of-error:
      
      <img src="https://app.graphite.dev/user-attachments/assets/a1a7e1c8-bc05-4262-91d8-c3590f5a1253.png" width=500>
      10e70b61
  2. 02 Sep, 2025 15 commits