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.

Issues with tree-shaking in v3 beta

See original GitHub issue

Intended outcome:

I would expect these bundles to be roughly the same size:

import {Observable} from 'apollo-boost'
console.log(Observable)

and:

import {Observable} from '@apollo/client'
console.log(Observable)

Actual outcome:

The apollo-boost bundle is 7.6 KiB, whereas the @apollo/client bundle is 94.2 KiB.

How to reproduce the issue:

Compare this branch to this branch. To produce the bundle size measurements, check out either branch and run npm run build.

Versions

For the apollo-boost bundle:

  System:
    OS: macOS Mojave 10.14.6
  Binaries:
    Node: 12.13.1 - ~/.config/nvm/12.13.1/bin/node
    npm: 6.13.4 - ~/.config/nvm/12.13.1/bin/npm
  Browsers:
    Chrome: 79.0.3945.79
    Firefox: 69.0.2
    Safari: 13.0.4
  npmPackages:
    apollo-boost: ^0.4.7 => 0.4.7 

The @apollo/client one is the same except:

  npmPackages:
    @apollo/client: 3.0.0-beta.34 => 3.0.0-beta.34

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:6
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
benjamncommented, Apr 9, 2021

Thanks for all the detailed info @miqdadfwz! We will dig into this before the Apollo Client v3.4 launch is finalized (though probably during the Release Candidate phase, since improving tree-shakeability should be relatively a transparent optimization, not a change in functionality).

2reactions
miqdadfwzcommented, Mar 30, 2021

Well I’m using the same webpack configuration (webpack v4), but ended up with significantly larger size comparing with former AC version.

Here is AC3 result using webpack bundle analyzer, it takes 39kb gzip along with graphql dependency. I’m afraid the tree shaking is partially not working here. Screen Shot 2021-03-30 at 17 15 42

And here for AC2 with same chunks combination and other AC2 dependecies such as apollo-link-* and @apollo/react-hooks, it only takes 26kb. Screen Shot 2021-03-30 at 17 15 35

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use tree shaking in Webpack? - angular - Stack Overflow
I just updated to webpack 2.1.0-beta.15 with an Angular 2 (version rc.2) app (with Typescript), but I was wondering how to use the...
Read more >
Tree Shaking - webpack
Clarifying tree shaking and sideEffects. The sideEffects and usedExports (more known as tree shaking) optimizations are two different things. sideEffects is ...
Read more >
July 29, 2022 Release - React Spectrum Libraries - Adobe
These include tree shaking improvements, large dependency removal, ... @react-aria/checkbox@3.5.0 - @react-aria/color@3.0.0-beta.14 ...
Read more >
Upgrade from version 8 to the modular Web SDK - Firebase
Modular - a new API surface designed to facilitate tree-shaking (removal of ... v8 to v9 beta, change your import statements to use...
Read more >
VueJS 3.0.0 Beta: Features I'm Excited About - Bits and Pieces
Support is now also available in this version for things like tree-shaking. Most features that were optional in Vue are now tree-shakable, ...
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 Reddit Thread

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