apollographql / apollo-client-nextjs

Apollo Client support for the Next.js App Router
https://www.npmjs.com/package/@apollo/experimental-nextjs-app-support
MIT License
358 stars 25 forks source link

remove superjson dependency #274

Closed phryneas closed 4 weeks ago

phryneas commented 1 month ago

closes #209

This is a big bundle size reduction for the library itself (see below, -44.93% on what we ship to the browser with the Next.js package), but beyond that it also cuts down a lot on data transported by the library, as SuperJSON adds a lot of extra bulk in their serialization format that we just don't need.

That said, some of our users might have non-serializable values in the cache and also want that transported over, so I'm leaving an escape hatch: stringify and revive can be configured.

relativeci[bot] commented 1 month ago

Job #128: Bundle Size — 1019.48KiB (-1.01%).

b7c0118(current) vs 1f8cda5 main#115(baseline)

[!WARNING] Bundle contains 1 duplicate package – View duplicate packages

Bundle metrics  Change 5 changes Regression 1 regression Improvement 2 improvements
                 Current
Job #128
     Baseline
Job #115
Improvement  Initial JS 880.22KiB(-1.16%) 890.58KiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 1.5% 0%
No change  Chunks 24 24
No change  Assets 45 45
Change  Modules 499(-2.54%) 512
No change  Duplicate Modules 30 30
Regression  Duplicate Code 1.31%(+1.55%) 1.29%
Improvement  Packages 26(-10.34%) 29
No change  Duplicate Packages 1 1

Bundle size by type  Change 1 change Improvement 1 improvement
|            |       Current
[Job #128](https://app.relative-ci.com/projects/fukE5WxC5RnzLcZncFJw/jobs/128-W3OaxEOXI3vYug732pwd?utm_source=github&utm_medium=pr-report "View job report") |      Baseline
[Job #115](https://app.relative-ci.com/projects/fukE5WxC5RnzLcZncFJw/jobs/115-9xgEFBbUDuVGFYBVjWlB?utm_source=github&utm_medium=pr-report "View baseline job report") | |:--|--:|--:| | Improvement  [JS](https://app.relative-ci.com/projects/fukE5WxC5RnzLcZncFJw/jobs/128-W3OaxEOXI3vYug732pwd/assets?ba=%7B%22filters%22%3A%22ft.CSS-0_ft.JS-1_ft.IMG-0_ft.MEDIA-0_ft.FONT-0_ft.HTML-0_ft.OTHER-0%22%7D "View JS assets") | `1013.49KiB` (`-1.01%`) | `1023.84KiB` | | Not changed  [Other](https://app.relative-ci.com/projects/fukE5WxC5RnzLcZncFJw/jobs/128-W3OaxEOXI3vYug732pwd/assets?ba=%7B%22filters%22%3A%22ft.CSS-0_ft.JS-0_ft.IMG-0_ft.MEDIA-0_ft.FONT-0_ft.HTML-0_ft.OTHER-1%22%7D "View Other assets") | `5.99KiB` | `5.99KiB` |

View job #128 reportView pr/remove-superjson branch activityView project dashboard

github-actions[bot] commented 1 month ago

size-limit report 📦

Path Size
{ ApolloNextAppProvider, NextSSRApolloClient, NextSSRInMemoryCache } from '@apollo/experimental-nextjs-app-support/ssr' (Browser ESM) 4.29 KB (-44.93% 🔽)
{ WrapApolloProvider, ApolloClient, InMemoryCache } from '@apollo/client-react-streaming' (Browser ESM) 1.4 KB (0%)
{ buildManualDataTransport } from '@apollo/client-react-streaming/manual-transport' (Browser ESM) 2.6 KB (-58.57% 🔽)
@apollo/client-react-streaming (Browser ESM) 2.13 KB (0%)
@apollo/client-react-streaming (SSR ESM) 1.75 KB (0%)
@apollo/client-react-streaming (RSC ESM) 1.36 KB (0%)
@apollo/client-react-streaming/manual-transport (Browser ESM) 2.8 KB (-56.57% 🔽)
@apollo/client-react-streaming/manual-transport (SSR ESM) 2.76 KB (-56.46% 🔽)
@apollo/experimental-nextjs-app-support/ssr (Browser ESM) 4.91 KB (-41.63% 🔽)
@apollo/experimental-nextjs-app-support/ssr (SSR ESM) 4.86 KB (-41.73% 🔽)
@apollo/experimental-nextjs-app-support/ssr (RSC ESM) 867 B (0%)
@apollo/experimental-nextjs-app-support/rsc (RSC ESM) 626 B (0%)
phryneas commented 1 month ago

I tried to explain this better. I'm really sorry for the 🤯 - I had a ton of difficulties wrapping my mind around what needs to be done here and what's already implicitly happening, too, but I didn't really know how to explain it better (without half a page of text, at least).