-
Notifications
You must be signed in to change notification settings - Fork 36
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
New package (0.11.0+) brings Apollo Client into Browser bundle when not used in Client Components #341
Comments
Hi there @lionskape 👋 What you're describing indeed sounds very strange. My first instinct is that a question of including server code in a client bundle would be best asked of the framework/bundler. What version of Next.js are you using? Did you notice this change after this package, or multiple dependencies? Any additional information you can provide would be very helpful in determining where this issue would be best directed. Thanks! |
@alessbell hi! I believe that it is just apollo client, which can be used on SSR (but I do not need it). My case: "@apollo/experimental-nextjs-app-support": "0.10.1" "@apollo/experimental-nextjs-app-support": "0.11.2" |
Hey @lionskape 👋 0.11 added a new shared entry point that now uses export conditions in order to determine the right bundle to use (assuming you're importing from the top-level entry point). This should work well with Next.js and the app router as this is the bundling strategy React recommends for RSC architecture, though the sub imports (i.e. the Can you put together a reproduction for us? A reproduction would go a long way to figuring out why you're seeing the bundle increase. |
I can reproduce it here: phryneas/apollo-client-nextjs-reproduction-341@8b39385 This is clearly a bug in Next.js. It should not bundle any library that's only referenced in RSC - no matter how we build, no matter how we bundle, it should not have any influence on that. |
@phryneas thank you for reproducing an issue! I believe they will not include a fix in 14th release. May be it is possible to make workaround in this integration library? Something like additional dedicated |
Let's wait for their feedback first. |
Yeah, I had similar thoughts occur to me over the weekend - we have a RSC call that creates a component that references a client component. I could reduce the impact with a well-placed and lazily executed |
@lionskape could you please verify if this fixes the issue for you? npm i @apollo/experimental-nextjs-app-support@0.0.0-commit-release.0.1724059607.3b1a1ef |
@phryneas sorry for being late. Thank you, great job! I have validated your variant, so:
Maybe you can just create a separate entrypoint for rsc, without any "use client" imports in the import graph? |
@lionskape we're probably not going to get around that stub unless Next.js does something on their side.
We had separate entry points, and it has confused users a lot. I think having that separate entrypoint would do more harm than good - especially since we want most users that use RSC to use the It's good to know that this already brings a significant improvement, so I'm going to merge and ship that PR, it will benefit a lot of users. Thank you for bringing this up and testing it out! |
My project uses CommonJS (no "type": "module").
I found an issue.The new version of
@apollo/experimental-nextjs-app-support
have been added to a bundle, on pages where there is no ApolloProvider, only RSC calls of apollo client.Steps to reproduce:
"@apollo/experimental-nextjs-app-support": "0.11.2"
const {data} = await(await getClient()).query({query: MyQuery});
on any nextjs page.tsx@apollo/experimental-nextjs-app-support
in browser bundle, and all it deps (like Apollo Client)The text was updated successfully, but these errors were encountered: