Skip to content

Nested next/dynamic is not preloaded during SSR #45213

Description

@fikrikarim

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000
Binaries:
  Node: 16.18.1
  npm: 8.19.2
  Yarn: 1.22.19
  pnpm: N/A
Relevant packages:
  next: 13.1.6-canary.0
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue

https://github.com/fikrikarim/nested-next-dynamic-bug

To Reproduce

Create a nested next/dynamic component: import a component with next/dynamic, and inside that component, import another component with next/dynamic.

Run next build and next start. Check the generated HTML.

image

https://nested-next-dynamic-bug.vercel.app/

Describe the Bug

The recent PR #45160 fix React.lazy preloading during SSR. It's working, but it doesn't preload a nested next/dynamic.

Expected Behavior

The generated HTML should contain the correct content by preloading all next/dynamic, even the nested ones.

Next.js v13.0.6 has the expected behavior:

image

https://nested-next-dynamic-dbn5z8i2d-fikrikarim.vercel.app/

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Lazy LoadingRelated to Next.js Lazy Loading (e.g., next/dynamic or React.lazy).bugIssue was opened via the bug report template.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions