1. 06 Apr, 2023 25 commits
  2. 05 Apr, 2023 15 commits
    • JJ Kasper's avatar
      v13.2.5-canary.31 · be2237fc
      JJ Kasper authored
      be2237fc
    • Jiachi Liu's avatar
      Create unique route path for og under group routes (#47985) · c0751e8c
      Jiachi Liu authored
      ### What
      
      When using dynamic metadata image rouets (such as `opengraph-image.js`)
      under group routes, the generated urls were still normalized. In this
      case it might have conflicts with those ones not under group routes. For
      instance `app/(post)/opengraph-image.js` could have same url with
      `/app/opengraph-image.js`. In reality we want them to be different
      route, unlike layout or pages.
      
      ### How
      
      So when we found `()` or `@` signs from the metadata image urls, we'll
      generate a unqiue suffix (`-\d{6}`) and append to the generated url. So
      they can be isolated from the ones are not under special convention
      routes.
      
      Closes NEXT-937
      c0751e8c
    • Jiachi Liu's avatar
      Fix metadata nested twitter props rendering (#47972) · 7af9c439
      Jiachi Liu authored
      For twitter and og image nested properties we should render them as
      snake case according to [og spec](https://ogp.me/) and [twitter card
      docs](https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started).
      For typing we keep them as camel case and then convert them to snake
      case during render
      
      This issue is reported in #47960 that user thinks the types are
      incorrect, but turns out twitter metadata didn't render it correctly
      
      Closes #47960
      7af9c439
    • Tim Neutkens's avatar
      Check for null before reading value in useParams (#47875) · a94de4c7
      Tim Neutkens authored
      Ensures the `null` value is checked instead of destructuring the value
      as it caused an error.
      Also added a test to check for `useParams` in `pages`.
      
      <!-- Thanks for opening a PR! Your contribution is much appreciated.
      To make sure your PR is handled as smoothly as possible we request that
      you follow the checklist sections below.
      Choose the right checklist for the change(s) that you're making:
      
      ## For Contributors
      
      ### Improving Documentation or adding/fixing Examples
      
      - The "examples guidelines" are followed from our contributing doc
      https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
      - Make sure the linting passes by running `pnpm build && pnpm lint`. See
      https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
      
      ### Fixing a bug
      
      - Related issues linked using `fixes #number`
      - Tests added. See:
      https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      ### Adding a feature
      
      - Implements an existing feature request or RFC. Make sure the feature
      request has been accepted for implementation before opening a PR. (A
      discussion must be opened, see
      https://github.com/vercel/next.js/discussions/new?category=ideas)
      - Related issues/discussions are linked using `fixes #number`
      - e2e tests added
      (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
      - Documentation added
      - Telemetry added. In case of a feature if it's used or not.
      - Errors have a helpful link attached, see
      https://github.com/vercel/next.js/blob/canary/contributing.md
      
      
      
      ## For Maintainers
      
      - Minimal description (aim for explaining to someone not on the team to
      understand the PR)
      - When linking to a Slack thread, you might want to share details of the
      conclusion
      - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
      - Add review comments if necessary to explain to the reviewer the logic
      behind a change
      
      ### What?
      
      ### Why?
      
      ### How?
      
      Closes NEXT-
      Fixes #
      
      -->
      
      ---------
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      a94de4c7
    • Justin Ridgewell's avatar
      turbopack: add vary header to app routes (#47946) · fde065b9
      Justin Ridgewell authored
      Next.js adds a `Vary: RSC, Next-Router-State-Tree, Next-Router-Prefetch`
      to app routes for both rendering and flight requests. Without this, the
      browser can mistakenly serve the flight request to the app render, and
      vice versa.
      
      This only adds `Vary: RSC` for the moment, I'm not sure what the others
      are used for. We also don't add a `Cache-Control: max-age=0` header, but
      I'm not sure if that's necessary either.
      
      Fixes NEXT-657
      fix #45595
      fde065b9
    • JJ Kasper's avatar
      Update search params/route params handling on deploy (#47930) · e3e22f5b
      JJ Kasper authored
            This ensures we prefix the dynamic route params in the query so that
      they can be kept separate from actual query params from the initial
      request.
      
      Fixes: https://github.com/vercel/next.js/issues/43139
        
      e3e22f5b
    • Wyatt Johnson's avatar
      Unify Request types (#47884) · 1fbbba6f
      Wyatt Johnson authored
      This serves to start the transition of replacing the following:
      
      - Replace `BaseNextRequest`, `WebNextRequest`, and `NodeNextRequest`
      with `NextRequest`
      - Replace `BaseNextResponse`, `WebNextResponse`, and `NodeNextResponse`
      with `Response`
      
      This will currently only apply to app routes, enabling the following:
      
      ```ts
      ////////////////////////////////////////////////////////////////////////////////
      // Use `Request` and `Response`
      ////////////////////////////////////////////////////////////////////////////////
      
      import { NextRequest, NextResponse } from 'next/server'
      
      export function GET(request: Request): Response {
        return new Response(
          JSON.stringify({
            hello: request.headers.get('user-agent'),
          }),
          { headers: { 'content-type': 'application/json' } }
        )
      }
      
      ////////////////////////////////////////////////////////////////////////////////
      // Use `NextRequest` and `NextResponse`
      ////////////////////////////////////////////////////////////////////////////////
      
      import { NextRequest, NextResponse } from 'next/server'
      
      export function GET(request: NextRequest): NextResponse {
        return NextResponse.json({ hello: request.headers.get('user-agent') })
      }
      
      ////////////////////////////////////////////////////////////////////////////////
      // Use `NextRequest` and `Response`
      ////////////////////////////////////////////////////////////////////////////////
      
      import { NextRequest, NextResponse } from 'next/server'
      
      // `NextRequest` extends `Request`.
      export function GET(request: NextRequest): Response {
        return new Response(
          JSON.stringify({ hello: request.headers.get('user-agent') }),
          { headers: { 'content-type': 'application/json' } }
        )
      }
      
      ////////////////////////////////////////////////////////////////////////////////
      // Use `NextRequest`, `NextResponse`, and `Response`
      ////////////////////////////////////////////////////////////////////////////////
      
      import { NextRequest, NextResponse } from 'next/server'
      
      export function GET(request: NextRequest): Response {
        // `NextResponse` extends `Response`.
        return NextResponse.json({ hello: request.headers.get('user-agent') })
      }
      
      ////////////////////////////////////////////////////////////////////////////////
      // Use `Request` and `NextResponse`
      ////////////////////////////////////////////////////////////////////////////////
      
      import { NextRequest, NextResponse } from 'next/server'
      
      export function GET(request: Request): NextResponse {
        return NextResponse.json({ hello: request.headers.get('user-agent') })
      }
      
      ```
      
      fix NEXT-713
      1fbbba6f
    • Jan Kaifer's avatar
      Auto-restart dev server when next.config.js changes (#47912) · 2c9b484f
      Jan Kaifer authored
      This is a follow-up PR on https://github.com/vercel/next.js/pull/46577
      after it got nasty conflicts.
      
      Basically, just restart `dev` when `next.config.ts` it will just restart
      instead of printing that message asking you to restart.
      fix NEXT-639
      2c9b484f
    • JJ Kasper's avatar
      Fix app metadata in edge runtime (#47941) · af694f66
      JJ Kasper authored
      Seems edge runtime started failing for app paths from `path` being added
      in https://github.com/vercel/next.js/pull/47829 so this updates to use
      the isomorphic version instead and adds a regression test.
      
      Fixes NEXT-866
      af694f66
    • JJ Kasper's avatar
      Increase CI test timeout (#47973) · df9de3de
      JJ Kasper authored
      Seems builds in CI have been timing out with the 90s limit and with the
      shared concurrency of the limited CPUs additional time may be needed to
      avoid retrying un-necessarily.
      
      x-ref:
      https://github.com/vercel/next.js/actions/runs/4620023451/jobs/8170530943
      x-ref:
      https://github.com/vercel/next.js/actions/runs/4619675493/jobs/8168849370
      df9de3de
    • Jiachi Liu's avatar
      Fallback to localhost for metadataBase when it's used and missing (#47910) · 3f75387b
      Jiachi Liu authored
      [slack
      thread](https://vercel.slack.com/archives/C04G5LHAVAR/p1680106437791819?thread_ts=1680013412.588999&cid=C04G5LHAVAR)
      
      When `metadataBase` is missing and used for resolving og/tw image urls,
      we'll fallback to localhost for it to always safely resolve the url
      instead of erroring. Instead, we give a warning in console for which url
      is resolved but with fallback `metadataBase`.
      
      Once they found the warning and it's not expected, they need to update
      the `metadataBase` to a proper URL for giving the right domain.
      
      Another minor change is always resolve canonical with current pathname
      if it's a URL instance.
      Remove `resolveStringUrl` as it's not required anymore, the default
      `pathname` for `resolveUrl` is '', so no trailing slash needs to be
      removed
      3f75387b
    • Tobias Koppers's avatar
      add a warning when using implicit metadata (#47928) · a7837bd0
      Tobias Koppers authored
      ### What?
      
      add a warning until it's supported
      
      ### Why?
      
      to avoid unexpected behavior for the user when things are not working
      
      fixes WEB-840
      a7837bd0
    • Tobias Koppers's avatar
      avoid duplicated error output (#47954) · 3be9430e
      Tobias Koppers authored
      ### What?
      
      avoid including the error twice in the output
      
      ### Why?
      
      `.context()` already keeps the previous error, no need to include in the
      error message again
      3be9430e
    • Tobias Koppers's avatar
      Run bench tests as part of CI (#47849) · e643d52e
      Tobias Koppers authored
      ### What?
      
      enables the benchmark tests from turbopack again
      
      ### Why?
      
      It tests common scenarios like HMR
      
      fixes WEB-792
      
      ---------
      Co-authored-by: 's avatarAlex Kirszenberg <alex.kirszenberg@vercel.com>
      e643d52e
    • Shu Ding's avatar
      Vendor `react@experimental` under an `experimentalReact` flag (#47759) · 89b4605f
      Shu Ding authored
      Next.js includes various feature sets that depend on specific release
      channels of React. However, our current setup only includes the `next`
      channel of React, which restricts our ability to integrate with features
      available on the `experimental` channel.
      
      To address this limitation, this pull request introduces the following
      changes:
      - Vendors the `react@experimental` version, along with the corresponding
      `react-dom` and `scheduler` packages.
      - Modifies the `sync-react` script to also update the `experimental`
      channel and removes `--version` as they're always synced to the latest
      now.
      - Retains the default behavior of using the `next` channel in the
      `appDir` directory.
      - Adds an option to switch to the `experimental` channel by setting
      `experimental.experimentalReact: true` in the configuration.
      
      fix NEXT-926 ([link](https://linear.app/vercel/issue/NEXT-926))
      89b4605f