1. 14 Sep, 2022 3 commits
    • JJ Kasper's avatar
      v12.3.1-canary.2 · 46dd1cff
      JJ Kasper authored
      46dd1cff
    • Sukka's avatar
      next/script: make `onLoad` concurrent rendering resilient (#40191) · ed3cb83c
      Sukka authored
      Another step toward fixing #40025.
      
      Multiple `next/script` components with the same `src` may exist in the
      Next.js app. So the `loadScript` function will always attach the
      `onLoad` handler to the `loadingPromise` every time it executes.
      
      However, with strict mode (or wrapped inside the `<OffScreen />`
      component), the `useEffect` could execute more than once for the same
      `next/script` component, thus the `loadScript` for each `next/script`
      component could execute more than once (and `onLoad` to be attached more
      than once), results in `onLoad` fires more than once.
      
      The PR makes sure that for every `next/script` component mounted, the
      `loadScript` will always be executed only once for each of them.
      
      The corresponding `onload fires correctly` integration test case is also
      updated to run in dev mode.
      
      ## Bug
      
      - [x] Related issues linked using `fixes #number`
      - [x] Integration tests added
      - [ ] Errors have helpful link attached, see `contributing.md`
      ed3cb83c
    • Henrik Wenz's avatar
      [Docs] Remove legacy mobx example (#40304) · 155a4d5e
      Henrik Wenz authored
      ## Info
      
      This PR merges with-mobx-lite into with-mobx. After that we will migrate `with-mobx` to typescript.
      
      ## Context
      
      As discussed in https://github.com/vercel/next.js/pull/40302#issuecomment-1239238966 we are going to merge the mobx examples.
      
      #40302
      
      ## 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)
      155a4d5e
  2. 13 Sep, 2022 15 commits
  3. 12 Sep, 2022 12 commits
    • JJ Kasper's avatar
      Rename allowDynamic to unstable_allowDynamic (#40496) · 8bf6a873
      JJ Kasper authored
      Follow-up to https://github.com/vercel/next.js/pull/39539 as discussed
      this renames to `unstable_` prefix initially while we test this out
      further.
      
      ## 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)
      8bf6a873
    • Damien Simonin Feugas's avatar
      feat(edge): allows configuring Dynamic code execution guard (#39539) · 97ac3444
      Damien Simonin Feugas authored
      ### 📖  What's in there?
      
      Dynamic code evaluation (`eval()`, `new Function()`, ...) is not
      supported on the edge runtime, hence why we fail the build when
      detecting such statement in the middleware or `experimental-edge` routes
      at build time.
      
      However, there could be false positives, which static analysis and
      tree-shaking can not exclude:
      - `qs` through these dependencies (get-intrinsic:
      [source](https://github.com/ljharb/get-intrinsic/blob/main/index.js#L12))
      - `function-bind`
      ([source](https://github.com/Raynos/function-bind/blob/master/implementation.js#L42))
      - `has`
      ([source](https://github.com/tarruda/has/blob/master/src/index.js#L5))
      
      This PR leverages the existing `config` export to let user allow some of
      their files.
      it’s meant for allowing users to import 3rd party modules who embed
      dynamic code evaluation, but do not use it (because or code paths), and
      can't be tree-shaked.
      
      By default, it’s keeping the existing behavior: warn in dev, fails to
      build.
      If users allow dynamic code, and that code is reached at runtime, their
      app stills breaks.
      
      ### 🧪 How to test?
      
      - (existing) integration tests for disallowing dynamic code evaluation:
      `pnpm testheadless --testPathPattern=runtime-dynamic`
      - (new) integration tests for allowing dynamic code evaluation: `pnpm
      testheadless --testPathPattern=runtime-configurable`
      - (amended) production tests for validating the new configuration keys:
      `pnpm testheadless --testPathPattern=config-validations`
      
      To try it live, you could have an application such as:
      ```js
      // lib/index.js
      /* eslint-disable no-eval */
      export function hasUnusedDynamic() {
        if ((() => false)()) {
          eval('100')
        }
      }
      
      export function hasDynamic() {
        eval('100')
      }
      
      // pages/index.jsx
      export default function Page({ edgeRoute }) {
        return <p>{edgeRoute}</p>
      }
      
      export const getServerSideProps = async (req) => {
        const res = await fetch(`http://localhost:3000/api/route`)
        const data = await res.json()
        return { props: { edgeRoute: data.ok ? `Hi from the edge route` : '' } }
      }
      
      // pages/api/route.js
      import { hasDynamic } from '../../lib'
      
      export default async function handle() {
        hasDynamic()
        return Response.json({ ok: true })
      }
      
      export const config = { 
        runtime: 'experimental-edge' ,
        allowDynamic: '/lib/**'
      }
      ```
      
      Playing with `config.allowDynamic`, you should be able to:
      - build the app even if it uses `eval()` (it will obviously fail at
      runtime)
      - build the app that _imports but does not use_ `eval()`
      - run the app in dev, even if it uses `eval()` with no warning
      
      ### 🆙 Notes to reviewers
      
      Before adding documentation and telemetry, I'd like to collect comments
      on a couple of points:
      - the overall design for this feature: is a list of globs useful and
      easy enough?
      - should the globs be relative to the application root (current
      implementation) to to the edge route/middleware file?
      - (especially to @sokra) is the implementation idiomatic enough? I've
      leverage loaders to read the _entry point_ configuration once, then the
      ModuleGraph to get it back during the parsing phase. I couldn't re-use
      the existing `getExtractMetadata()` facility since it's happening late
      after the parsing.
      - there's a glitch with `import { ServerRuntime } from '../../types'` in
      `get-page-static-info.ts`
      ([here](https://github.com/vercel/next.js/pull/39539/files#diff-cb7ac6392c3dd707c5edab159c3144ec114eafea92dad5d98f4eedfc612174d2L12)).
      I had to use `next/types` because it was failing during lint. Any clue
      why?
      
      ### ☑️ Checklist
      
      - [ ] 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
      - [x] Telemetry added. In case of a feature if it's used or not.
      - [x] Errors have helpful link attached, see `contributing.md`
      97ac3444
    • Thomas Knickman's avatar
      chore(examples): update turborepo examples link (#40487) · d83ceeec
      Thomas Knickman authored
      ## Documentation / Examples
      
      We now maintain a landing page of all monorepo examples with Next.js apps. We can point users here instead. 
      
      - [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)
      d83ceeec
    • M.K. Safi's avatar
      Clarify use of `loading` property (#40488) · d6f5ebf7
      M.K. Safi authored
      I was a little confused by the `loading` property having the value `<header />`. I think that property is meant to show a loading state while the file is being loaded? If my assumption is correct, I think this change makes sense.
      d6f5ebf7
    • JJ Kasper's avatar
      v12.3.1-canary.1 · 2872deef
      JJ Kasper authored
      2872deef
    • Donny/강동윤's avatar
      53ce3bf2
    • Đorđe Spasić's avatar
      fix: eslint no-script-component-in-head error url (#40422) · 804dc6bd
      Đorđe Spasić authored
      
      
      ## Bug
      
      - [ ] Related issues linked using `fixes #number`
      - [ ] Integration tests added
      - [ ] 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: 's avatarJJ Kasper <22380829+ijjk@users.noreply.github.com>
      804dc6bd
    • Balázs Orbán's avatar
      docs: move `swcMinify: true` out of "Experimental features" section (#40394) · 73557570
      Balázs Orbán authored
      See the blog post:
      https://nextjs.org/blog/next-12-3##swc-minifier-stable
      
      ## 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)
      Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
      73557570
    • Jiachi Liu's avatar
      Drop legacy RSC handling in client for pages (#40472) · c7d3f9d4
      Jiachi Liu authored
      Remove the unused RSC handling for pages in both server router and client side in favor of using RSC in app dir
      c7d3f9d4
    • Tim Neutkens's avatar
      Add failing case for location throw (#40445) · f92a4cee
      Tim Neutkens authored
      Found that the cause was that `React.useId()` returns the same value across requests whereas it was being used to create a unique key. On further inspection that code could be removed altogether as `id` was not used client-side and the `rscCache` map is no longer needed as the flight instance is already being created per request so it can live in the context of the request execution.
      
      
      ## 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)
      f92a4cee
    • Balázs Orbán's avatar
      docs(middleware): fix broken link · 3851d906
      Balázs Orbán authored
      3851d906
    • Lee Robinson's avatar
      Update Server Components documentation. (#40452) · 40fc066f
      Lee Robinson authored
      This PR updates the server components documentation to make it more clear the benefit of server components and what their current status is inside Next.js.
      
      It removes code snippets and CTAs for trying them out, as things have changed with the Layouts RFC since these docs were previously written. With the upcoming changes, server components will now be the default inside `app`. The list of supported and unsupported features was no longer accurate.
      
      We will be providing more guidance as the layouts and routing changes are ready to be tested.
      
      [Read the Layouts RFC](https://nextjs.org/blog/layouts-rfc) for more details.
      40fc066f
  4. 11 Sep, 2022 1 commit
  5. 09 Sep, 2022 9 commits