1. 27 Apr, 2022 12 commits
  2. 26 Apr, 2022 12 commits
  3. 25 Apr, 2022 10 commits
    • Tim Neutkens's avatar
      Rework <Link> behavior (backwards compatible) (#36436) · 489e65ed
      Tim Neutkens authored
      Fixes https://github.com/vercel/next.js/discussions/32233
      
      ⚠ If you're looking at this PR please read the complete description including the part about incremental adoption.
      
      ## TLDR:
      
      Official support for `<Link href="/about">About</Link>` / `<Link href="/about"><CustomComponent /></Link>` / `<Link href="/about"><strong>About</strong></Link>` where `<Link>` always renders `<a>` without edge cases where it doesn’t render `<a>`. You'll no longer have to put an empty `<a>` in `<Link>` with this enabled.
      
      ## Full context
      
      ### Changes to `<Link>`
      
      - Added an `legacyBehavior` prop that defaults to `true` to preserve the defaults we have today, this will allow to run a codemod on existing codebases to move them to the version where `legacyBehavior` becomes `false` by default
      - When using the new behavior `<Link>` always renders an `<a>` instead of having `React.cloneElement` and passing props onto a child element
      - When using the new behavior props that can be passed to `<a>` can be passed to `<Link>`. Previously you could do something like `<Link href="/somewhere"><a target="_blank">Download</a></Link>` but with `<Link>` rendering `<a>` it now allows these props to be set on link. E.g. `<Link href="/somewhere" target="_blank"></Link>` / `<Link href="/somewhere" className="link"></Link>`
      
      ### Incremental Adoption / Codemod
      
      The main reason we haven't made these changes before is that it breaks pretty much all Next.js apps, which is why I've been hesitant to make this change in the past. I've spent a bunch of time figuring out what the right approach is to rolling this out and ended up with an approach that requires existing apps to run a codemod that automatically opts their `<Link>` usage into the old behavior in order to keep the app functioning.
      
      This codemod will auto-fix the usage where possible. For example: 
      
      - When you have `<Link href="/about"><a>About</a></Link>` it'll auto-fix to `<Link href="/about">About</Link>`
      - When you have `<Link href="/about"><a onClick={() => console.log('clicked')}>About</a></Link>` it'll auto-fix to `<Link href="/about" onClick={() => console.log('clicked')}>About</Link>`
      - For cases where auto-fixing can't be applied the `legacyBehavior` prop is added. When you have `<Link href="/about"><Component /></Link>` it'll transform to `<Link href="/about" legacyBehavior><Component /></Link>` so that your app keeps functioning using the old behavior for that particular link. It's then up to the dev to move that case out of the `legacyBehavior` prop.
      
      
      **This default will be changed in Next.js 13, it does not affect existing apps in Next.js 12 unless opted in via `experimental.newLinkBehavior` and running the codemod.**
      
      Some code samples of what changed:
      
      ```jsx
      const CustomComponent = () => <strong>Hello</strong>
      
      // Legacy behavior: `<a>` has to be nested otherwise it's excluded
      
      // Renders: <a href="/about">About</a>. `<a>` has to be nested.
      <Link href="/about">
        <a>About</a>  
      </Link>
      
      // Renders: <strong onClick={nextLinkClickHandler}>Hello</strong>. No `<a>` is included.
      <Link href="/about">
        <strong>Hello</strong>
      </Link>
      
      
      // Renders: <strong onClick={nextLinkClickHandler}>Hello</strong>. No `<a>` is included.
      <Link href="/about">
        <CustomComponent />
      </Link>
      
      // --------------------------------------------------
      // New behavior: `<Link>` always renders `<a>`
      
      // Renders: <a href="/about">About</a>. `<a>` no longer has to be nested.
      <Link href="/about">
        About
      </Link>
      
      // Renders: <a href="/about"><strong>Hello</strong></a>. `<a>` is included.
      <Link href="/about">
        <strong>Hello</strong>
      </Link>
      
      // Renders: <a href="/about"><strong>Hello</strong></a>. `<a>` is included.
      <Link href="/about">
        <CustomComponent />
      </Link>
      ```
      
      ---
      
      
      ## Feature
      
      - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
      - [x] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [x] Errors have helpful link attached, see `contributing.md`
      Co-authored-by: 's avatarJJ Kasper <22380829+ijjk@users.noreply.github.com>
      489e65ed
    • Naoyuki Kanezawa's avatar
      Fix to remove webpack message per error (#36452) · b264064a
      Naoyuki Kanezawa authored
      Remove the webpack breaking change message per error since it can be contained in all errors and the current implementation causes to truncate other error messages
      
      Follow up for https://github.com/vercel/next.js/pull/36190
      
      ## Bug
      
      - [x] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have helpful link attached, see `contributing.md`
      b264064a
    • Luis Alvarez D's avatar
      Update usage paragraph of next/script `onLoad` (#36453) · ff140a72
      Luis Alvarez D authored
      Changing the paragraph to not include `beforeInteractive` as one of the possible use cases of `onLoad`.
      
      *Update:* Added docs for `onError` in the API reference of `next/script`.
      
      @housseindjirdeh does `onError` also has the same limitation or is this only for `onLoad`?
      
      Closes https://github.com/vercel/next.js/issues/33402
      
      ## 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
      - [x] Documentation added
      - [ ] Telemetry added. In case of a feature if it's used or not.
      - [ ] Errors have helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [x] Make sure the linting passes by running `yarn lint`
      ff140a72
    • Alex's avatar
      Grammar Changed features and API to features and it's API (#36396) · adcd9143
      Alex authored
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have 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 helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [x] Make sure the linting passes by running `yarn lint`
      Co-authored-by: 's avatarJJ Kasper <22380829+ijjk@users.noreply.github.com>
      adcd9143
    • Marzouq's avatar
      added with-react-foundation example (#36375) · 1f0f2c0a
      Marzouq authored
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have 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 helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `yarn lint`
      1f0f2c0a
    • Jordan Baron's avatar
      Add pnpm-debug (#36394) · b6f168bd
      Jordan Baron authored
      b6f168bd
    • Naoyuki Kanezawa's avatar
      Do not polyfill node built-in modules on edge functions (#36190) · a6282566
      Naoyuki Kanezawa authored
      As the title. This is intended to be applied on both middleware and edge functions.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [ ] Errors have 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 helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `yarn lint`
      Co-authored-by: 's avatarJiachi Liu <4800338+huozhi@users.noreply.github.com>
      a6282566
    • JJ Kasper's avatar
      Revert "Change getStaticProps to getStaticPaths in getStaticPaths docs" (#36425) · e8320075
      JJ Kasper authored
      This change was un-necessary and `getStaticProps` was correct here so this reverts the change. 
      
      Reverts vercel/next.js#36403
      e8320075
    • Marzouq's avatar
      updated with-rebass dependencies (#36416) · a0b70067
      Marzouq authored
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] Errors have 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 helpful link attached, see `contributing.md`
      
      ## Documentation / Examples
      
      - [x] Make sure the linting passes by running `yarn lint`
      a0b70067
    • Nico's avatar
      chore(create-next-app): fix pnpm create step (#36398) · 963549e9
      Nico authored
      Small copy-paste mistake with the readme of create-next-app on the steps for using PNPM to execute.
      
      ## Documentation / Examples
      
      - [ ] Make sure the linting passes by running `yarn lint`
      963549e9
  4. 23 Apr, 2022 1 commit
  5. 22 Apr, 2022 5 commits