chore: fix some build issues (#701)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* clearer error when plugin is missing * chore: fix travis build not failing, fixes #688 (?) * fix: make plugin loading idempotent, fixes #692 * docs: Organize performance and pitfalls, and document nested produce behavior. Fixes #694 * chore: fix prod-build-issues
authored by Michel Weststrate · committed by GitHub · parent 678e541 · Browse files · 15 files·+224 added−145 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
15 files+224 added−145 removed
- tests:+145 added−122 removed
- other:+79 added−23 removed
Provenance
- Commit
31684f2- Tree
2435d0a- Author
Michel Weststrate <mweststrate@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
678e541
15 files changed+224 added−145 removed
modified:__tests__/__prod_snapshots__/base.js.snap+32 added-48 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3 exports[`base functionality - es5 (autofreeze) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;4 5-exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;5+exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;6 7-exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;7+exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;8 9 exports[`base functionality - es5 (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;10 11 exports[`base functionality - es5 (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines17 exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;18 19 exports[`base functionality - es5 (autofreeze) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;20 21-exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;21+exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;22 23-exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;23+exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;24 25-exports[`base functionality - es5 (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;26-25 exports[`base functionality - es5 (autofreeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;26 27 exports[`base functionality - es5 (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;28 31-exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;29+exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;30 33-exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;31+exports[`base functionality - es5 (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;32 33 exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;34 35 exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines41 exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;42 43 exports[`base functionality - es5 (autofreeze)(patch listener) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;44 47-exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;45+exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;46 49-exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;47+exports[`base functionality - es5 (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;48 51-exports[`base functionality - es5 (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;52-49 exports[`base functionality - es5 (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;50 51 exports[`base functionality - es5 (no freeze) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;52 57-exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;53+exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;54 59-exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;55+exports[`base functionality - es5 (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;56 57 exports[`base functionality - es5 (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;58 59 exports[`base functionality - es5 (no freeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines65 exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;66 67 exports[`base functionality - es5 (no freeze) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;68 73-exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;69+exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;70 75-exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;71+exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;72 77-exports[`base functionality - es5 (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;78-73 exports[`base functionality - es5 (no freeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;74 75 exports[`base functionality - es5 (patch listener) async recipe function works with rejected promises 1`] = `"[Immer] minified error nr: 3 {\\"a\\":0,\\"b\\":1}. Find the full error at: https://bit.ly/3cXEKWf"`;76 83-exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;77+exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;78 85-exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;79+exports[`base functionality - es5 (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;80 81 exports[`base functionality - es5 (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;82 83 exports[`base functionality - es5 (patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;5 unmodified lines89 exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 3`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;90 91 exports[`base functionality - es5 (patch listener) revokes the draft once produce returns 4`] = `"[Immer] minified error nr: 3 [1]. Find the full error at: https://bit.ly/3cXEKWf"`;92 99-exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;93+exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;94 101-exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;95+exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;96 103-exports[`base functionality - es5 (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;104-97 exports[`base functionality - es5 (patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;98 99 exports[`base functionality - proxy (autofreeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;100 109-exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;101+exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;102 111-exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;103+exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;104 105 exports[`base functionality - proxy (autofreeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;106 107 exports[`base functionality - proxy (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines121 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;122 123 exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;124 133-exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;125+exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;126 135-exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;127+exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;128 137-exports[`base functionality - proxy (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;138-129 exports[`base functionality - proxy (autofreeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;130 131 exports[`base functionality - proxy (autofreeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;132 133 exports[`base functionality - proxy (autofreeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;134 135 exports[`base functionality - proxy (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;136 147-exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;137+exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;138 149-exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;139+exports[`base functionality - proxy (autofreeze)(patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;140 141 exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;142 143 exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines157 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;158 159 exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;160 171-exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;161+exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;162 173-exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;163+exports[`base functionality - proxy (autofreeze)(patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;164 175-exports[`base functionality - proxy (autofreeze)(patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;176-165 exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;166 167 exports[`base functionality - proxy (autofreeze)(patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;168 169 exports[`base functionality - proxy (autofreeze)(patch listener) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;170 171 exports[`base functionality - proxy (no freeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;172 185-exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;173+exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;174 187-exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;175+exports[`base functionality - proxy (no freeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;176 177 exports[`base functionality - proxy (no freeze) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;178 179 exports[`base functionality - proxy (no freeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines193 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;194 195 exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;196 209-exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;197+exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;198 211-exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;199+exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;200 213-exports[`base functionality - proxy (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;214-201 exports[`base functionality - proxy (no freeze) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;202 203 exports[`base functionality - proxy (no freeze) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;204 205 exports[`base functionality - proxy (no freeze) throws when the draft is modified and another object is returned 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;206 207 exports[`base functionality - proxy (patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;208 223-exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;209+exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;210 225-exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;211+exports[`base functionality - proxy (patch listener) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;212 213 exports[`base functionality - proxy (patch listener) recipe functions cannot return a modified child draft 1`] = `"[Immer] minified error nr: 4. Find the full error at: https://bit.ly/3cXEKWf"`;214 215 exports[`base functionality - proxy (patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;13 unmodified lines229 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;230 231 exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;232 247-exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;233+exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;234 249-exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;235+exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;236 251-exports[`base functionality - proxy (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;252-237 exports[`base functionality - proxy (patch listener) throws when Object.defineProperty() is used on drafts 1`] = `"[Immer] minified error nr: 11. Find the full error at: https://bit.ly/3cXEKWf"`;238 239 exports[`base functionality - proxy (patch listener) throws when Object.setPrototypeOf() is used on a draft 1`] = `"[Immer] minified error nr: 12. Find the full error at: https://bit.ly/3cXEKWf"`;240 377 unmodified linesmodified:__tests__/__prod_snapshots__/patch.js.snap+3 added-3 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"[Immer] minified error nr: 17 copy. Find the full error at: https://bit.ly/3cXEKWf"`;3+exports[`applyPatches throws when \`op\` is not "add", "replace", nor "remove" 1`] = `"[Immer] minified error nr: 17 'copy'. Find the full error at: https://bit.ly/3cXEKWf"`;4 5-exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 a/b. Find the full error at: https://bit.ly/3cXEKWf"`;5+exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 'a/b'. Find the full error at: https://bit.ly/3cXEKWf"`;6 7-exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"[Immer] minified error nr: 15 a/b/c. Find the full error at: https://bit.ly/3cXEKWf"`;7+exports[`applyPatches throws when \`path\` cannot be resolved 2`] = `"[Immer] minified error nr: 15 'a/b/c'. Find the full error at: https://bit.ly/3cXEKWf"`;modified:__tests__/__prod_snapshots__/plugins.js.snap+5 added-5 removed
1 // Jest Snapshot v1, https://goo.gl/fbAQLP2 3-exports[`ES5 plugins should throw if no proxies are available error when using ES5 1`] = `"[Immer] minified error nr: 19 ES5. Find the full error at: https://bit.ly/3cXEKWf"`;3+exports[`ES5 plugins should throw if no proxies are available error when using ES5 1`] = `"[Immer] minified error nr: 18 'ES5'. Find the full error at: https://bit.ly/3cXEKWf"`;4 5-exports[`error when using Maps 1`] = `"[Immer] minified error nr: 19 MapSet. Find the full error at: https://bit.ly/3cXEKWf"`;5+exports[`error when using Maps 1`] = `"[Immer] minified error nr: 18 'MapSet'. Find the full error at: https://bit.ly/3cXEKWf"`;6 7-exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;7+exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;8 9-exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;9+exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;10 11-exports[`error when using patches - 3 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;11+exports[`error when using patches - 3 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;modified:__tests__/base.js+56 added-51 removed
14 unmodified lines15 jest.setTimeout(1000)16 17 enableAllPlugins()18 19+const isProd = process.env.NODE_ENV === "production"20+21 test("immer should have no dependencies", () => {22 expect(require("../package.json").dependencies).toBeUndefined()23 })24 1121 unmodified lines1146 expect(nextState.aProp).toBe(undefined)1147 })1148 1149 // NOTE: ES5 drafts only protect existing properties when revoked.1150+ if (!isProd)1148- it("revokes the draft once produce returns", () => {1149- const expectRevoked = (fn, shouldThrow = true) => {1150- if (shouldThrow) expect(fn).toThrowErrorMatchingSnapshot()1151- else expect(fn).not.toThrow()1152- }1151+ it("revokes the draft once produce returns", () => {1152+ const expectRevoked = (fn, shouldThrow = true) => {1153+ if (shouldThrow) expect(fn).toThrowErrorMatchingSnapshot()1154+ else expect(fn).not.toThrow()1155+ }1156 1154- // Test object drafts:1155- let draft1156- produce({a: 1, b: 1}, s => {1157- draft = s1158- delete s.b1159- })1157+ // Test object drafts:1158+ let draft1159+ produce({a: 1, b: 1}, s => {1160+ draft = s1161+ delete s.b1162+ })1163 1161- // Access known property on object draft.1162- expectRevoked(() => {1163- draft.a1164- })1164+ // Access known property on object draft.1165+ expectRevoked(() => {1166+ draft.a1167+ })1168 1166- // Assign known property on object draft.1167- expectRevoked(() => {1168- draft.a = true1169- })1169+ // Assign known property on object draft.1170+ expectRevoked(() => {1171+ draft.a = true1172+ })1173 1171- // Access unknown property on object draft.1172- expectRevoked(() => {1173- draft.z1174- }, useProxies)1174+ // Access unknown property on object draft.1175+ expectRevoked(() => {1176+ draft.z1177+ }, useProxies)1178 1176- // Assign unknown property on object draft.1177- expectRevoked(() => {1178- draft.z = true1179- }, useProxies)1179+ // Assign unknown property on object draft.1180+ expectRevoked(() => {1181+ draft.z = true1182+ }, useProxies)1183 1181- // Test array drafts:1182- produce([1, 2], s => {1183- draft = s1184- s.pop()1185- })1184+ // Test array drafts:1185+ produce([1, 2], s => {1186+ draft = s1187+ s.pop()1188+ })1189 1187- // Access known index of an array draft.1188- expectRevoked(() => {1189- draft[0]1190- })1190+ // Access known index of an array draft.1191+ expectRevoked(() => {1192+ draft[0]1193+ })1194 1192- // Assign known index of an array draft.1193- expectRevoked(() => {1194- draft[0] = true1195- })1195+ // Assign known index of an array draft.1196+ expectRevoked(() => {1197+ draft[0] = true1198+ })1199 1197- // Access unknown index of an array draft.1198- expectRevoked(() => {1199- draft[1]1200- }, useProxies)1200+ // Access unknown index of an array draft.1201+ expectRevoked(() => {1202+ draft[1]1203+ }, useProxies)1204 1202- // Assign unknown index of an array draft.1203- expectRevoked(() => {1204- draft[1] = true1205- }, useProxies)1206- })1205+ // Assign unknown index of an array draft.1206+ expectRevoked(() => {1207+ draft[1] = true1208+ }, useProxies)1209+ })1210 1211 it("can access a child draft that was created before the draft was modified", () => {1212 produce({a: {}}, s => {1213 const before = s.a485 unmodified lines1699 throw "failed"1700 },1701 e => {1702 expect(e).toBe(err)1700- expect(() => draft.a).toThrowErrorMatchingSnapshot()1703+ if (!isProd) expect(() => draft.a).toThrowErrorMatchingSnapshot()1704 }1705 )1706 })1707 712 unmodified lines2420 produce(value, draft => {2421 draft.foo = true2422 })2423 ).toThrowError(2424+ isProd2425+ ? "[Immer] minified error nr: 21"2421- "produce can only be called on things that are draftable"2426+ : "produce can only be called on things that are draftable"2427 )2428 })2429 } else {2430 it("does not create a draft", () => {27 unmodified linesmodified:__tests__/current.js+7 added-1 removed
12 unmodified lines13 14 runTests("proxy", true)15 runTests("es5", false)16 17+const isProd = process.env.NODE_ENV === "production"18+19 function runTests(name, useProxies) {20 describe("current - " + name, () => {21 beforeAll(() => {22 setAutoFreeze(true)2 unmodified lines25 26 it("must be called on draft", () => {27 expect(() => {28 current({})27- }).toThrowError("[Immer] 'current' expects a draft, got: [object Object]")29+ }).toThrowError(30+ isProd31+ ? "[Immer] minified error nr: 22 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"32+ : "[Immer] 'current' expects a draft, got: [object Object]"33+ )34 })35 36 it("can handle simple arrays", () => {37 const base = [{x: 1}]175 unmodified linesmodified:__tests__/manual.js+12 added-9 removed
8 unmodified lines910111213141516171823 unmodified lines4243444546444547484947484950515253505152535455565758596085 unmodified lines8 unmodified lines} from "../src/immer"
enableAllPlugins()
const isProd = process.env.NODE_ENV === "production"
runTests("proxy", true)runTests("es5", false)
function runTests(name, useProxies) {23 unmodified lines expect(result).toEqual([{index: 0}, {index: 1}, {index: 2}]) expect(state).toEqual([{}, {}, {}]) })
if (!isProd) it("cannot modify after finish", () => { const state = {a: 1} it("cannot modify after finish", () => { const state = {a: 1}
const draft = createDraft(state) draft.a = 2 expect(finishDraft(draft)).toEqual({a: 2}) expect(() => { draft.a = 3 }).toThrowErrorMatchingSnapshot() }) const draft = createDraft(state) draft.a = 2 expect(finishDraft(draft)).toEqual({a: 2}) expect(() => { draft.a = 3 }).toThrowErrorMatchingSnapshot() })
it("should support patches drafts", () => { const state = {a: 1}
85 unmodified linesmodified:__tests__/map-set.js+16 added-1 removed
3 unmodified lines4 nothing,5 original,6 isDraft,7 immerable,8- enableAllPlugins8+ enableAllPlugins,9+ enableMapSet10 } from "../src/immer"11 import {each, shallowCopy, isEnumerable, DRAFT_STATE} from "../src/common"12 13 enableAllPlugins()266 unmodified lines280 draft.clear()281 })282 expect(result).toBe(set)283 })284+285+ test("#692 - idempotent plugin loading", () => {286+ let mapType1287+ produce(new Map(), draft => {288+ mapType1 = draft.constructor289+ })290+291+ enableMapSet()292+ let mapType2293+ produce(new Map(), draft => {294+ mapType2 = draft.constructor295+ })296+ expect(mapType1).toBe(mapType2)297+ })298 })299 }modified:__tests__/original.js+14 added-4 removed
1 unmodified line2 import produce, {original, setUseProxies, enableAllPlugins} from "../src/immer"3 4 enableAllPlugins()5 6+const isProd = process.env.NODE_ENV === "production"7+8 describe("original", () => {9 const baseState = {10 a: [],11 b: {}29 unmodified lines41 produce(baseState, draftState => {42 draftState.c = {}43 draftState.d = 344 expect(() => original(draftState.c)).toThrowErrorMatchingInlineSnapshot(45+ isProd46+ ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"`43- `"[Immer] 'original' expects a draft, got: [object Object]"`47+ : `"[Immer] 'original' expects a draft, got: [object Object]"`48 )49 expect(() => original(draftState.d)).toThrowErrorMatchingInlineSnapshot(50+ isProd51+ ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"`46- `"[Immer] 'original' expects a draft, got: 3"`52+ : `"[Immer] 'original' expects a draft, got: 3"`53 )54 })55 })56 57 it("should return undefined for an object that is not proxied", () => {58 expect(() => original({})).toThrowErrorMatchingInlineSnapshot(59+ isProd60+ ? `"[Immer] minified error nr: 23 '[object Object]'. Find the full error at: https://bit.ly/3cXEKWf"`53- `"[Immer] 'original' expects a draft, got: [object Object]"`61+ : `"[Immer] 'original' expects a draft, got: [object Object]"`62 )63 expect(() => original(3)).toThrowErrorMatchingInlineSnapshot(64+ isProd65+ ? `"[Immer] minified error nr: 23 '3'. Find the full error at: https://bit.ly/3cXEKWf"`56- `"[Immer] 'original' expects a draft, got: 3"`66+ : `"[Immer] 'original' expects a draft, got: 3"`67 )68 })69 })modified:docs/performance.md+15 added-3 removed
40 unmodified lines41 - The ES5 fallback implementation is roughly twice as slow as the proxy implementation, in some cases worse.42 43 ## Performance tips44 45-- When adding a large data set to the state tree in an Immer producer (for example data received from a JSON endpoint), it is worth to call `Object.freeze(json)` on the root of the data to be added first. This will allow Immer to add the new data to the tree faster, as it will skip freezing it, or searching the tree for any changes (drafts) that might be made.46-- Immer will convert anything you read in a draft recursively into a draft as well. If you have expensive side effect free operations on a draft that involves a lot of reading, for example finding an index using `find(Index)` in a very large array, you can speed this up by first doing the search, and only call the `produce` function once you know the index. Thereby preventing Immer to turn everything that was searched for in a draft. Or, perform the search on the original value of a draft, by using `original(someDraft)`, which boils to the same thing.47-- Always try to pull produce 'up', for example `for (let x of y) produce(base, d => d.push(x))` is exponentially slower than `produce(base, d => { for (let x of y) d.push(x)})`45+### Pre-freeze data46+47+When adding a large data set to the state tree in an Immer producer (for example data received from a JSON endpoint), it is worth to call `Object.freeze(json)` on the root of the data to be added first. This will allow Immer to add the new data to the tree faster, as it will skip freezing it, or searching the tree for any changes (drafts) that might be made.48+49+### You can always opt-out50+51+Realize that immer is opt-in everywhere, so it is perfectly fine to manually write super performance critical reducers, and use immer for all the normal ones. Even from within a producer you opt-out from Immer for certain parts of your logic by using utilies `original` or `current` and perform some of your operations on plain JavaScript objects.52+53+### For expensive search operations, read from the original state, not the draft54+55+Immer will convert anything you read in a draft recursively into a draft as well. If you have expensive side effect free operations on a draft that involves a lot of reading, for example finding an index using `find(Index)` in a very large array, you can speed this up by first doing the search, and only call the `produce` function once you know the index. Thereby preventing Immer to turn everything that was searched for in a draft. Or, alternatively, perform the search on the original value of a draft, by using `original(someDraft)`, which boils to the same thing.56+57+### Pull produce as far up as possible58+59+Always try to pull produce 'up', for example `for (let x of y) produce(base, d => d.push(x))` is exponentially slower than `produce(base, d => { for (let x of y) d.push(x)})`modified:docs/pitfalls.md+47 added-10 removed
5 unmodified lines6 <center>7 <div data-ea-publisher="immerjs" data-ea-type="image" class="horizontal bordered"></div>8 </center>9 10-1. For performance tips, see [Performance Tips](https://immerjs.github.io/immer/docs/performance/#performance-tips).11-1. Don't redefine draft like, `draft = myCoolNewState`. Instead, either modify the `draft` or return a new state. See [Returning data from producers](https://immerjs.github.io/immer/docs/return).12-1. Immer assumes your state to be a unidirectional tree. That is, no object should appear twice in the tree, and there should be no circular references.13-1. Since Immer uses proxies, reading huge amounts of data from state comes with an overhead (especially in the ES5 implementation). If this ever becomes an issue (measure before you optimize!), do the current state analysis before entering the producer function or read from the `currentState` rather than the `draftState`. Also, realize that immer is opt-in everywhere, so it is perfectly fine to manually write super performance critical reducers, and use immer for all the normal ones. Also note that `original` can be used to get the original state of an object, which is cheaper to read.14-1. It is possible to return values from producers, except, it is not possible to return `undefined` that way, as it is indistinguishable from not updating the draft at all! If you want to replace the draft with `undefined`, just return `nothing` from the producer.15-1. Immer [does not support exotic objects](https://github.com/immerjs/immer/issues/504) such as window.location.16-1. You will need to enable your own classes to work properly with Immer. For docs on the topic, check out the section on [working with complex objects](https://immerjs.github.io/immer/docs/complex-objects).17-1. For arrays, only numeric properties and the `length` property can be mutated. Custom properties are not preserved on arrays.18-1. Note that data that comes from the closure, and not from the base state, will never be drafted, even when the data has become part of the new draft:19-1. The set of patches generated by Immer should be correct, that is, applying them to an equal base object should result in the same end state. However Immer does not guarantee the generated set of patches will be optimal, that is, the minimum set of patches possible.10+### Performance tipes11 12+For performance tips, see [Performance Tips](https://immerjs.github.io/immer/docs/performance/#performance-tips).13+14+### Don't reassign the recipe argument15+16+Never reassign the `draft` argument (example: `draft = myCoolNewState`). Instead, either modify the `draft` or return a new state. See [Returning data from producers](https://immerjs.github.io/immer/docs/return).17+18+### Immer only supports unidirectional trees19+20+Immer assumes your state to be a unidirectional tree. That is, no object should appear twice in the tree, there should be no circular references. There should be exactly one path from the root to any node of the tree.21+22+### Never explicitly return `undefined` from a producer23+24+It is possible to return values from producers, except, it is not possible to return `undefined` that way, as it is indistinguishable from not updating the draft at all! If you want to replace the draft with `undefined`, just return `nothing` from the producer.25+26+### Don't mutate exotic objects27+28+Immer [does not support exotic objects](https://github.com/immerjs/immer/issues/504) such as window.location.29+30+### Classes should be made draftable or not mutated31+32+You will need to enable your own classes to work properly with Immer. For docs on the topic, check out the section on [working with complex objects](https://immerjs.github.io/immer/docs/complex-objects).33+34+### Only valid indices and length can be mutated on Arrays35+36+For arrays, only numeric properties and the `length` property can be mutated. Custom properties are not preserved on arrays.37+38+### Data not originating from the state will never be drafted39+40+Note that data that comes from the closure, and not from the base state, will never be drafted, even when the data has become part of the new draft.41+42 ```javascript43 function onReceiveTodo(todo) {44 const nextTodos = produce(todos, draft => {45 draft.todos[todo.id] = todo7 unmodified lines53 draft.todos[todo.id] = todo54 })55 }56 ```57+58+### Immer patches are not necessarily optimal59+60+The set of patches generated by Immer should be correct, that is, applying them to an equal base object should result in the same end state. However Immer does not guarantee the generated set of patches will be optimal, that is, the minimum set of patches possible.61+62+### Always use the result of nested producers63+64+Nested `produce` calls are supported, but note that `produce` will _always_ produce a new state, so even when passing a draft to a nested produce, the changes made by the inner produce won't be visibile in the draft that was passed it, but only in the output that is produced. In other words, when using nested produce, you get a draft of a draft and the result of the inner produce should be merged back into the original draft (or returned). For example `produce(state, draft => { produce(draft.user, userDraft => { userDraft.name += "!" })})` won't work as the output if the inner produce isn't used. The correct way to use nested producers is:65+66+```javascript67+produce(state, draft => {68+ draft.user = produce(draft.user, userDraft => {69+ userDraft.name += "!"70+ })71+})72+```modified:src/utils/errors.ts+1 added-2 removed
27 unmodified lines28 },29 18(plugin: string) {30 return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`31 },32- 19: "plugin not loaded",32 20: "Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",33 21(thing: string) {34 return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`35 },16 unmodified lines52 throw new Error(`[Immer] ${msg}`)53 }54 throw new Error(55 `[Immer] minified error nr: ${error}${57- args.length ? " " + args.join(",") : ""56+ args.length ? " " + args.map(s => `'${s}'`).join(",") : ""57 }. Find the full error at: https://bit.ly/3cXEKWf`58 )59 }modified:src/utils/plugins.ts+2 added-2 removed
50 unmodified lines51 pluginKey: K52 ): Exclude<Plugins[K], undefined> {53 const plugin = plugins[pluginKey]54 if (!plugin) {55- die(__DEV__ ? 18 : 19, pluginKey)55+ die(18, pluginKey)56 }57 // @ts-ignore58 return plugin59 }1 unmodified line61 export function loadPlugin<K extends keyof Plugins>(62 pluginKey: K,63 implementation: Plugins[K]64 ): void {65- plugins[pluginKey] = implementation65+ if (!plugins[pluginKey]) plugins[pluginKey] = implementation66 }67 68 /** ES5 Plugin */69 43 unmodified linesmodified:.travis.yml+6 added-5 removed
1 language: node_js2 node_js:3- - "10.18.1"4- # - "node"3+ # - "10.18.1"4+ - "node"5 env:6 - NODE_ENV=TEST7 cache:8 yarn: true2 unmodified lines11 before_script:12 - yarn global add if-node-version13 script:14 - yarn build || travis_terminate 115- - if-node-version 10 || { yarn test && travis_terminate 0; }16- - yarn coveralls15+ - yarn test || travis_terminate 116+ - yarn coveralls || travis_terminate 017 jobs:18 include:19 - stage: deploy20 if: branch == master && !fork21 script:22- - NODE_ENV= yarn build22+ - yarn test || travis_terminate 123+ - NODE_ENV= yarn build || travis_terminate 124 - yarn semantic-releaseadded:ignoreObseleteSnapshots.js+6 added
1+module.exports = function(results) {2+ // don't count obselete snapshot as a failure, but just check if there are no failing tests3+ // console.dir(results)4+ results.success = results.testResults.every(r => r.numFailingTests === 0)5+ return results6+}modified:jest.config.build.js+2 added-1 removed
12 unmodified lines13 },14 preset: "ts-jest/presets/js-with-ts",15 testEnvironment: "node",16 testMatch: ["**/__tests__/**/*.[jt]s?(x)"],17- snapshotResolver: "<rootDir>/jest.config.build.snapshots.js"17+ snapshotResolver: "<rootDir>/jest.config.build.snapshots.js",18+ testResultsProcessor: "<rootDir>/ignoreObseleteSnapshots.js"19 }