GithubHelp home page GithubHelp logo

Comments (10)

kentcdodds avatar kentcdodds commented on May 26, 2024 2

I'm happy with that so long as the bundle size stays below 15kb 👍 thanks!

from graphql-request.

kentcdodds avatar kentcdodds commented on May 26, 2024 1

Interesting! I'll give it a look. Thanks!

from graphql-request.

kentcdodds avatar kentcdodds commented on May 26, 2024 1

Super! Verified with my reproduction and it's back down to 12.6 KiB. Thank you!

from graphql-request.

divyenduz avatar divyenduz commented on May 26, 2024

Thanks for reporting this. Related issue: graphql/graphql-js#1272

@timsuchanek : We need just the print function from graphql-js, extracting that inline will remove the graphql dependency and reduce bundle size. Sounds good?

I will also add bundle size check in CI.

from graphql-request.

divyenduz avatar divyenduz commented on May 26, 2024

Added bundlesize to CI here: #96
It is still under 3 KB, of course it is not counting the peer dep size.

Is it possible for you to configure webpack to not include unused code from peer dep?

from graphql-request.

kentcdodds avatar kentcdodds commented on May 26, 2024

Is it possible for you to configure webpack to not include unused code from peer dep?

What do you mean? This line is importing the peer dep, so that code is used (though the module may be tree-shaken, that's still a LOT of code). I'm pretty certain that the feature must be dropped entirely. If someone wants that feature then they can use one of the many other libraries that provide this capability... The appeal of graphql-request is its size. If this isn't changed, then I'll probably look for another module or fork this one if I ever need changes, which is fine, I just thought that the goal of this module was to fill the needs of size-conscious people like me.

from graphql-request.

divyenduz avatar divyenduz commented on May 26, 2024

It is definitely a goal to maintain the tiny size of this project. Which is why I want to work with you and reliably detect the impact of any dependencies change in CI.

Currently, the bundlesize check is CI passes. Also, the size reported by bundlephobia is under 15 KB as you had originally asked for.

from graphql-request.

kentcdodds avatar kentcdodds commented on May 26, 2024

Hmm... I updated the example to use 1.8.0 and the bundle size is still the same and I'm still getting the console error.

Maybe there's a bug in bundlephobia. The fact is that graphql-request is using print from graphql which is what's causing the issues. If I remove the line import { print } from 'graphql' then the size goes down to 12.6 KiB.

I don't think it's possible to import print from graphql and keep the filesize down because print requires a LOT of code. And it's impossible to tree-shake that because it's used in the source code. I mean, you could restructure the code so folks who want that support can import another file or something, but I think that would be pointless because people who use that don't care about size and can therefore use another package altogether.

from graphql-request.

divyenduz avatar divyenduz commented on May 26, 2024

@kentcdodds: Thanks for working with me on this one and providing the reproduction. This PR reverts this feature: #97

Further actions for me:-

    • Create issue for reliably detecting bundle size in CI to avoid this regression in future, both bundlephobia and bundlesize didn't work for graphql being a peer dependency.
    • Reopen the issue #10

Thanks!

from graphql-request.

divyenduz avatar divyenduz commented on May 26, 2024

This is release in 1.8.1 🎉

from graphql-request.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.