Skip to content

ship compiled hooks behind exports condition, inline React Compiler runtime #12731

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

Open
wants to merge 13 commits into
base: release-4.0
Choose a base branch
from

Conversation

phryneas
Copy link
Member

@phryneas phryneas commented Jun 23, 2025

This would be one possible solution to the React Compiler runtime not being released in a stable version yet.

  • hooks imported from @apollo/client/react are not compiled per default
  • compiled hooks can be opted in by adding the react-compiler exports condition
  • we do not have an external dependency on react-compiler-runtime as that's still not stable, but we ship a snapshot of it ourselves as @apollo/client/react/internal/compiler-runtime

Copy link

changeset-bot bot commented Jun 23, 2025

⚠️ No Changeset found

Latest commit: 4a740a0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

pkg-pr-new bot commented Jun 23, 2025

npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@12731

commit: f53fc6c

Copy link
Contributor

github-actions bot commented Jun 23, 2025

size-limit report 📦

Path Size
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (CJS) 42.62 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) (CJS) 37.73 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" 32.55 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client" (production) 26.97 KB (0%)
import { ApolloProvider } from "@apollo/client/react" 5.7 KB (0%)
import { ApolloProvider } from "@apollo/client/react" (production) 960 B (0%)
import { useQuery } from "@apollo/client/react" 7 KB (-6.41% 🔽)
import { useQuery } from "@apollo/client/react" (production) 2.23 KB (-17.8% 🔽)
import { useLazyQuery } from "@apollo/client/react" 6.89 KB (-0.89% 🔽)
import { useLazyQuery } from "@apollo/client/react" (production) 2.13 KB (-2.64% 🔽)
import { useMutation } from "@apollo/client/react" 6.23 KB (-4.38% 🔽)
import { useMutation } from "@apollo/client/react" (production) 1.47 KB (-16.03% 🔽)
import { useSubscription } from "@apollo/client/react" 6.56 KB (-0.96% 🔽)
import { useSubscription } from "@apollo/client/react" (production) 1.81 KB (-2.64% 🔽)
import { useSuspenseQuery } from "@apollo/client/react" 8.34 KB (-1.79% 🔽)
import { useSuspenseQuery } from "@apollo/client/react" (production) 3.61 KB (-3.38% 🔽)
import { useBackgroundQuery } from "@apollo/client/react" 8.1 KB (-1.57% 🔽)
import { useBackgroundQuery } from "@apollo/client/react" (production) 3.37 KB (-3.69% 🔽)
import { useLoadableQuery } from "@apollo/client/react" 8.06 KB (-5.68% 🔽)
import { useLoadableQuery } from "@apollo/client/react" (production) 3.35 KB (-12.12% 🔽)
import { useReadQuery } from "@apollo/client/react" 6.39 KB (-0.96% 🔽)
import { useReadQuery } from "@apollo/client/react" (production) 1.63 KB (-3.54% 🔽)
import { useFragment } from "@apollo/client/react" 6.42 KB (-1.12% 🔽)
import { useFragment } from "@apollo/client/react" (production) 1.67 KB (-3.99% 🔽)

@phryneas phryneas changed the title inline React Compiler runtime ship compiled hooks behind exports condition, inline React Compiler runtime Jun 25, 2025
@jerelmiller
Copy link
Member

I know we had talked about this a little before but did you want to pursue the idea of a separate export condition instead?

@phryneas
Copy link
Member Author

phryneas commented Jun 26, 2025

@jerelmiller this is that - a separate build behind the react-compiler exports condition for @apollo/client/react. Or did you mean a completely separate export at @apollo/client/react-compiled? I'm a bit concerned that people might end up shipping both versions that way tbh.

@phryneas
Copy link
Member Author

Now we have both @apollo/client/react with a react-compiler exports condition, and @apollo/client/react/compiled.

Let's wait for feedback from the Compiler team what they think about the exports condition. It would reduce the risk of importing from both entry points and accidentally shipping hooks in two different versions, bloating bundle size, but the exports condition would need to become an ecosystem pattern.

@jerelmiller
Copy link
Member

@phryneas oh gosh I realized I didn't refresh the page when I made that comment so I didn't see the new commits 🤦‍♂️. My mistake!

Copy link
Member

@jerelmiller jerelmiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming we get the blessing from the react team, this looks good to me

@github-actions github-actions bot added the auto-cleanup 🤖 label Jun 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants