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

Use import * as React everywhere. #11000

Merged
merged 7 commits into from
Jul 7, 2023
Merged

Use import * as React everywhere. #11000

merged 7 commits into from
Jul 7, 2023

Conversation

phryneas
Copy link
Member

This prevents an error when importing @apollo/client in a React Server component. (see #10974)

Checklist:

  • If this PR contains changes to the library itself (not necessary for e.g. docs updates), please include a changeset (see CONTRIBUTING.md)
  • If this PR is a new feature, please reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests

This prevents an error when importing `@apollo/client` in a React Server component. (see [#10974](#10974))
@changeset-bot
Copy link

changeset-bot bot commented Jun 21, 2023

🦋 Changeset detected

Latest commit: ed9919d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@apollo/client Patch

Not sure what this means? Click here to learn what changesets are.

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

@github-actions
Copy link
Contributor

github-actions bot commented Jun 21, 2023

size-limit report 📦

Path Size
dist/apollo-client.min.cjs 36.97 KB (-0.04% 🔽)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" 43.55 KB (-0.03% 🔽)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/main.cjs" (production) 42.16 KB (-0.07% 🔽)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" 32.57 KB (0%)
import { ApolloClient, InMemoryCache, HttpLink } from "dist/index.js" (production) 31.43 KB (0%)
import { ApolloProvider } from "dist/react/index.js" 1.23 KB (0%)
import { ApolloProvider } from "dist/react/index.js" (production) 1.22 KB (0%)
import { useQuery } from "dist/react/index.js" 4.26 KB (-0.21% 🔽)
import { useQuery } from "dist/react/index.js" (production) 4.08 KB (-0.22% 🔽)
import { useLazyQuery } from "dist/react/index.js" 4.58 KB (-0.28% 🔽)
import { useLazyQuery } from "dist/react/index.js" (production) 4.39 KB (-0.25% 🔽)
import { useMutation } from "dist/react/index.js" 2.5 KB (-0.28% 🔽)
import { useMutation } from "dist/react/index.js" (production) 2.48 KB (-0.36% 🔽)
import { useSubscription } from "dist/react/index.js" 2.24 KB (-0.4% 🔽)
import { useSubscription } from "dist/react/index.js" (production) 2.2 KB (-0.32% 🔽)
import { useSuspenseQuery } from "dist/react/index.js" 3.63 KB (-0.43% 🔽)
import { useSuspenseQuery } from "dist/react/index.js" (production) 3.04 KB (-0.32% 🔽)
import { useBackgroundQuery } from "dist/react/index.js" 3.83 KB (-0.21% 🔽)
import { useBackgroundQuery } from "dist/react/index.js" (production) 3.26 KB (-0.36% 🔽)
import { useReadQuery } from "dist/react/index.js" 2.56 KB (-0.12% 🔽)
import { useReadQuery } from "dist/react/index.js" (production) 2.54 KB (-0.16% 🔽)
import { useFragment } from "dist/react/index.js" 2.05 KB (-0.05% 🔽)
import { useFragment } from "dist/react/index.js" (production) 2 KB (-0.2% 🔽)

@phryneas
Copy link
Member Author

/release:pr

@github-actions
Copy link
Contributor

A new release has been made for this PR. You can install it with npm i @apollo/[email protected].

@phryneas
Copy link
Member Author

phryneas commented Jun 21, 2023

Irritatingly, a7ed5a8 brings down our bundle size for “dist/apollo-client.min.cjs” from 37796 to 37651 (without this PR: 37662). It doesn't influence any of the non-cjs other builds in size.
(unminified dist/main.cjs: 44352 -> 44209, for reference: 44241)

Is that size gain in the "legacy" commonJs build worth the slightly annoying syntax for us?

@jerelmiller
Copy link
Member

I definitely prefer the destructured version, but I could get used to whatever syntax makes most sense for us. If we go the route of React.useState, is there an ESLint rule we could enable to enforce this? One of us (likely me) is bound to forget to use this syntax in the future.

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.

Thanks for continuing to invest research into making this work for us!

@phryneas
Copy link
Member Author

I definitely prefer the destructured version, but I could get used to whatever syntax makes most sense for us.

Tbh., I do, too - but having a destructuring const at the top of every file gets even weirder - and the IDE will not help us destructure new values, unlike it could add new imports - so it's probably even more ergonomic this way.

If we go the route of React.useState, is there an ESLint rule we could enable to enforce this? One of us (likely me) is bound to forget to use this syntax in the future.

Very good call! I added an eslint rule!

@phryneas phryneas self-assigned this Jun 30, 2023
@jerelmiller jerelmiller added this to the Release 3.8 milestone Jul 6, 2023
@phryneas phryneas merged commit 1d43ab6 into release-3.8 Jul 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants