1. 01 Sep, 2022 1 commit
  2. 31 Aug, 2022 9 commits
  3. 30 Aug, 2022 10 commits
  4. 29 Aug, 2022 8 commits
  5. 28 Aug, 2022 7 commits
    • Yoann Moinet's avatar
      [docs] Add precision about `pageExtensions` (#40016) · 1b61d1f5
      Yoann Moinet authored
      
      
      Adding a precision because when you change the `pageExtensions` configuration in `next.config.js`, `middleware.ts` isn't recognized anymore.
      
      Took me some time to debug this one, not sure if it should be considered a bug or just lack of documentation.
      I'll let you be the judge of that.
      
      ## 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: 's avatarJJ Kasper <22380829+ijjk@users.noreply.github.com>
      1b61d1f5
    • JJ Kasper's avatar
      Update docker image for stats action (#40032) · 4f360649
      JJ Kasper authored
      Noticed the stats action was leveraging the wasm fallback incorrectly
      which seems to be due to the necessary glibc version not being available
      in the docker image we were leveraging so this updates the base docker
      image used so the wasm fallback isn't needed and the dev binary is
      correctly used again.
      
      Fixes:
      https://github.com/vercel/next.js/runs/8004433626?check_suite_focus=true
      Fixes:
      https://github.com/vercel/next.js/runs/7988021570?check_suite_focus=true
      4f360649
    • Sanjaiyan Parthipan's avatar
      Update script.md (#40017) · ca807d66
      Sanjaiyan Parthipan authored
      Adding id property for inline script 
      Co-authored-by: 's avatarSukka <isukkaw@gmail.com>
      ca807d66
    • Shu Ding's avatar
      Avoid bundling `next/script` in the server build by default (#40013) · d592d206
      Shu Ding authored
      We only use `if (child.type === Script)` on the server side to check the
      element type, that's unnecessary because we can add a special flag for
      that (`__nextScript` in this PR).
      
      This reduces the server bundle by ~13kb if `next/script` is not imported
      by the user.
      
      ## 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)
      d592d206
    • YK's avatar
    • Sukka's avatar
      fix(#39993): avoid race condition for next/script onReady (#40002) · e6862e40
      Sukka authored
      Fixes #39993.
      
      Before the PR:
      
      - `next/script` component mount, `useEffect` for `onReady` executes
      - The script's cacheKey is not added to `LoadCache`, skip `onReady`
      - The second `useEffect` for `loadScript` executes
      - The script's cacheKey is added to `LoadCache` even if it might not fully load yet
      - Because of React's strict mode, `useEffect` for `onReady` executes again
      - Since the script's cacheKey is in `LoadCache`, `onReady` is called (even when the script is not loaded yet)
      - After the script is actually loaded, inside the `script.onload` event handler the `onReady` is called again
      
      After the PR:
      
      - `next/script` component mount, `useEffect` for `onReady` executes
      - The script's cacheKey is not added to `LoadCache`, `useEffect` skips `onReady`
      - The second `useEffect` for `loadScript` executes
      - The script's cacheKey is added to `LoadCache` only if it is an inline script
      - Because of React's strict mode, `useEffect` for `onReady` executes again
      - The script is not yet loaded, its cacheKey is not in `LoadCache`, `useEffect` skips `onReady` again
      - After the script is actually loaded, inside the `script.onload` event handler the `onReady` is finally called
      
      In short, the PR resolves a race condition that only occurs under React strict mode (and makes the `next/script` component more concurrent rendering resilient).
      
      ## Bug
      
      - [x] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [ ] Errors have helpful link attached, see `contributing.md`
      e6862e40
    • Shu Ding's avatar
      Add test for server CSS imports (#40019) · afbf4b10
      Shu Ding authored
      Now we are covering all 8 scenarios in our tests: server-client × global-CSS Modules × page-layout. Next step is to cover HMR and page navigation cases.
      
      ## 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)
      afbf4b10
  6. 27 Aug, 2022 1 commit
    • JJ Kasper's avatar
      Fix incorrect build log for moduleResolution (#39991) · f6c96e05
      JJ Kasper authored
      Removes extra log shown when checking `moduleResolution` in
      `tsconfig.json` and adds regression test.
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [ ] Errors have helpful link attached, see `contributing.md`
      f6c96e05
  7. 26 Aug, 2022 4 commits
    • Balázs Orbán's avatar
      feat: add `experimental.fallbackNodePolyfills` flag (#39248) · 6da621df
      Balázs Orbán authored
      For historical reasons, Next.js has been falling back to polyfill certain Node.js APIs in the browser. `webpack` itself stopped doing it, and so should Next.js. This might unexpectedly break some packages in the ecosystem though, so it is being introduced as an experimental flag. These imports will now throw a `Module not found` error and the package maintainer should make sure that the library isn't relying on these Node.js APIs when the package is meant for browser usage. 
      
      Let's take a look at a common example, the `crypto` API, which can be imported as `import crypto from "crypto"` but [should already be available in browsers](https://caniuse.com/cryptography). Until now, Next.js has fallen back to use a polyfilled version for the import, which resulted in a bundle-size increase.
      
      
      ```js
      import crypto from 'crypto'
      import { useEffect } from 'react'
      export default function Page() {
        useEffect(() => {
          console.log(crypto)
        }, [])
      }
      ```
      
      it imports `crypto`, which currently resolves to [`crypto-browserify`](https://www.npmjs.com/package/crypto-browserify).
      
      So the bundle will include `crypto-browserify` as well:
      ```sh
      Page                                       Size     First Load JS
      ┌ ○ /                                      131 kB          213 kB # <--
      └ ○ /404                                   194 B          82.2 kB
      + First Load JS shared by all              82 kB
        ├ chunks/framework-bcc2dc0ea27ab0c6.js   45.1 kB
        ├ chunks/main-dc2421aef72299b4.js        35.4 kB
        ├ chunks/pages/_app-a85935458980c5c2.js  708 B
        └ chunks/webpack-9b312e20a4e32339.js     836 B
      ```
      
      Here, we can just remove the import, as we are [safely accessing](https://nextjs.org/docs/migrating/from-create-react-app#safely-accessing-web-apis) the [Crypto Web API](https://caniuse.com/cryptography):
      
      ```diff
      - import crypto from 'crypto'
      import { useEffect } from 'react'
      export default function Page() {
        useEffect(() => {
          console.log(crypto)
        }, [])
      }
      ```
      
      Which will reduce the bundle size:
      
      ```sh
      Page                                       Size     First Load JS
      ┌ ○ /                                      269 B          82.2 kB # <--
      └ ○ /404                                   194 B          82.1 kB
      + First Load JS shared by all              81.9 kB
        ├ chunks/framework-bcc2dc0ea27ab0c6.js   45.1 kB
        ├ chunks/main-dc2421aef72299b4.js        35.4 kB
        ├ chunks/pages/_app-a85935458980c5c2.js  708 B
        └ chunks/webpack-fd82975a6094609f.js     727 B
      ```
      
      
      This is harder to detect if the `crypto` import is in a third-party package though. By setting `experimental: { fallbackNodePolyfills: false }`, Next.js will now fail at build-time and should show where the unnecessary import comes from, so the developer can reach out to the package maintainer to fix this issue.
      
      Note: There might be differences between the living standard and some of these older polyfills, so you have to make sure your code works well without the polyfilled version.
      
      Related feedback: https://twitter.com/lfredolo/status/1539608666026000384
      6da621df
    • JJ Kasper's avatar
      Ensure prefetch heuristic matches with and without middleware (#39920) · f7df3fc1
      JJ Kasper authored
      This fixes the prefetching handling when middleware is present as currently we are incorrectly triggering data requests for non-SSG pages to handle the case where a middleware rewrite is present and pointing to an SSG path. Since the majority use case won't be rewriting in middleware and this incurs a lot of potentially heavy requests to `getServerSideProps` paths this matches the prefetch handling when middleware isn't present and only prefetches the data route when we match an SSG path. 
      
      Fixes: [slack thread](https://vercel.slack.com/archives/C0289CGVAR2/p1661364670589519?thread_ts=1661199566.675759&cid=C0289CGVAR2)
      Fixes: https://github.com/vercel/next.js/issues/38918
      
      ## Bug
      
      - [x] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [ ] Errors have helpful link attached, see `contributing.md`
      f7df3fc1
    • Steven's avatar
      Fix `next/future/image` incorrectly warning for `fill` + `blur` (#39986) · 6a65dc5d
      Steven authored
      This warning was incorrectly printed when `fill` and `placeholder="blur"` were used together:
      
      > Image with src "/test.jpg" is smaller than 40x40. Consider removing the "placeholder='blur'" property to improve performance.
      6a65dc5d
    • Travis Arnold's avatar
      (next/mdx) set providerImportSource to react by default (#39954) · c6dafda0
      Travis Arnold authored
      Hello, this PR simply configures the `next/mdx` package to use `{ providerImportSource: '@mdx-js/react' }` by default. This is now [required in version 2](https://mdxjs.com/packages/mdx/#optionsproviderimportsource) and causes a lot of confusion personally because `MDXProvider` seems to not work when all is needed is to set this option.
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      c6dafda0