Some notes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Michel Weststrate · committed by Michel Weststrate · parent f1918cb · Browse files · 4 files·+34 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+34 added−10 removed
- other:+34 added−10 removed
Provenance
- Commit
746dc6f- Tree
25ea0d6- Author
Michel Weststrate <mweststrate@fb.com>- Committer
Michel Weststrate <mweststrate@fb.com>- Parent
f1918cb
4 files changed+34 added−10 removed
modified:src/plugins/es5.ts+1 added-1 removed
153 unmodified lines154 if (desc) {155 desc.enumerable = enumerable156 } else {157 descriptors[prop] = desc = {158- configurable: true,158+ // configurable: true,159 enumerable,160 get(this: any) {161 return get(this[DRAFT_STATE], prop)162 },136 unmodified linesmodified:src/plugins/mapset.ts+5 added-6 removed
68 unmodified lines69 // TODO: smaller build size if we create a util for Object.defineProperty70 Object.defineProperty(p, "size", {71 get: function() {72 return latest(this[DRAFT_STATE]).size73- },74- enumerable: true,75- configurable: true73+ }74+ // enumerable: false,75+ // configurable: true76 })77 78 p.has = function(key: any): boolean {79 return latest(this[DRAFT_STATE]).has(key)144 unmodified lines224 225 Object.defineProperty(p, "size", {226 get: function() {227 return latest(this[DRAFT_STATE]).size228- },229- enumerable: true,230- configurable: true228+ }229+ // enumerable: true,230 })231 232 p.has = function(value: any): boolean {233 const state: SetState = this[DRAFT_STATE]106 unmodified linesmodified:src/common.ts+3 added-1 removed
165 unmodified lines166 ): T167 export function shallowCopy(base: any, invokeGetters = false) {168 if (Array.isArray(base)) return base.slice()169 const clone = Object.create(Object.getPrototypeOf(base))170+ // TODO: each?171 ownKeys(base).forEach(key => {172 if (key === DRAFT_STATE) {173 return // Never copy over draft state.174 }31 unmodified lines206 function dontMutateFrozenCollections() {207 invariant(false, "This object has been frozen and should not be mutated")208 }209 210+// TODO: used only once, inline211 export function createHiddenProperty(212 target: AnyObject,213 prop: PropertyKey,214 value: any215 ) {216 Object.defineProperty(target, prop, {217 value: value,216- enumerable: false,218+ // enumerable: false <- the default219 writable: true220 })221 }222 7 unmodified linesmodified:notes.txt+25 added-2 removed
1 Things to optimize2 3 [x] extract errors4 [x] don't enable all features by default5-[ ] "undefined" "object" prototype undefined ?5+[ ] "undefined" "object" "function" prototype undefined + buildin FNs ?6 [x] kill hooks7 [x] _ postfix all members8 [ ] clean up finalize9-[ ] remove die9+[x] remove die10+[ ] own invariant11+[ ] optimize enumerations12+[ ] update docs13+[ ] plugin tests14+[ ] check if we can create more local vars15+[ ] verify performance16+[ ] kill ownKeys?17+[ ] kill isEnumerable?18+[ ] check todos19 20 Import size report for immer:21 ┌───────────────────────┬───────────┬────────────┬───────────┐22 │ (index) │ just this │ cumulative │ increment │34 unmodified lines57 │ enableMapSet │ 4439 │ 5227 │ 799 │58 │ enablePatches │ 4319 │ 5929 │ 702 │59 └───────────────────────┴───────────┴────────────┴───────────┘60 (this report was generated by npmjs.com/package/import-size)61+62+After hooks:[63+ Import size report for immer:64+┌───────────────────────┬───────────┬────────────┬───────────┐65+│ (index) │ just this │ cumulative │ increment │66+├───────────────────────┼───────────┼────────────┼───────────┤67+│ import * from 'immer' │ 5983 │ 0 │ 0 │68+│ produce │ 3454 │ 3454 │ 0 │69+│ enableES5 │ 4270 │ 4278 │ 824 │70+│ enableMapSet │ 4285 │ 5079 │ 801 │71+│ enablePatches │ 4154 │ 5770 │ 691 │72+└───────────────────────┴───────────┴────────────┴───────────┘73+(this report was generated by npmjs.com/package/import-size)74+]