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

[V3] Create @apollo/client/core bundle #5541

Merged
merged 13 commits into from
Nov 12, 2019
Merged

[V3] Create @apollo/client/core bundle #5541

merged 13 commits into from
Nov 12, 2019

Conversation

kamilkisiela
Copy link
Contributor

@kamilkisiela kamilkisiela commented Nov 1, 2019

This PR creates package.json under /core directory so people are able to use @apollo/client/core module, just like regular node module, with support of bundlers and everything.

Thanks to @apollo/client/core non-react people doesn't have to install react (and @types/react on TypeScript).

It still doesn't fix the issue in codesandbox.io and stackblitz.io and related because in all non-react projects the react module has to be installed... But at least non-react folks are able to use new Apollo Client v3 :)

import { gql, ApolloClient } from '@apollo/client/core';

Related #5532

@kamilkisiela kamilkisiela changed the title Create @apollo/client/common bundle [V3] Create @apollo/client/common bundle Nov 1, 2019
@wtrocki
Copy link
Contributor

wtrocki commented Nov 1, 2019

A really important change that is going to fix the main issue for many community packages that will want to migrate to 3.0!

@hwillson
Copy link
Member

hwillson commented Nov 4, 2019

Thanks for kickstarting this @kamilkisiela. We'll be working on a variation of this over the next little while, and will merge our commits into this PR to keep everything in the same place. We'd love to get your feedback when ready, so we'll definitely keep you posted.

@hwillson hwillson self-assigned this Nov 4, 2019
@hwillson hwillson added this to the Release 3.0 milestone Nov 4, 2019
@hwillson hwillson removed their request for review November 4, 2019 19:07
@kamilkisiela kamilkisiela changed the title [V3] Create @apollo/client/common bundle [V3] Create @apollo/client/core bundle Nov 11, 2019
@kamilkisiela
Copy link
Contributor Author

kamilkisiela commented Nov 11, 2019

@hwillson I see you're pushing it forward. Is there a way we could prevent people from using @apollo/client instead of @apollo/client/core in 3rd party libraries, like custom Link and Caches?

I'm talking about not exposing some types and classes in @apollo/client but only in @apollo/client/core so people won't get it wrong. IDEs and their suggestions and auto-imports features would pick the /core and @apollo/client won't leak there.

@abdonrd
Copy link
Contributor

abdonrd commented Nov 11, 2019

I think it would be much clearer to have something like:

  • @apollo/client with just the core
  • @apollo/client/react with the React exports

What do you think?

@hwillson
Copy link
Member

@abdonrd we considered that in our original design, but decided we want the @apollo/client package to be everything by default, to give people the shortest/easiest possible path to get up and running with Apollo Client. Apollo Client 3 removes apollo-boost, so we want @apollo/client to take its place. While we 💯% want to support people using view layers other than React, React use is still the most popular view option with Apollo, which is why it's part of the full package. There are also other less technical business-y reasons for this decision. Thanks for the feedback though - I'll definitely re-iterate this in our next planning meeting.

@kamilkisiela I'll put some thought into this - thanks!

Copy link
Member

@benjamn benjamn left a comment

Choose a reason for hiding this comment

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

Now let's do the same for other entry points (in subsequent PRs)!

hwillson and others added 9 commits November 12, 2019 13:16
This ensures `dist` is fully ready after each build, which helps
when linking the `dist` dir into test projects during development.
We'll use `core` as the non-React bundle, instead of `common`.
These changes help avoid creating a CJS specific bundle for
`@apollo/client/core` by comparing `dist/apollo-client.cjs.js`
and `dist/react/index.js` exports, then re-exporting all
non-React exports from the main CJS bundle.
@hwillson hwillson merged commit 94f3b84 into release-3.0 Nov 12, 2019
@hwillson hwillson deleted the fix/react-import branch November 12, 2019 18:33
hwillson added a commit that referenced this pull request Nov 13, 2019
Similar to the changes made in #5541, this commit adds a direct
entry point for the Apollo Client cache code. Importing from
`@apollo/client/cache` gives access to the cache code directly,
without pulling in other parts of the Apollo Client codebase.
hwillson added a commit that referenced this pull request Nov 15, 2019
Similar to the changes made in #5541, this commit adds a direct
entry point for the Apollo Client cache code. Importing from
`@apollo/client/cache` gives access to the cache code directly,
without pulling in other parts of the Apollo Client codebase.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants