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

Next.js bundles libraries only used in Server Components into the Client Bundle Chunks #68972

Open
phryneas opened this issue Aug 16, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template. SWC Related to minification/transpilation in Next.js.

Comments

@phryneas
Copy link
Contributor

phryneas commented Aug 16, 2024

Link to the code that reproduces this issue

https://github.com/phryneas/apollo-client-nextjs-reproduction-341

To Reproduce

The reproduction is a blank create repo created with yarn create next-app - all differences to a new repo are in this commit

  1. npm install
  2. npm run build
  3. grep -rl watchQuery .next/static/chunks -> .next/static/chunks/959-17277ce4ae2a5d3b.js (watchQuery is an Apollo Client api, so it's easily identifiable by that even when class names are mangled)
  4. npm run start
  5. open http://localhost:3000 in the browser
  6. verify that 959-17277ce4ae2a5d3b.js is indeed sent to the browser

Current vs. Expected behavior

Apollo Client should not end up in the Client Chunks when only referenced from Server Components.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 22.6.0
  npm: 10.8.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 14.2.5 // Latest available version is detected (14.2.5).
  eslint-config-next: N/A
  react: 18.3.1
  react-dom: 18.3.1
  typescript: N/A
Next.js Config:
  output: N/A

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

SWC

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

next build (local), next start (local)

Additional context

This was brought to our attention in apollographql/apollo-client-nextjs#341

@phryneas phryneas added the bug Issue was opened via the bug report template. label Aug 16, 2024
@github-actions github-actions bot added the SWC Related to minification/transpilation in Next.js. label Aug 16, 2024
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. SWC Related to minification/transpilation in Next.js.
Projects
None yet
Development

No branches or pull requests

1 participant