Apollo-feature-requests: Make browser bundles for React Apollo that omit SSR code

Created on 22 Jun 2019  路  6Comments  路  Source: apollographql/apollo-feature-requests

My company (Intuit) leverages a microfrontend architecture for our applications. The current bundling scheme for react-apollo does not nicely support this because it brings in Server Side Rendering code in the UMD bundle. This means we are "paying" for bytes we will never use. To be able to support architectures like this (which, by nature, can't treeshake out code they don't use for shared modules) I'm requesting that a UMD bundle be made that omits functions that only SSR code would use.

For example, removing the following lines in 2.5.7 would slim the bundle significantly

https://github.com/apollographql/react-apollo/blob/3bc993b2ea91704bd6a2667f42d1940656c071ff/src/index.ts#L26-L28

And in the beta channel, the following lines

https://github.com/apollographql/react-apollo/blob/master/packages/all/src/index.ts#L62-L63

For reference, when I do this locally and run the code through webpack, React Apollo is 6 kb for a production bundle. Other bundles are created and excluded because I have to manually dedupe (lack of tree shaking in shared libraries).

image

Ultimately, I'd just like browser targeted code that doesn't have bytes my apps will never use.

project-react-apollo

Most helpful comment

Thanks for the reminder @corysimmons - this will be coming (soon) in RA 3.

All 6 comments

Thanks for the FR @Aghassi, I think this makes a lot of sense. I'll dig into this a bit and see if this is something we can get into the react-apollo 3.0 release.

I think it makes a lot of sense. UMD bundle is not intended for consumption on a server side and as such should be trimmed down.

I do wonder though if you use Webpack, why not configure it to consume ESM format? Webpack will do tree shaking and SSR code should be removed, shouldn't it?

Please follow the implementation of this feature request over at https://github.com/apollographql/react-apollo/pull/3168. Thanks!

Thanks for moving fast on this guys! Very excited to see the size drop. I'll make sure we are prepped internally for this version. I plan to put out an article talking about our use case down the line.

Seems like this was merged https://github.com/apollographql/react-apollo/pull/3168 and can be closed.

Thanks for the reminder @corysimmons - this will be coming (soon) in RA 3.

Was this page helpful?
0 / 5 - 0 ratings