Aggressive bundle size optimization: 1908 → 1792 bytes (-116 bytes, -6%)#77
Open
Aggressive bundle size optimization: 1908 → 1792 bytes (-116 bytes, -6%)#77
Conversation
Result: {"status":"keep","size_bytes":1908,"raw_bytes":11989}
… saves 2 bytes
Result: {"status":"keep","size_bytes":1906,"raw_bytes":11891}
Result: {"status":"keep","size_bytes":1893,"raw_bytes":11809}
… — saves 13 bytes
Result: {"status":"keep","size_bytes":1880,"raw_bytes":11710}
… 12 bytes
Result: {"status":"keep","size_bytes":1868,"raw_bytes":11590}
Result: {"status":"keep","size_bytes":1866,"raw_bytes":11591}
…s 6 bytes
Result: {"status":"keep","size_bytes":1860,"raw_bytes":11522}
…ion — saves 10 bytes
Result: {"status":"keep","size_bytes":1850,"raw_bytes":11511}
…n — saves 2 bytes
Result: {"status":"keep","size_bytes":1848,"raw_bytes":11498}
Result: {"status":"keep","size_bytes":1845,"raw_bytes":11497}
Result: {"status":"keep","size_bytes":1840,"raw_bytes":11456}
Result: {"status":"keep","size_bytes":1839,"raw_bytes":11450}
Result: {"status":"keep","size_bytes":1834,"raw_bytes":11420}
Result: {"status":"keep","size_bytes":1831,"raw_bytes":11409}
Result: {"status":"keep","size_bytes":1830,"raw_bytes":11395}
…s, eliminates 1 TS error
Result: {"status":"keep","size_bytes":1826,"raw_bytes":11292}
Result: {"status":"keep","size_bytes":1825,"raw_bytes":11286}
Result: {"status":"keep","size_bytes":1819,"raw_bytes":11207}
Result: {"status":"keep","size_bytes":1811,"raw_bytes":11174}
…es 1 byte
Result: {"status":"keep","size_bytes":1810,"raw_bytes":11156}
Result: {"status":"keep","size_bytes":1809,"raw_bytes":11152}
… 1800!
Result: {"status":"keep","size_bytes":1800,"raw_bytes":11117}
Result: {"status":"keep","size_bytes":1795,"raw_bytes":11093}
…aves 6 bytes, eliminates last TS error
Result: {"status":"keep","size_bytes":1789,"raw_bytes":11088}
…ns) — saves 3 bytes
Result: {"status":"keep","size_bytes":1786,"raw_bytes":11087}
… 4 bytes
Result: {"status":"keep","size_bytes":1782,"raw_bytes":11091}
Result: {"status":"keep","size_bytes":1778,"raw_bytes":11084}
…ibe already handles it, saves 25 bytes!
Result: {"status":"keep","size_bytes":1753,"raw_bytes":10878}
Result: {"status":"keep","size_bytes":1752,"raw_bytes":10845}
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.
Summary
This PR implements aggressive bundle size optimizations across the entire codebase, reducing the gzipped bundle from 1908 bytes to 1792 bytes (a 116-byte or ~6% reduction).
Key Optimizations
Core Changes (
lib/factory.ts)Removed redundant code patterns
_revalidateOnIntervalMap in favor of a local variablegetCachedValueByKeyfunction, inlined at call siteshandleNewListenerandrunRefetcherinto single functionSimplified control flow
firstRun+currentKeyValueblock inonStart—subscribealready handles initializationif/elsechains to ternary expressions where appropriateFunction and variable optimizations
for...ofloops withforEach(5-9 bytes per occurrence)Symbol()to plain object{}forfetcherSymbol(1 byte)prevKey = fetcherStore.key = newKeyType and property simplifications
void 0property initializations in mutator store??operator:opts?.throttleCalls ?? truesafeKeySethelper with direct inline checksasyncfromfetcherStore.fetch(returns promise already)Cache iteration improvements
for...of cache.keys()withcache.forEach(6 bytes)getKeyStore, using parallel arrays instead (4 bytes + 1 TS error fix)Platform Adapter (
lib/platforms/browser.ts)typeof windowcheck incanSubbooleanisServervariable, using expression directlyError Messages and Warnings
console.warnfrom__unsafeOverruleSettings(13 bytes)Error()wrappernewkeyword (minor size reduction)Developer Experience
pnpm-workspace.yamlto fix pnpm build warnings.gitignoreto exclude autoresearch artifactsImpact
Testing
pnpm test:unit)Commits
This PR contains ~30 granular commits, each addressing a specific size optimization with detailed commit messages explaining the byte savings.