1. 08 Sep, 2022 15 commits
  2. 07 Sep, 2022 14 commits
  3. 06 Sep, 2022 9 commits
    • Alex Castle's avatar
      Change sizes docs to use max-width in media query (#40290) · 6cc8dc38
      Alex Castle authored
      This PR updates the next/image and `next/future/image` sizes docs to use `max-width` in the `sizes` media query, for code style and consistency reasons.
      6cc8dc38
    • Alex Castle's avatar
      Change image sizes docs to use em instead of px (#40288) · 815abc5e
      Alex Castle authored
      This PR is a minor change to the image docs (`next/image` and `next/future/image`). The example sizes media queries are switched from `em` to `px` for readability.
      815abc5e
    • JJ Kasper's avatar
      Fix test hydration check in Safari 10.1 (#40285) · e8ff2738
      JJ Kasper authored
      This removes the optional chaining inside of the `executeAsync` as that
      is treated literally when passed to the browser and Safari 10.1 doesn't
      support optional chaining.
      
      fixes:
      https://github.com/vercel/next.js/runs/8213273664?check_suite_focus=true
      fixes:
      https://github.com/vercel/next.js/runs/8213237056?check_suite_focus=true
      e8ff2738
    • Steven's avatar
      Update `next/future/image` to support only `width` or only `height` (#40278) · d53e2f2f
      Steven authored
      This PR allows you to resize a statically imported image using only `width` or only `height`. For example:
      
      ```jsx
      import img from './img.jpg'
      <Image src={img} width="200" />
      ```
      
      Previously, you had to specify both or else the image aspect ratio would not be preserved.
      d53e2f2f
    • Tim Neutkens's avatar
      Add prefetch to new router (#39866) · 71ad0dd0
      Tim Neutkens authored
      Follow-up to #37551
      Implements prefetching for the new router.
      
      There are multiple behaviors related to prefetching so I've split them out for each case. The list below each case is what's prefetched:
      
      Reference:
      - Checkmark checked → it's implemented.
      - RSC Payload → Rendered server components.
      - Router state → Patch for the router history state.
      - Preloads for client component entry → This will be handled in a follow-up PR.
      - No `loading.js` static case → Will be handled in a follow-up PR.
      
      ---
      
      - `prefetch={true}` (default, same as current router, links in viewport are prefetched)
          - [x]  Static all the way down the component tree
              - [x] RSC payload
              - [x] Router state
              - [ ] preloads for the client component entry
          - [x]  Not static all the way down the component tree
              - [x]  With `loading.js`
                  - [x] RSC payload up until the loading below the common layout
                  - [x] router state
                  - [ ] preloads for the client component entry
              - [x]  No `loading.js` (This case can be static files to make sure it’s fast)
                  - [x] router state
                  - [ ] preloads for the client component entry
      - `prefetch={false}`
          - [x]  always do an optimistic navigation. We already have this implemented where it tries to figure out the router state based on the provided url. That result might be wrong but the router will automatically figure out that
      
      ---
      
      In the first implementation there is a distinction between `hard` and `soft` navigation. With the addition of prefetching you no longer have to add a `soft` prop to `next/link` in order to leverage the `soft` case. 
      
      A heuristic has been added that automatically prefers `soft` navigation except when navigating between mismatching dynamic parameters.
      
      An example:
      - `app/[userOrTeam]/dashboard/page.js` and `app/[userOrTeam]/dashboard/settings/page.js`
        - `/tim/dashboard` → `/tim/dashboard/settings` = Soft navigation 
        - `/tim/dashboard` → `/vercel/dashboard` = Hard navigation
        - `/vercel/dashboard` → `/vercel/dashboard/settings` = Soft navigation
        - `/vercel/dashboard/settings` -> `/tim/dashboard` = Hard navigation
      
      ---
      
      While adding these new heuristics some of the tests started failing and I found some state bugs in `router.reload()` which have been fixed. An example being when you push to `/dashboard` while on `/` in the same transition it would navigate to `/`, it also wouldn't push a new history entry. Both of these cases are now fixed:
      
      ```
      React.startTransition(() => {
        router.push('/dashboard')
        router.reload()
      })
      ```
      
      ---
      
      While debugging the various changes I ended up debugging and manually diffing the cache and router state quite often and was looking at a way to automate this. `useReducer` is quite similar to Redux so I was wondering if Redux Devtools could be used in order to debug the various actions as it has diffing built-in. It took a bit of time to figure out the connection mechanism but in the end I figured out how to connect `useReducer`, a new hook `useReducerWithReduxDevtools` has been added, we'll probably want to put this behind a compile-time flag when the new router is marked stable but until then it's useful to have it enabled by default (only when you have Redux Devtools installed ofcourse).
      
      > ⚠️ Redux Devtools is only connected to take incoming actions / state. Time travel and other features are not supported because the state sent to the devtools is normalized to allow diffing the maps, you can't move backward based on that state so applying the state is not connected.
      
      Example of the integration:
      
      <img width="1912" alt="Screen Shot 2022-09-02 at 10 00 40" src="https://user-images.githubusercontent.com/6324199/188637303-ad8d6a81-15e5-4b65-875b-1c4f93df4e44.png">
      71ad0dd0
    • Shu Ding's avatar
      Improved route resolution in next-app-loader (#40109) · 5f95b6b0
      Shu Ding authored
      This PR implements the logic to make next-app-loader able to match multiple routes.
      
      The app loader is refactored to construct the tree recursively instead of within a loop, as there could be multiple branches. Similarly, when entering a new layout level or branch, we resolve both the slot name (defaults to `"children"`) and the segment.
      
      In order to make that work, the loader has to know all matched app paths. This is passed in as the `appPaths` loader option, which is gathered when creating the entrypoint.
      
      ## 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 `pnpm lint`
      - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
      Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      5f95b6b0
    • sumiren's avatar
      docs: update get-static-paths.md (#40205) · 5c2faad3
      sumiren authored
      I found that `fallback: true` behaves like `fallback: blocking` when client-side page transition, but document doesn't mention the behavior.
      I tried following.
      
      * created a SSG page which has getStaticPaths and getStaticProps, and the getStaticProps is too slow(something like `await setTimeout(10000)`)
      * `next build && next start`, not `next dev`
      * tried page reload and client-side page transition both
      
      getServerSideProps document explains about client-side page transition.
      https://nextjs.org/docs/basic-features/data-fetching/get-server-side-props#when-does-getserversideprops-run
      
      On the other hand, getStaticPaths didn't explain this behavior, so I added it.
      
      
      
      ## 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 `pnpm lint`
      - [x] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
      5c2faad3
    • Balázs Orbán's avatar
      fix(cli): delete temp file after extraction (#40259) · fa08a177
      Balázs Orbán authored
      Follow-up on the review comment https://github.com/vercel/next.js/pull/40182#discussion_r963036314 since the PR was merged.
      
      ## 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 `pnpm lint`
      - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
      fa08a177
    • Balázs Orbán's avatar
      fix: apply default export interop to `next/config` (#40224) · 8698b492
      Balázs Orbán authored
      The `next/config` code generated is incompatible with the `type: "module"` setting in `package.json`. This PR makes sure that we append the same interop code to the output `shared/lib/runtime-config` file as other re-exported modules:
       https://github.com/vercel/next.js/blob/93830bf04f1f40e1996f21a3534b6010d9ef3c0c/packages/next/taskfile-swc.js#L124-L128
      
      Fixes #40159
      
      ## 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 `pnpm lint`
      - [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
      8698b492
  4. 05 Sep, 2022 2 commits