diff --git a/docs/source/development-testing/reducing-bundle-size.mdx b/docs/source/development-testing/reducing-bundle-size.mdx index 902d9464b25..3ad44edee34 100644 --- a/docs/source/development-testing/reducing-bundle-size.mdx +++ b/docs/source/development-testing/reducing-bundle-size.mdx @@ -3,8 +3,11 @@ title: Reducing bundle size description: Squeeze those last few bytes out of your production build --- -Some quick configuration changes can help you reduce your bundle size: turning off Apollo Client's development mode and picking a consistent style for your imports. -Every byte counts in optimizing your app's performance. +Every byte counts in optimizing your app's performance. This page covers some configuration changes that can help reduce Apollo Client's bundle size: + +- Turn off Apollo Client's development mode +- Pick a consistent style for your imports + ## Turning off development mode @@ -183,12 +186,23 @@ With many modern bundlers, it should not matter which of these styles you choose It is important to keep in mind though that bundlers are complex and it might make a difference - especially when your bundler picks up the CommonJS artifacts instead of the ESM artifacts.
Every bundling setup is different and we cannot guarantee which style results in the smallest bundle size. We recommend trying out these styles in a small setup to determine which results in the best outcome in your environment. -**Note:** some entry points are not part of the "main" entrypoint `'@apollo/client'` and can only be imported directly (e.g. from `'@apollo/client/link/batch'`). It's perfectly fine to use these, even when using the "main" entrypoint. + + +Some entry points are not part of the "main" entry point `'@apollo/client'` and can only be imported directly, for example, from `'@apollo/client/link/batch'`. It's fine to use these, even when using the "main" entry point. + + ## Why have a larger library in the first place? -### What you get -Apollo Client is more than just a simple data fetcher: it is a request/response cache, state manager, and React component integration. Attempting to build a comparable experience to Apollo Client with other libraries would require you to write custom logic, libraries, and components wrappers. Scaling that out to all the components in your application would easily lead to a larger bundle and doing so with a custom and difficult to understand implementation that needs to be maintain by your team. By choosing Apollo Client, you hand off that ownership to a trusted team building Open Source Software since 2016. -### Next major version -Apollo Client v3 supports a large range of browser compatibility, back to IE11. In our next major version we plan to raise those targets which will allow us to remove included polyfills and as well as clean up deprecated features. +Apollo Client is more than a data fetcher. It's a normalized request and response cache, state manager, and React component integration, including React testing utilities. + +To build a similar experience with other libraries, you need to write custom logic, libraries, and component wrappers. Scaling this custom code to all your app components often creates a bundle larger than Apollo Client's. + +A custom implementation also means extra maintenance work for your team. By using Apollo Client, you hand off that ownership to a team specializing in GraphQL clients. + +### Legacy support + +Apollo Client v3 supports legacy JavaScript syntax. It also includes support for some now deprecated features. Similarly, v3 offers broad browser compatibility, extending back to IE11. + +The next major version will prioritize contemporary browser support. This transition will streamline the client by removing unnecessary polyfills and phasing out support for legacy syntax and features. Ultimately, these changes reduce bundle size but require a major version release.