Repository navigation
Reduce the bundle size without changing behavior - #121
Merged
Merged
Conversation
size-limit report 📦
|
Merged
MattCCC
force-pushed
the
bundle-size
branch
from
September 27, 2026 21:12
885693b to
161bbcd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request trims the bundle by removing duplicated code and compiler helpers, without changing what the library does. The bundles get 0.1–0.2 KB smaller (2–4%), whichever bundler the app uses.
✨ Features & Improvements
FetchErrordeclared its properties as class fields, which the ES2018 build compiles into adefinePropertyhelper and one call per field. They're now only declared, and set in the constructor in the same order, so errors have exactly the same properties.Setof names plus lowercasing. It matches exactly the same names, which was checked for every name in several cases and for near misses likeaccept-charsetorx-api-keys.[].concat().Filecheck next to theBlobcheck is dropped, as aFileis aBlob.?.compiles to longer code in the ES2018 build, so it's replaced with plain checks where the result is identical. Async functions return values directly instead of wrapping them inPromise.resolve()orPromise.reject().A benchmark later showed that one of these changes, extending custom fetcher responses with one
Object.assign(), made requests with interceptors 2.4% slower. #123 undoes it. Cache key generation got faster (+3% to +11% across runs), andfetchf()andbuildConfig()were within the noise.🔍 Tried and Left Out
🧪 Tests
POSTnot being retried), the interceptor order ofcreateApiFetcher(), cache keys, ETag revalidation,mutate()and merged default headers.📦 Bundle Size
browser/index.mjsbrowser/index.global.jsnode/index.jsreact/index.mjsreact/index.jsMinified, the core goes from 21.8 kB to 21.0 kB (−3.8%), and gzipped from 9.2 kB to 9.0 kB (−2.4%). Measured like in the README comparison, fetchff goes from 9.1 KB to 8.9 KB, and with its React hook from 9.9 KB to 9.7 KB. #120 has the rebuilt
distand the new numbers in the README.