helios1138 / graphql-typed-client

A tool that generates a strongly typed client library for any GraphQL endpoint. The client allows writing GraphQL queries as plain JS objects (with type safety, awesome code completion experience, custom scalar type mapping, type guards and more)
MIT License
212 stars 18 forks source link

Reduce bundle size #32

Open remorses opened 4 years ago

remorses commented 4 years ago

Currently the bundle size is pretty big because of lodash and rxjs https://bundlephobia.com/result?p=graphql-typed-client@1.7.4

Lodash impact can be reduced simply by changing the import paths, rxjs instead requires the consumer tree shaking the library to reduce bundle size

To enable tree shaking this library should expose a module version of the lib and generate the entry point code with the import syntax instead of require, this way Webpack can tree shake the unused rxjs operators

remorses commented 4 years ago

Maybe we can remove rxjs altogether? The rxjs dependency is used just for this line (exclduing the map operator that can be easily removed) https://github.com/helios1138/graphql-typed-client/blob/b616fe82725417d378a6be64e23f6b9f3ced5ace/src/client/getSubscriptionCreator.ts#L18

From what i understand this code maintains the connection open for multiple subscribers, isn't this already implemented in subscriptions-transport-ws?