1. 23 Oct, 2022 3 commits
  2. 22 Oct, 2022 15 commits
  3. 21 Oct, 2022 5 commits
    • Steven's avatar
      Update `next-image-experimental` codemod to handle loaders (#41633) · 6fb9a192
      Steven authored
      As a follow up to #41585, this PR updates the `next-image-experimental`
      codemod to change `loader` to `loaderFile`.
      6fb9a192
    • Tim Neutkens's avatar
      BREAKING CHANGE: Remove React 17 (#41629) · 14c93768
      Tim Neutkens authored
      Next.js 13 will require React 18.
      
      In this PR I've only updated the peerDependency and removed the test runs in GH actions. Further cleanup will follow later, this allows us to remove the code supporting it later.
      
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      Co-authored-by: 's avatarJiachi Liu <4800338+huozhi@users.noreply.github.com>
      14c93768
    • Steven's avatar
      Add support for `images.loaderFile` config (#41585) · 7102050e
      Steven authored
      This PR adds a new configure property, `images.loaderFile` that allow
      you to define a path to a file with an exported image loader function.
      
      This is useful when migrating from `next/legacy/image` to `next/image`
      because it lets you configure the loader for every instance of
      `next/image` once, similar to the legacy "built-in loaders".
      7102050e
    • Damien Simonin Feugas's avatar
      feat(edge): adds AsyncLocalStorage support to the edge function sandbox (#41622) · 6f43c90b
      Damien Simonin Feugas authored
      
      
      ## 📖  Feature
      
      Adds `AsyncLocalStorage` as a global variable to any edge function (middleware, Edge API routes).
      Falls back to Node.js' implementation. 
      
      ## 🧪 How to test
      
      1. `pnpm build`
      2. `pnpm testheadless --testPathPattern async-local`
      6f43c90b
    • Hannes Bornö's avatar
      Root layout head not required (#41621) · bdc53ef6
      Hannes Bornö authored
      Remove head as required in root layout.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing
      doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      bdc53ef6
  4. 20 Oct, 2022 17 commits
    • Steven's avatar
      Add test fixture `e2e/app-dir/next-image` (#41609) · 001a67df
      Steven authored
      This PR adds a test fixture `e2e/app-dir/next-image` to ensure `next/image` works with the `app` dir.
      001a67df
    • Ismael's avatar
      remove next/future/image ref (#41610) · 75aab126
      Ismael authored
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      75aab126
    • Shu Ding's avatar
      Fix missing JSON.stringify in loader (#41599) · 6bd789da
      Shu Ding authored
      We can't directly put `filePath` in the generated code as it can contain in valid JavaScript string such as `"\2"` in `"C:\Users\foo\2022\bar.js"`. Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Deprecated_octal
      
      Reported issue in Next.js:
      
      ![image](https://user-images.githubusercontent.com/3676859/196962933-0a3bf4b4-9142-426f-9ac5-bdcfb3c5ebf0.png)
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      6bd789da
    • Janicklas Ralph's avatar
      Updating size-adjust calculation (#41406) · 56b097a8
      Janicklas Ralph authored
      <!--
      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 that you're making:
      
      
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing
      doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      -->
      
      Updating size-adjust calc to use azAvgWidth instead of xAvgCharWidth
      Co-authored-by: 's avatarHannes Bornö <hannes.borno@vercel.com>
      Co-authored-by: 's avatarBalázs Orbán <info@balazsorban.com>
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      56b097a8
    • Hannes Bornö's avatar
      Font loader types (#41591) · 77ba4a86
      Hannes Bornö authored
      Make local and google font loaders more similar. Both should define `weight: string` and `style: string`.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      77ba4a86
    • Shu Ding's avatar
      Add transpilePackages option (#41583) · 138a7bfd
      Shu Ding authored
      This is a new experimental feature to specify a list of packages (or
      subpaths in packages, like `pkg/src/index.ts`), to opt-in Next.js
      transpilation in the server build.
      
      cc @jescalan 
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR.
      - [ ] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing
      doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      138a7bfd
    • Jimmy Lai's avatar
      perf: refactor path logic in router + add LRU cache (#41365) · 6d297130
      Jimmy Lai authored
      I'm investigating the runtime perf of the node server and this was one of the hot spot I stumbled upon.
      
      This diff:
      - refactors getPagePath to not throw when it doesn't find a path: this function is used to check if a path exists, we don't want that kind of overhead there
      - adds a LRU cache to cache the result of the evaluation
      
      Results:
      
      before:
      > 110k requests in 11.01s, 285 MB read
      
      after
      >135k requests in 11.01s, 348 MB read
      
      on an autocannon run
      
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      6d297130
    • Yohann MARTZOLFF's avatar
    • Balázs Orbán's avatar
      2cafe367
    • Tim Neutkens's avatar
      f7fecf00
    • Hannes Bornö's avatar
      Full remaining path in selected layout segment (#41562) · d7348c4e
      Hannes Bornö authored
      Make `useSelectedLayoutSegment` include the remaining segments from the current level to the leaf node.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      d7348c4e
    • Hannes Bornö's avatar
      Check root layout change on client (#41475) · a5d53155
      Hannes Bornö authored
      Moves the logic that checks if there's a new root layout to the client.
      Adds test for static and dynamic catchall.
      
      Related: #41457
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing
      doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      a5d53155
    • Seiya Nuta's avatar
      Support overriding request headers in middlewares (#41380) · 765791a6
      Seiya Nuta authored
      
      
      This PR adds a feature in middleware to add, modify, or delete request headers. This feature is quite useful to pass data from middleware to Serverless/Edge API routes.
      
      ### Questions for Reviewers
      
      - Should we deny modifying standard request headers like `Transfer-Encoding`?
      - Should we throw an error if the header is too large? Real-world HTTP servers will accept up to only 8KB - 32KB.
      
      ### New APIs
      
      Adds a new option `request.headers` to the `MiddlewareResponseInit` parameter in `NextResponse.next()` and `NextResponse.rewrite()`. It's a [`Header`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) object holding *all* request headers. Specifically:
      
      ```ts
      interface MiddlewareResponseInit extends ResponseInit {
        request?: {
          headers?: Headers
        }
      }
      ```
      
      ### Example
      
      ```ts
      // pages/api/hello.ts
      export default (req, res) => {
        const valueFromMiddleware = req.headers['x-hello-from-middleware']
        return res.send(valueFromMiddleware)
      }
      
      // middleware.ts
      import { NextRequest, NextResponse } from 'next/server'
      
      export default function middleware(request: NextRequest) {
        // Clone request headers
        const headers = new Headers(request.headers);
        // Add a new request header
        headers.set('x-hello-from-middleware', 'foo');
        // Delete a request header from the client
        headers.delete('x-from-client');
      
        const resp = NextResponse.next({
          // New option `request.headers` which accepts a Headers object
          // overrides request headers with the specified new ones.
          request: {
            headers
          }
        });
      
        // You can still set *response* headers to the client, as before.
        resp.headers.set('x-hello-client', 'bar');
        return resp;
      }
      ```
      
      ### New middleware headers
      
      - `x-middleware-override-headers`: A comma separated list of *all* request header names. Headers not listed will be deleted.
      - `x-middleware-request-<name>`: A new value for the header `<name>`.
      
      ## Related Discussions
      
      - https://github.com/vercel/next.js/discussions/31188
      - https://github.com/vercel/next.js/discussions/39300
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [ ] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [x] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      765791a6
    • Shu Ding's avatar
      Update error message for invalid react-dom/server imports (#41582) · b0db95ff
      Shu Ding authored
      Related discussion:
      https://vercel.slack.com/archives/C043ANYDB24/p1666208186363099?thread_ts=1664676119.265829&cid=C043ANYDB24.
      
      Tl;dr: RSC already renders and serializes things dynamically, there is
      no need to manually do that in RSC and embed them via
      dangerouslySetInnerHTML.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing
      doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      b0db95ff
    • Marcial Cambronero's avatar
      Small change to note `<Link />` executes server methods (#41577) · cec9d02d
      Marcial Cambronero authored
      I stumbled upon a lack of clarity when using `<Link />` where I believed it didn't execute the server methods before navigation. This change makes it a bit more clear
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      Co-authored-by: 's avatarBalázs Orbán <18369201+balazsorban44@users.noreply.github.com>
      Co-authored-by: 's avatarJJ Kasper <22380829+ijjk@users.noreply.github.com>
      cec9d02d
    • Shu Ding's avatar
      Improve server bundling strategy (#41584) · 4adab6a6
      Shu Ding authored
      This PR adds a list of popular packages that should always opt-out
      bundling in the server layer.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing
      doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      4adab6a6
    • Shu Ding's avatar
      Update page config APIs (#41580) · bad909e4
      Shu Ding authored
      This PR updates app configurations from `export const config = { ... }`
      to be directly exported.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Feature
      
      - [ ] Implements an existing feature request or RFC. Make sure the
      feature request has been accepted for implementation before opening a
      PR.
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have a helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `pnpm lint`
      - [ ] The "examples guidelines" are followed from [our contributing
      doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      bad909e4