Decompose StateImpl class for tree-shaking#35
Merged
Conversation
Replace monolithic StateImpl class with module-level functions and a createState closure factory. Bundlers can now eliminate unused exports — importing only `state` drops derive, select, lens and all lens helpers (87.5% size reduction for state-only consumers).
Measure heap delta per benchmark run using process.memoryUsage().heapUsed with forced GC before each run for a clean baseline. Reports median heap delta in KB alongside existing timing stats. Adds --expose-gc flag to the benchmark npm script.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
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
StateImplclass with module-level functions and acreateStateclosure factory, enabling bundlers to tree-shake unused exportsheap=XXkb) usingprocess.memoryUsage().heapUsedwith forced GCsideEffects: falsetopackage.jsonResults
Tree-shaking: Importing only
statereduces bundle from 5,443 bytes to 680 bytes (87.5% reduction).createDerive,createSelect,createLens,createEffectare all eliminated when unused.Performance (A/B, same session):
get(): -39% (closure eliminatesinstance.get()indirection)set(): -32%Test plan
--expose-gc, heap column reports meaningful values