question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bundle size is very big

See original GitHub issue

I find that Apollos bundle size is quite big, to the point where I’m thinking about moving away from it. Maybe there are things to do about that?

As of right now, Apollo outweighs both React and Material-UI by quite a bit and is therefore my largest dependency. The biggest modules caused by my Apollo usage are:

Total parsed: 137.26 kB
Total GZipped: 39.12 kB

Parsed Sizs:
  apollo-client 38.76 kB
  apollo-cache-inmemory 26.18 kB
  react-apollo 22.48 kB
  subscriptions-transport-ws 12.54 kB
  graphql 10.12 kB
  apollo-utilities 10.07 kB
  zen-observable 6.56 kB
  apollo-link-http 4.94 kB
  apollo-link 2.92 kB
  eventemitter3 2.69 kB

GZipped Sizes:
  apollo-client 10.11 kB
  apollo-cache-inmemory 7.24 kB
  react-apollo 5.88 kB
  subscriptions-transport-ws 3.81 kB
  graphql 2.95 kB
  apollo-utilities 2.93 kB
  apollo-link-http 2.07 kB
  zen-observable 2 kB
  apollo-link 1.13 kB
  eventemitter3 1 kB

I open this issue as a discussion starter

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:25
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

18reactions
jaydensericcommented, Dec 13, 2018

@Pajn After using Apollo Client and react-apollo for long time I took a step back and thought critically about how a GraphQL client could be architected from the ground up for efficiency; the result being graphql-react. It’s bundle-impact is ~2.5kb (tested here), compared to Apollo’s ~40kb.

It’s a lot easier to configure and use (one package, less config, uploads work out of the box, etc.), has a way smaller surface area for bugs (zero known ATM), and can even do some things that Apollo can’t that matter to me (i.e. SSR errors, easily refresh cache post mutations without also blowing away the mutation payload, etc.) trading off a few things that I don’t really need, like subscriptions, which could be implemented in the future anyway.

enamor.app uses graphql-react and Next.js. The JS for fresh app/page load is only ~100kb (including Google Analytics), with subsequent routes around ~5kb each:

screen shot 2018-12-13 at 11 50 15 pm

It might be up your alley.

While some of Apollo’s ~40kb bundle impact could be reduced to perhaps ~20kb with polish, I doubt sub 10kb is possible without rethinking the way it works (i.e. scrapping normalized cache, links, gql tagged template strings, graphql dependency, etc.).

6reactions
hwillsoncommented, Dec 13, 2018

While some of Apollo’s ~40kb bundle impact could be reduced to perhaps ~20kb with polish, I doubt sub 10kb is possible without rethinking the way it works (i.e. scrapping normalized cache, links, gql tagged template strings, graphql dependency, etc.).

Challenge accepted @jaydenseric 🙂. Seriously though, bundle size reduction is one of the items that’s next up on our todo list.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React webpack bundle size is large - Stack Overflow
I have a website that developed using react which has a single page, but the production bundle size is 1.11 MiB ...
Read more >
Small Bundles, Fast Pages: What To Do With Too Much ...
This post will explain why bundle size matters and recommend tools ... During parse and compile: big bundles take longer to be turned...
Read more >
5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
5 Methods to Reduce JavaScript Bundle Size · 1. Code Splitting with Webpack · 2. Using Webpack Plugins for Tree Shaking · 3....
Read more >
Here's how I reduced my bundle size by 90% | by Ajay Poshak
Bundle size was huge. So I looked for some optimizations. On the front of performance also, it was taking 3.25 secs for first...
Read more >
Slimming down your bundle size - LogRocket Blog
Bundle optimization #2: Install lighter-weight alternative libraries. React's bundle size is still a bit large (124KB in our project), even ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found