Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App router dynamic imports not working with parent server component #58238

Open
1 task done
tombryden opened this issue Nov 9, 2023 · 2 comments
Open
1 task done

App router dynamic imports not working with parent server component #58238

tombryden opened this issue Nov 9, 2023 · 2 comments
Labels
bug Issue was opened via the bug report template. Lazy Loading Related to Next.js Lazy Loading (e.g., `next/dynamic` or `React.lazy`).

Comments

@tombryden
Copy link

tombryden commented Nov 9, 2023

Link to the code that reproduces this issue

https://github.com/tombryden/dynamic-import-bug

To Reproduce

  1. npm run build - Observe / first load js = 119 kB
  2. Uncomment "use client" in page.tsx
  3. npm run build - Observe / first load js = 85.7 kB

Current vs. Expected behavior

Dynamic importing of a component only works when the parent component is a client component. Perhaps some additional documentation (e.g. suggesting wrapping with a client component to import dynamically) is needed to clear up confusion if this is expected behaviour. I believe you should be ok to close #49454 as this looks to be caused by this.

Verify canary release

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

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 18.17.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.2-canary.25
  eslint-config-next: 14.0.2-canary.25
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

App Router, Dynamic imports (next/dynamic)

Additional context

No response

@tombryden tombryden added the bug Issue was opened via the bug report template. label Nov 9, 2023
@github-actions github-actions bot added the Lazy Loading Related to Next.js Lazy Loading (e.g., `next/dynamic` or `React.lazy`). label Nov 9, 2023
@AhmedBaset
Copy link
Contributor

Jiachi explained that very well at #49454 (comment)

I believe this should be documented officially in the docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template. Lazy Loading Related to Next.js Lazy Loading (e.g., `next/dynamic` or `React.lazy`).
Projects
None yet
Development

No branches or pull requests

3 participants
@tombryden @AhmedBaset and others