Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/next.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v12.2.4
Choose a base ref
...
head repository: vercel/next.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v12.2.5
Choose a head ref

Commits on Aug 5, 2022

  1. Fixed links to supabase examples (#39343)

    Corrected links to supabase examples in the `with-supabase-auth-realtime-db/README.md`
    
    ## 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
    - [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
    
    - [ ] 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)
    pthomas931 authored Aug 5, 2022
    Copy the full SHA
    b402787 View commit details
  2. Change invalid internal upstream image error code (#39334)

    fixes #39312
    this is more consistent with other errors
    an invalid image should cause a validation error and not a server error
    madmed88 authored Aug 5, 2022
    Copy the full SHA
    869a2fe View commit details
  3. Hoist styles for Route Announcer 📢 (#39331)

    Hi,
    
    - Remove inlined CSS style which have minor performance loss. And hoist it to top of the component.
    > Each time you inline an object, React re-creates a new reference to this object on every render. This causes components that receive this object to treat it as a referentially different one which have some performance pitfalls.
    
    
    _Extremely sorry if I made any mistakes :(_
    sanjaiyan-dev authored Aug 5, 2022
    Copy the full SHA
    d88fd14 View commit details
  4. test: ensure default output is correct (#39358)

    So we don't regress on issues like #39090, #35913, #34629, #33314, etc.
    
    Closes #35912
    
    ## 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)
    balazsorban44 authored Aug 5, 2022
    Copy the full SHA
    0571885 View commit details
  5. fix: wrong reference url for disableStaticImages (#39362)

    ## Minor Improvement
    - doc of `disableStaticImages` has an incorrect reference link.
    
    
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    DonghyukJacobJang and ijjk authored Aug 5, 2022
    Copy the full SHA
    9f2949f View commit details
  6. Examples/cms-wordpress migrate to TypeScript (#39250)

    ## Documentation / Examples
    
    Not sure that I need to provide type to all of components or not?
    Let me know if you want me to provide.
    - [x] Closes #38752
    - [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)
    chaiwattsw authored Aug 5, 2022
    Copy the full SHA
    5f483b9 View commit details
  7. Copy the full SHA
    442378d View commit details
  8. fix: skip resizing image if it's animated (#39325)

    We were resizing animated images when importing them, but we don't optimize images when they come from an upstream provider. For consistency, we can skip resizing for local animated images as well.
    
    Fixes #39317
    
    ## 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)
    balazsorban44 authored Aug 5, 2022
    Copy the full SHA
    d008f65 View commit details

Commits on Aug 6, 2022

  1. Fix catchall rewrites for _next/data routes (#39370)

    * Fix catchall rewrites for _next/data routes
    
    * update check
    ijjk authored Aug 6, 2022
    Copy the full SHA
    a679a1e View commit details
  2. Fix next/future/image alt text (#39366)

    In many browsers (other than Chrome), the `alt` text is visible while the image is loading. This causes a sense layout shift since you'll see a flash of text and then the image (although lighthouse measures 0 CLS, likely because Chrome doesn't have this problem). This PR updates `next/future/image` to hide the alt text, unless there is an error while loading the image in which case the `alt` text because relevant as the fallback.
    
    Example:
    
    <img width="115" alt="image" src="https://user-images.githubusercontent.com/229881/183128008-0660c50c-18aa-4e64-872e-ada9a652130f.png">
    
    Unfortunately, Safari also shows a border while lazy loading images and it cannot be styled.
    
    See upstream issue here: https://bugs.webkit.org/show_bug.cgi?id=243601
    styfle authored Aug 6, 2022
    Copy the full SHA
    59a01ec View commit details
  3. chore: upgrade example to Docker Compose v2 (#39372)

    Upgrade the README to use Docker Compose v2, which is faster and shipped by default with Docker Desktop since April.
    
    ## 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)
    dunglas authored Aug 6, 2022
    Copy the full SHA
    43a4a8e View commit details

Commits on Aug 7, 2022

  1. fix (examples): Changed the version of next-pwa (#39369)

    next-pwa verison 5.5.5 causes the app to [crash](shadowwalker/next-pwa#370). See issue #39224
    Changed the version to 5.5.4 and removed `^`.
    
    Fixes: #39383
    ahkhanjani authored Aug 7, 2022
    Copy the full SHA
    b1de1d1 View commit details
  2. refactor: add named export in next/server (#39381)

    ## Bug
    When using next/server in different environment ([vitest](https://vitest.dev/)), named import will have runtime error.
    
    ```tsx
    import { NextRequest } from 'next/server'
    // TypeError: NextRequest is not a constructor
    const request = new NextRequest()
    ```
    This is conflicted with current `server.d.ts` files.
    
    ## Alternative
    * reverte current `server.js` to esm, them compiled it to cjs.
    promer94 authored Aug 7, 2022
    Copy the full SHA
    dc13c12 View commit details
  3. fix(ts): More strict Redirect type (#38277)

    * fix(ts): More strict Redirect type
    
    * lint-fix
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    terrierscript and ijjk authored Aug 7, 2022
    Copy the full SHA
    3238352 View commit details
  4. Port 'with-static-export' example to TypeScript (#38268)

    The 'with-static-export' example is very useful but, if a developer wants to use TypeScript, converting it is nontrivial. There are some gotchas in the GetStaticProps/GetStaticPaths functions. This example should help jumpstart TS development for sites static generation.
    
    ## 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)
    
    
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    shawncal and ijjk authored Aug 7, 2022
    Copy the full SHA
    0d5a692 View commit details
  5. update examples/custom-server-fastify and replace depreaction (#38269)

    ## 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)
    
    
    Co-authored-by: Balázs Orbán <18369201+balazsorban44@users.noreply.github.com>
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    3 people authored Aug 7, 2022
    Copy the full SHA
    5910458 View commit details
  6. fix(next): dev server starting when importing a file using get-projec… (

    #38274)
    
    Fixes: #38232 
    Fixes: #36893
    
    Version [12.1.1-canary.5](https://github.com/vercel/next.js/releases/tag/v12.1.1-canary.5) introduced a bug, more specifically this PR: #34836
    
    The issue described in #38232 is that the following code starts both the dev and prod servers:
    ```js
    const start = require('next/dist/cli/next-start')
    start.nextStart()
    ```
    
    I searched a bit and found that `lib/get-project-dir.ts#getProjectDir()` now imports `bin/next.ts`
    
    https://github.com/vercel/next.js/blob/6b8e499c7bf13914cca92f9da1737d358133ee20/packages/next/lib/get-project-dir.ts#L3
    
    and it calls a CLI command via
    
    https://github.com/vercel/next.js/blob/6b8e499c7bf13914cca92f9da1737d358133ee20/packages/next/bin/next.ts#L137
    
    This `command` should not be defined, but it fallbacks to `defaultCommand`, which is `dev` (that explains why the dev server is also started)
    
    This PR moves the `cliCommand` types and `commands` variable to a new separate file instead of `bin/next.ts`, to avoid running a CLI command when we import any file that also imports `lib/get-project-dir.ts`
    
    Not sure how integration tests can be added for this issue, but feel free to tell me.
    
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    QuiiBz and ijjk authored Aug 7, 2022
    Copy the full SHA
    a720dbd View commit details
  7. Add runtime to PageConfig type (#37453)

    * Add runtime to PageConfig type
    
    * Add test case for runtime type
    
    * Apply suggestions from code review
    
    * dedupe type
    
    * fix import
    
    * fix lint
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    ykzts and ijjk authored Aug 7, 2022
    Copy the full SHA
    0796b6f View commit details
  8. fix: improve logging for _devPagesManifest.json loading failures (#38046

    )
    
    ## Bug
    
    - [x] Fixes #38047
    - ~[ ] Integration tests added: do you want them added for such an unusual edge case?~ [Comment below: skipping](#38046 (comment))
    - [x] Errors have helpful link attached, see `contributing.md`: ~I'll wait until this approach & error message are confirmed before thinking more deeply on how to explain the error~
    
    Sending a draft PR as reference ahead of time. 🙂 
    
    Doesn't resolve the root issue of why `_devPagesManifest.json` might fail to load. But does improve the log for when it happens. I'd suggest applying this same fix to `_devMiddlewareManifest.json` too.
    
    <table>
    <thead>
    <tr>
    <th></th>
    <th>Before</th>
    <th>After</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <th>Console</th>
    <td>
    <pre>
    <code>
    Failed to fetch devPagesManifest TypeError: Failed to fetch
        at PageLoader.getPageList (page-loader.js?e87a:30:53)
        at _callee$ (router.js?8684:955:45)
        at ...
    </code>
    </pre>
    <pre>
    <code>
    router.js?8684:1319 Uncaught (in promise) TypeError: Cannot \
    read properties of undefined (reading 'includes')
        at resolveDynamicRoute (router.js?8684:1319:16)
        at _callee$
        at ...
    </code>
    </pre>
    </td>
    <td>
    <pre>
    <code>
    Failed to fetch devPagesManifest: TypeError: Failed to fetch
        at PageLoader.getPageList (page-loader.js?e87a:30:53)
        at _callee$ (router.js?8684:955:45)
        at ...
    </code>
    </pre>
    </td>
    </tr>
    <tr>
    <th>Visual</th>
    <td><img alt="Screenshot of a Next.js runtime error: TypeError: Cannot read properties of undefined (reading 'includes')" src="https://user-images.githubusercontent.com/3335181/175854728-8d5c2051-1229-4da7-8af1-fc95236befae.png" /></td>
    <td><img alt="Screenshot of a Next.js runtime error: Error: Failed to fetch _devPagesManifest.json. Is something blocking that network request?" src="https://user-images.githubusercontent.com/3335181/175854774-07895846-1a1c-4bb8-bf57-fa696b8c6ba4.png" /></td>
    </tr>
    </tbody>
    </table>
    JoshuaKGoldberg authored Aug 7, 2022
    Copy the full SHA
    963585a View commit details

Commits on Aug 8, 2022

  1. Allow custom path for preview mode cookies (#38313)

    * Allow custom path for preview mode cookies
    
    * update params order and tests
    
    * update tests
    
    * fix tests and update docs
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    lucasassisrosa and ijjk authored Aug 8, 2022
    Copy the full SHA
    a5029e9 View commit details
  2. Fix removing whitespacing in dev overlay (#28277)

    ## Bug
    
    - [x] Related issues linked using `fixes #number`
    
    fixes #14434 
    
    Before
    ![image](https://user-images.githubusercontent.com/31622972/130001431-392efc66-69b3-47b5-802a-251a545983fd.png)
    
    After
    ![image](https://user-images.githubusercontent.com/31622972/130001455-f553c977-c64b-43da-8e27-b513c6ea4179.png)
    
    
    
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    dikwickley and ijjk authored Aug 8, 2022
    Copy the full SHA
    8ddcc6a View commit details
  3. Copy the full SHA
    4da09da View commit details
  4. Add yarn 2 Setup Files to Valid Files for create-next-app (#30936)

    * added yarn 2 based files/dirs to valid files
    
    * remove package.json
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    sicarius97 and ijjk authored Aug 8, 2022
    Copy the full SHA
    b30ae64 View commit details
  5. Fix emotion shouldForwardProp options breaks component selectors (#39390

    )
    
    fixes #38291
    
    
    
    ## Bug
    
    - [x] 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)
    Brooooooklyn authored Aug 8, 2022
    Copy the full SHA
    4264408 View commit details
  6. next/image imgix loader can use multiple auto params (#34808)

    fix: imgixLoader can use multiple auto params
    FourwingsY authored Aug 8, 2022
    Copy the full SHA
    160da6b View commit details
  7. Adds eslint-plugin-eslint-plugin to ensure eslint-plugin-next rul…

    …es follow ESLint rule best practices along with enforcing some consistency. (#37920)
    
    * Adds eslint-plugin-eslint-plugin and recommended rules.
    
    * Removes `fixable` as none of the rules contain fixers.
    
    * Adds description and url rules.
    
    * Adds message format.
    
    * Removes optional dependencies.
    
    * Lints eslint-plugin-next tests too.
    
    * Removes optional dependencies from pnpm lock file.
    
    * Resets pnpm lock file.
    
    * Resets package.json too.
    
    * Fixes pnpm lockfile.
    manovotny authored Aug 8, 2022
    Copy the full SHA
    ab48f54 View commit details
  8. Copy the full SHA
    4199da0 View commit details
  9. [ESLint] Adds --output-file flag (#36420)

    Add support for `--output-file` on ESLint cli, based on this discussion #26179, and this closed PR #35154. With this flag, it is possible to save the output in a file and use it for any purpose.
    
    ## 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: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    pepoeverton and ijjk authored Aug 8, 2022
    Copy the full SHA
    59b144c View commit details
  10. Land(Update example with-apivideo-upload README) (#39391)

    * update(README)
    
    * fix create scripts
    
    Co-authored-by: MarDi66 <yohann.mtfpro@gmail.com>
    ijjk and MarDi66 authored Aug 8, 2022
    Copy the full SHA
    f60f8ae View commit details
  11. Update polyfill for eslint no-unwanted-polyfillio rule (#33170)

    Fixes #33072
    
    I documented all `esXXX` features to be sure that they were already polyfilled. Only `es2019` feature `Object.fromEntries` is not already polyfilled by nextjs.
    
    I added some unwanted polyfill (that are polyfilled by nextjs).
    
    I kept the `es5`, `es6` and `es2015` "as-is" as they contain functions that does not seem to be explicitly polyfilled (all `Math` functions or `Date.now` for example) in the [polyfill file](https://github.com/vercel/next.js/blob/master/packages/next-polyfill-nomodule/src/index.js)
    
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    jdeniau and ijjk authored Aug 8, 2022
    Copy the full SHA
    8ebd1a2 View commit details
  12. fix(ts): Middleware type tweaks (#38625)

    * fix internal type
    
    * allow `void` to be returned from Middleware
    
    * mark deprecated APIs in JSDoc
    
    * fix typo
    
    * add missing error page
    
    * remove unused import
    balazsorban44 authored Aug 8, 2022
    Copy the full SHA
    b292bdc View commit details
  13. docs: update When section of getStaticProps page (#39393)

    getStaticProps will be called in conjection with fallback.
    
    it's written in following page, but not in concerned page.
    https://nextjs.org/docs/basic-features/data-fetching/get-static-paths
    sumiren authored Aug 8, 2022
    Copy the full SHA
    9f8713f View commit details
  14. Update script.md (#39400)

    Adding `strategy="lazyOnload"` for prevent minor confusion.
    
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    sanjaiyan-dev and ijjk authored Aug 8, 2022
    Copy the full SHA
    1cc6e47 View commit details
  15. Fix: broken TypeScript in WordPress example. (#39402)

    * chore: add typescript and update deps
    
    * style: add tsconfig
    
    * chore: add g.avatar.com domain
    
    * fix: images domain api url to match with hostname
    
    * style: convert files to typescript
    
    * refactor(Avatar): const name for readable purpose
    
    * refactor: change regex to extract www from url
    
    * Update next-image domains.
    
    * Update a few types.
    
    * Update readme.
    
    * typo
    
    Co-authored-by: Chaiwat Trisuwan <chaiwattsw@gmail.com>
    Co-authored-by: Lee Robinson <me@leerob.io>
    Co-authored-by: Anthony Shew <anthony@inthezone.dev>
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    5 people authored Aug 8, 2022
    Copy the full SHA
    60c8e5c View commit details
  16. Fix Link generation for SSG pages if locale domains are used (#36818)

    * Fix SSG Link generation if using domain locales
    
    * Updated condition and test
    
    * Changed export worker domain locale check
    
    * Update check
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    pekarja5 and ijjk authored Aug 8, 2022
    Copy the full SHA
    289bfa6 View commit details
  17. v12.2.5-canary.0

    ijjk committed Aug 8, 2022
    1
    Copy the full SHA
    b0f5901 View commit details

Commits on Aug 9, 2022

  1. Setup require hook in next-server for styled-jsx resolving (#39305)

    * Use require hook and alias to resolve styled-jsx
    
    * re-export styled-jsx types from compiled
    
    * fix lint
    
    * add test for styled-jsx css
    
    * setup require hook in server
    
    * compile import path to styled-jsx/style
    
    * revert require hook
    
    * add test for server styled-jsx resolving
    
    * update test
    
    * pre copy styled-jsx assets
    
    * fix styled-jsx dts
    
    * add npmrc for styled-jsx e2e test
    
    * load require hook directly
    
    * rm legacy test
    
    * fix lint
    
    * fix pnpm install error
    
    * split require hook
    
    * only alias styled-jsx
    
    * make styled-jsx resolving statically analyzable
    
    * update test
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    huozhi and ijjk authored Aug 9, 2022
    Copy the full SHA
    71f5f25 View commit details
  2. API Routes Request Helpers docs. (#39407)

    Renames Middleware to Request Helpers to be both more accurate and also less confusing since Middleware is a separate feature of Next.js now.
    leerob authored Aug 9, 2022
    Copy the full SHA
    5d93753 View commit details
  3. fix: ensure trailing slash on registry URL when fetching wasm fallback (

    #39427)
    
    fix: ensure trailing slash on registry URL
    balazsorban44 authored Aug 9, 2022
    Copy the full SHA
    5ac50a9 View commit details
  4. Improve description of context.query in getServerSideProps() (#39422

    )
    
    Improve description of `query`
    
    `query` is not just representing of the query string. It has the same values as `router.query`.
    fediev authored Aug 9, 2022
    Copy the full SHA
    d3bbfea View commit details
  5. typing: upgrade styled-jsx to remove workaround in build script (#39408)

    Improve styled-jsx types in next.js, previously there's no `declare module` for styled-jsx and there's type name conflicts in `styled-jsx/index.d.ts` and we use a rename hack to avoid the conflicts. Now styled-jsx 5.0.3 fixed those issues.
    
    x-ref: vercel/styled-jsx#805
    huozhi authored Aug 9, 2022
    Copy the full SHA
    3e19ad5 View commit details
  6. Enhance sizes documentation for next/image (#39301)

    This PR updates the documentation for the `sizes` proper in next/image to make it more clear what this prop does and why it's (very) important to use it. After feedback, I'll update this PR to also modify the future image component docs.
    
    
    Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
    Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    3 people authored Aug 9, 2022
    Copy the full SHA
    b2d93e8 View commit details
  7. Extract redirect utils into a separate file (#39433)

    extract redirect utils
    shuding authored Aug 9, 2022
    Copy the full SHA
    ed14af3 View commit details
  8. Copy the full SHA
    997e3c0 View commit details
  9. Add component wrapper in sizes documentation code snippet (#39437)

    * Wrap sizes code snippets in component
    
    * Don't remove docs import statement
    atcastle authored Aug 9, 2022
    Copy the full SHA
    e2119c0 View commit details
  10. feat(middleware): augments / matcher with /index (#39397)

    * feat(middleware): augments / matcher with /index
    
    * fix(#39396): not invoked with i18n and trailingSlash
    
    * add test case
    
    * tweak matcher a bit and add tests
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    feugy and ijjk authored Aug 9, 2022
    Copy the full SHA
    15a216b View commit details
  11. v12.2.5-canary.1

    ijjk committed Aug 9, 2022
    1
    Copy the full SHA
    a6bc387 View commit details

Commits on Aug 10, 2022

  1. Update router.prefetch documentation to include locale option (#3…

    …9442)
    
    * Update `router.prefetch` documentation
    
    Include documentation for setting the locale as an option within `router.prefetch`.
    
    * apply suggestions
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    jonohewitt and ijjk authored Aug 10, 2022
    Copy the full SHA
    7d59da9 View commit details
  2. Fix docs path "Invalid getServerSideProps Return Value" (#39443)

    # Description
    
    The link to https://nextjs.org/docs/messages/invalid-getserversideprops-value does not exist, the correct link should be https://nextjs.org/docs/messages/invalid-getserversideprops-return-value
    
    ![image](https://user-images.githubusercontent.com/78015359/183795431-53210024-4938-4f50-9f0a-cb412383780e.png)
    
    ![image](https://user-images.githubusercontent.com/78015359/183795482-f17f31c2-cbaf-4652-ad77-5294fa8f104a.png)
    
    # Solution
    
    ## From
    
    Referring to the pattern, there is no `return`
    
    ![Screenshot from 2022-08-10 10-04-33](https://user-images.githubusercontent.com/78015359/183795393-ba244d6a-84b3-426c-b5ef-4e17d108902a.png)
    
    ## To
    
    So I removed the word `return` to match the pattern
    
    ![image](https://user-images.githubusercontent.com/78015359/183796280-da6f10d1-c017-4075-942a-01d9ad234c27.png)
    
    
    ## Bug
    
    - [ ] Related issues linked using `fixes #number`
    - [ ] Integration tests added
    - [ x] Errors have helpful link attached, see `contributing.md`
    
    ## Documentation / Examples
    
    - [x] 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: JJ Kasper <22380829+ijjk@users.noreply.github.com>
    zakiego and ijjk authored Aug 10, 2022
    Copy the full SHA
    5f033ec View commit details
  3. Bump edge-runtime packages (#39450)

    This version fixes a bug where [crypto buffers (ArrayBuffer, Uint8Array) not compatible with text decoding](vercel/edge-runtime@17475e4).
    Schniz authored Aug 10, 2022
    Copy the full SHA
    b899d01 View commit details
Showing 364 changed files with 4,885 additions and 3,074 deletions.
41 changes: 38 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -69,9 +69,10 @@
"warn",
{
"functions": false,
"classes": false,
"variables": false,
"typedefs": false
"classes": true,
"variables": true,
"enums": true,
"typedefs": true
}
],
"no-unused-vars": "off",
@@ -106,6 +107,16 @@
{
"files": ["examples/**/*"],
"rules": {
"@typescript-eslint/no-use-before-define": [
"error",
{
"functions": true,
"classes": true,
"variables": true,
"enums": true,
"typedefs": true
}
],
"import/no-anonymous-default-export": [
"error",
{
@@ -145,6 +156,30 @@
}
]
}
},
{
"files": [
"packages/eslint-plugin-next/**/*.js",
"test/unit/eslint-plugin-next/**/*.test.ts"
],
"extends": ["plugin:eslint-plugin/recommended"],
"parserOptions": {
"sourceType": "script"
},
"rules": {
"eslint-plugin/prefer-replace-text": "error",
"eslint-plugin/report-message-format": [
"error",
".+\\. See: https://nextjs.org/docs/messages/[a-z\\-]+$"
],
"eslint-plugin/require-meta-docs-description": [
"error",
{
"pattern": ".+"
}
],
"eslint-plugin/require-meta-docs-url": "error"
}
}
],
"rules": {
6 changes: 3 additions & 3 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
@@ -1463,7 +1463,7 @@ jobs:
rm -rf test
- name: Build
id: build
uses: vmactions/freebsd-vm@v0.2.0
uses: vmactions/freebsd-vm@v0.2.3
env:
DEBUG: napi:*
RUSTUP_HOME: /usr/local/rustup
@@ -1493,8 +1493,8 @@ jobs:
whoami
env
freebsd-version
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}" "turbo@${TURBO_VERSION}" && if [ ! -f $(dirname $(which yarn))/pnpm ]; then ln -s $(which yarn) $(dirname $(which yarn))/pnpm;fi
yarn --cwd=packages/next-swc build-native-no-plugin --release --target x86_64-unknown-freebsd
npm i -g "@napi-rs/cli@${NAPI_CLI_VERSION}"
cd packages/next-swc && napi build --platform -p next-swc-napi --cargo-name next_swc_napi native --release --target x86_64-unknown-freebsd
rm -rf node_modules
rm -rf packages/next-swc/target
- name: Upload artifact
4 changes: 2 additions & 2 deletions contributing.md
Original file line number Diff line number Diff line change
@@ -30,9 +30,9 @@ To develop locally:
```
git checkout -b MY_BRANCH_NAME
```
3. Install pnpm:
3. Enable pnpm:
```
npm install -g pnpm
corepack enable pnpm
```
4. Install the dependencies with:
```
2 changes: 1 addition & 1 deletion docs/advanced-features/compiler.md
Original file line number Diff line number Diff line change
@@ -358,7 +358,7 @@ This transform uses [handlebars](https://docs.rs/handlebars) to template the rep

1. `matches`: Has type `string[]`. All groups matched by the regular expression. `matches.[0]` is the full match.
2. `member`: Has type `string`. The name of the member import.
3. `lowerCase`, `upperCase`, `camelCase`: Helper functions to convert a string to lower, upper or camel cases.
3. `lowerCase`, `upperCase`, `camelCase`, `kebabCase`: Helper functions to convert a string to lower, upper, camel or kebab cases.

### SWC Trace profiling

2 changes: 2 additions & 0 deletions docs/advanced-features/preview-mode.md
Original file line number Diff line number Diff line change
@@ -194,10 +194,12 @@ Then, send a request to `/api/clear-preview-mode-cookies` to invoke the API Rout
`setPreviewData` takes an optional second parameter which should be an options object. It accepts the following keys:

- `maxAge`: Specifies the number (in seconds) for the preview session to last for.
- `path`: Specifies the path the cookie should be applied under. Defaults to `/` enabling preview mode for all paths.

```js
setPreviewData(data, {
maxAge: 60 * 60, // The preview mode cookies expire in 1 hour
path: '/about', // The preview mode cookies apply to paths with /about
})
```

2 changes: 1 addition & 1 deletion docs/api-reference/data-fetching/get-server-side-props.md
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ The `context` parameter is an object containing the following keys:
- `params`: If this page uses a [dynamic route](/docs/routing/dynamic-routes.md), `params` contains the route parameters. If the page name is `[id].js` , then `params` will look like `{ id: ... }`.
- `req`: [The `HTTP` IncomingMessage object](https://nodejs.org/api/http.html#http_class_http_incomingmessage), with an additional `cookies` prop, which is an object with string keys mapping to string values of cookies.
- `res`: [The `HTTP` response object](https://nodejs.org/api/http.html#http_class_http_serverresponse).
- `query`: An object representing the query string.
- `query`: An object representing the query string, including dynamic route parameters.
- `preview`: `preview` is `true` if the page is in the [Preview Mode](/docs/advanced-features/preview-mode.md) and `false` otherwise.
- `previewData`: The [preview](/docs/advanced-features/preview-mode.md) data set by `setPreviewData`.
- `resolvedUrl`: A normalized version of the request `URL` that strips the `_next/data` prefix for client transitions and includes original query values.
82 changes: 38 additions & 44 deletions docs/api-reference/next/future/image.md
Original file line number Diff line number Diff line change
@@ -43,19 +43,9 @@ Compared to `next/image`, the new `next/future/image` component has the followin

## Migration

Although `layout` is not available, you can migrate `next/image` to `next/future/image` using a few props. The following is a comparison of the two components:
Although `layout` is not available, you can migrate `next/image` to `next/future/image` using a few props. The following code snippets compare the two components:

<table>
<thead>
<tr>
<th>next/image</th>
<th>next/future/image</th>
</tr>
</thead>
<tbody>

<tr>
<td>
#### before: `next/image`

```jsx
import Image from 'next/image'
@@ -66,8 +56,7 @@ function Page() {
}
```

</td>
<td>
#### after: `next/future/image`

```jsx
import Image from 'next/future/image'
@@ -79,11 +68,7 @@ function Page() {
}
```

</td>
</tr>

<tr>
<td>
#### before: `next/image`

```jsx
import Image from 'next/image'
@@ -94,8 +79,7 @@ function Page() {
}
```

</td>
<td>
#### after: `next/future/image`

```jsx
import Image from 'next/future/image'
@@ -107,11 +91,7 @@ function Page() {
}
```

</td>
</tr>

<tr>
<td>
#### before: `next/image`

```jsx
import Image from 'next/image'
@@ -122,8 +102,7 @@ function Page() {
}
```

</td>
<td>
#### after: `next/future/image`

```jsx
import Image from 'next/future/image'
@@ -134,11 +113,7 @@ function Page() {
}
```

</td>
</tr>

<tr>
<td>
#### before: `next/image`

```jsx
import Image from 'next/image'
@@ -149,8 +124,7 @@ function Page() {
}
```

</td>
<td>
#### after: `next/future/image`

```jsx
import Image from 'next/future/image'
@@ -161,12 +135,6 @@ function Page() {
}
```

</td>
</tr>

</tbody>
</table>

You can also use `className` instead of `style`.

## Required Props
@@ -251,11 +219,37 @@ See also:

### sizes

A string that provides information about how wide the image will be at different breakpoints.
A string that provides information about how wide the image will be at different breakpoints. The value of `sizes` will greatly affect performance for images using [`fill`](#fill) or which are styled to have a responsive size.

The `sizes` property serves two important purposes related to image performance:

First, the value of `sizes` is used by the browser to determine which size of the image to download, from `next/future/image`'s automatically-generated source set. When the browser chooses, it does not yet know the size of the image on the page, so it selects an image that is the same size or larger than the viewport. The `sizes` property allows you to tell the browser that the image will actually be smaller than full screen. If you don't specify a `sizes` value in an image with the `fill` property, a default value of `100vw` (full screen width) is used.

Second, the `sizes` property configures how `next/future/image` automatically generates an image source set. If no `sizes` value is present, a small source set is generated, suitable for a fixed-size image. If `sizes` is defined, a large source set is generated, suitable for a responsive image. If the `sizes` property includes sizes such as `50vw`, which represent a percentage of the viewport width, then the source set is trimmed to not include any values which are too small to ever be necessary.

For example, if you know your styling will cause an image to be full-width on mobile devices, in a 2-column layout on tablets, and a 3-column layout on desktop displays, you should include a sizes property such as the following:

```js
import Image from 'next/image'
const Example = () => (
<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
)
```

This example `sizes` could have a dramatic effect on performance metrics. Without the `33vw` sizes, the image selected from the server would be 3 times as wide as it needs to be. Because file size is proportional to the square of the width, without `sizes` the user would download an image that's 9 times larger than necessary.

It's important to assign `sizes` for responsive images that takes up less than the full viewport width. For example, when the parent element will constrain the image to always be less than half the viewport width, use `sizes="50vw"`. Without `sizes`, the image will be sent at twice the necessary resolution, decreasing performance.
Learn more about `srcset` and `sizes`:

[Learn more](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-sizes).
- [web.dev](https://web.dev/learn/design/responsive-images/#sizes)
- [mdn](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-sizes)

### quality

32 changes: 27 additions & 5 deletions docs/api-reference/next/image.md
Original file line number Diff line number Diff line change
@@ -131,15 +131,37 @@ const MyImage = (props) => {

### sizes

A string that provides information about how wide the image will be at different breakpoints. Defaults to `100vw` (the full width of the screen) when using `layout="responsive"` or `layout="fill"`.
A string that provides information about how wide the image will be at different breakpoints. The value of `sizes` will greatly affect performance for images using `layout="responsive"` or `layout="fill"`. It will be ignored for images using `layout="intrinsic"` or `layout="fixed"`.

If you are using `layout="fill"` or `layout="responsive"` it's important to assign `sizes` for any image that takes up less than the full viewport width.
The `sizes` property serves two important purposes related to image performance:

For example, when the parent element will constrain the image to always be less than half the viewport width, use `sizes="50vw"`. Without `sizes`, the image will be sent at twice the necessary resolution, decreasing performance.
First, the value of `sizes` is used by the browser to determine which size of the image to download, from `next/image`'s automatically-generated source set. When the browser chooses, it does not yet know the size of the image on the page, so it selects an image that is the same size or larger than the viewport. The `sizes` property allows you to tell the browser that the image will actually be smaller than full screen. If you don't specify a `sizes` value, a default value of `100vw` (full screen width) is used.

If you are using `layout="intrinsic"` or `layout="fixed"`, then `sizes` is not needed because the upper bound width is constrained already.
Second, the `sizes` value is parsed and used to trim the values in the automatically-created source set. If the `sizes` property includes sizes such as `50vw`, which represent a percentage of the viewport width, then the source set is trimmed to not include any values which are too small to ever be necessary.

[Learn more](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-sizes).
For example, if you know your styling will cause an image to be full-width on mobile devices, in a 2-column layout on tablets, and a 3-column layout on desktop displays, you should include a sizes property such as the following:

```js
import Image from 'next/image'
const Example = () => (
<div className="grid-element">
<Image
src="/example.png"
layout="fill"
sizes="(min-width: 75em) 33vw,
(min-width: 48em) 50vw,
100vw"
/>
</div>
)
```

This example `sizes` could have a dramatic effect on performance metrics. Without the `33vw` sizes, the image selected from the server would be 3 times as wide as it needs to be. Because file size is proportional to the square of the width, without `sizes` the user would download an image that's 9 times larger than necessary.

Learn more about `srcset` and `sizes`:

- [web.dev](https://web.dev/learn/design/responsive-images/#sizes)
- [mdn](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#attr-sizes)

### quality

6 changes: 4 additions & 2 deletions docs/api-reference/next/router.md
Original file line number Diff line number Diff line change
@@ -248,14 +248,16 @@ export default function Page() {

Prefetch pages for faster client-side transitions. This method is only useful for navigations without [`next/link`](/docs/api-reference/next/link.md), as `next/link` takes care of prefetching pages automatically.

> This is a production only feature. Next.js doesn't prefetch pages on development.
> This is a production only feature. Next.js doesn't prefetch pages in development.
```jsx
router.prefetch(url, as)
router.prefetch(url, as, options)
```

- `url` - The URL to prefetch, including explicit routes (e.g. `/dashboard`) and dynamic routes (e.g. `/product/[id]`)
- `as` - Optional decorator for `url`. Before Next.js 9.5.3 this was used to prefetch dynamic routes, check our [previous docs](https://nextjs.org/docs/tag/v9.5.2/api-reference/next/link#dynamic-routes) to see how it worked
- `options` - Optional object with the following allowed fields:
- `locale` - allows providing a different locale from the active one. If `false`, `url` has to include the locale as the active locale won't be used.

#### Usage

11 changes: 5 additions & 6 deletions docs/api-routes/introduction.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@ description: Next.js supports API Routes, which allow you to build your API with
<summary><b>Examples</b></summary>
<ul>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/api-routes">Basic API Routes</a></li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/api-routes-middleware">API Routes with middleware</a></li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/api-routes-graphql">API Routes with GraphQL</a></li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/api-routes-rest">API Routes with REST</a></li>
<li><a href="https://github.com/vercel/next.js/tree/canary/examples/api-routes-cors">API Routes with CORS</a></li>
@@ -31,7 +30,7 @@ export default function handler(req, res) {
For an API route to work, you need to export a function as default (a.k.a **request handler**), which then receives the following parameters:

- `req`: An instance of [http.IncomingMessage](https://nodejs.org/api/http.html#class-httpincomingmessage), plus some [pre-built middlewares](/docs/api-routes/api-middlewares.md)
- `req`: An instance of [http.IncomingMessage](https://nodejs.org/api/http.html#class-httpincomingmessage), plus some [pre-built middlewares](/docs/api-routes/request-helpers.md)
- `res`: An instance of [http.ServerResponse](https://nodejs.org/api/http.html#class-httpserverresponse), plus some [helper functions](/docs/api-routes/response-helpers.md)

To handle different HTTP methods in an API route, you can use `req.method` in your request handler, like so:
@@ -57,17 +56,17 @@ For new projects, you can build your entire API with API Routes. If you have an

## Caveats

- API Routes [do not specify CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), meaning they are **same-origin only** by default. You can customize such behavior by wrapping the request handler with the [CORS middleware](/docs/api-routes/api-middlewares.md#connectexpress-middleware-support).
- API Routes [do not specify CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS), meaning they are **same-origin only** by default. You can customize such behavior by wrapping the request handler with the [CORS request helpers](https://github.com/vercel/next.js/tree/canary/examples/api-routes-cors).
- API Routes can't be used with [`next export`](/docs/advanced-features/static-html-export.md)

## Related

For more information on what to do next, we recommend the following sections:

<div class="card">
<a href="/docs/api-routes/api-middlewares.md">
<b>API Middlewares:</b>
<small>learn about the built-in middlewares for the request.</small>
<a href="/docs/api-routes/request-helpers.md">
<b>API Routes Request Helpers:</b>
<small>learn about the built-in helpers for the request.</small>
</a>
</div>

Loading