Skip to content
Myr

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

15 files+224 added−145 removed

modified:__tests__/__prod_snapshots__/base.js.snap+32 added-48 removed
1// Jest Snapshot v1, https://goo.gl/fbAQLP23exports[`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"`;45exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;5exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;67exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;7exports[`base functionality - es5 (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;89exports[`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"`;1011exports[`base functionality - es5 (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
5 unmodified lines
17exports[`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"`;1819exports[`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"`;2021exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;21exports[`base functionality - es5 (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;2223exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;23exports[`base functionality - es5 (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;2425exports[`base functionality - es5 (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;2625exports[`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"`;2627exports[`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"`;2831exports[`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"`;29exports[`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"`;3033exports[`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"`;31exports[`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"`;3233exports[`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"`;3435exports[`base functionality - es5 (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
5 unmodified lines
41exports[`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"`;4243exports[`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"`;4447exports[`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"`;45exports[`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"`;4649exports[`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"`;47exports[`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"`;4851exports[`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"`;5249exports[`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"`;5051exports[`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"`;5257exports[`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"`;53exports[`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"`;5459exports[`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"`;55exports[`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"`;5657exports[`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"`;5859exports[`base functionality - es5 (no freeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
5 unmodified lines
65exports[`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"`;6667exports[`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"`;6873exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;69exports[`base functionality - es5 (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;7075exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;71exports[`base functionality - es5 (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;7277exports[`base functionality - es5 (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;7873exports[`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"`;7475exports[`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"`;7683exports[`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"`;77exports[`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"`;7885exports[`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"`;79exports[`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"`;8081exports[`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"`;8283exports[`base functionality - es5 (patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
5 unmodified lines
89exports[`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"`;9091exports[`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"`;9299exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;93exports[`base functionality - es5 (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;94101exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;95exports[`base functionality - es5 (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;96103exports[`base functionality - es5 (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;10497exports[`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"`;9899exports[`base functionality - proxy (autofreeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;100109exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;101exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;102111exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;103exports[`base functionality - proxy (autofreeze) map drafts revokes map proxies 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;104105exports[`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"`;106107exports[`base functionality - proxy (autofreeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
13 unmodified lines
121exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;122123exports[`base functionality - proxy (autofreeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;124133exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;125exports[`base functionality - proxy (autofreeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;126135exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;127exports[`base functionality - proxy (autofreeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;128137exports[`base functionality - proxy (autofreeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;138129exports[`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"`;130131exports[`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"`;132133exports[`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"`;134135exports[`base functionality - proxy (autofreeze)(patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;136147exports[`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"`;137exports[`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"`;138149exports[`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"`;139exports[`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"`;140141exports[`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"`;142143exports[`base functionality - proxy (autofreeze)(patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
13 unmodified lines
157exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;158159exports[`base functionality - proxy (autofreeze)(patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;160171exports[`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"`;161exports[`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"`;162173exports[`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"`;163exports[`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"`;164175exports[`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"`;176165exports[`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"`;166167exports[`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"`;168169exports[`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"`;170171exports[`base functionality - proxy (no freeze) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;172185exports[`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"`;173exports[`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"`;174187exports[`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"`;175exports[`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"`;176177exports[`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"`;178179exports[`base functionality - proxy (no freeze) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
13 unmodified lines
193exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;194195exports[`base functionality - proxy (no freeze) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;196209exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;197exports[`base functionality - proxy (no freeze) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;198211exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;199exports[`base functionality - proxy (no freeze) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;200213exports[`base functionality - proxy (no freeze) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;214201exports[`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"`;202203exports[`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"`;204205exports[`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"`;206207exports[`base functionality - proxy (patch listener) async recipe function works with rejected promises 1`] = `"Cannot perform 'get' on a proxy that has been revoked"`;208223exports[`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"`;209exports[`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"`;210225exports[`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"`;211exports[`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"`;212213exports[`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"`;214215exports[`base functionality - proxy (patch listener) recipe functions cannot return an object that references itself 1`] = `"Maximum call stack size exceeded"`;
13 unmodified lines
229exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 7`] = `"Cannot perform 'get' on a proxy that has been revoked"`;230231exports[`base functionality - proxy (patch listener) revokes the draft once produce returns 8`] = `"Cannot perform 'set' on a proxy that has been revoked"`;232247exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;233exports[`base functionality - proxy (patch listener) set drafts revokes sets 1`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;234249exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 {}. Find the full error at: https://bit.ly/3cXEKWf"`;235exports[`base functionality - proxy (patch listener) set drafts revokes sets 2`] = `"[Immer] minified error nr: 3 '{}'. Find the full error at: https://bit.ly/3cXEKWf"`;236251exports[`base functionality - proxy (patch listener) throws on computed properties 1`] = `"[Immer] minified error nr: 1. Find the full error at: https://bit.ly/3cXEKWf"`;252237exports[`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"`;238239exports[`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 lines
modified:__tests__/__prod_snapshots__/patch.js.snap+3 added-3 removed
1// Jest Snapshot v1, https://goo.gl/fbAQLP23exports[`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"`;3exports[`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"`;45exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 a/b. Find the full error at: https://bit.ly/3cXEKWf"`;5exports[`applyPatches throws when \`path\` cannot be resolved 1`] = `"[Immer] minified error nr: 15 'a/b'. Find the full error at: https://bit.ly/3cXEKWf"`;67exports[`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"`;7exports[`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/fbAQLP23exports[`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"`;3exports[`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"`;45exports[`error when using Maps 1`] = `"[Immer] minified error nr: 19 MapSet. Find the full error at: https://bit.ly/3cXEKWf"`;5exports[`error when using Maps 1`] = `"[Immer] minified error nr: 18 'MapSet'. Find the full error at: https://bit.ly/3cXEKWf"`;67exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;7exports[`error when using patches - 1 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;89exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;9exports[`error when using patches - 2 1`] = `"[Immer] minified error nr: 18 'Patches'. Find the full error at: https://bit.ly/3cXEKWf"`;1011exports[`error when using patches - 3 1`] = `"[Immer] minified error nr: 19 Patches. Find the full error at: https://bit.ly/3cXEKWf"`;11exports[`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 lines
15jest.setTimeout(1000)1617enableAllPlugins()1819const isProd = process.env.NODE_ENV === "production"2021test("immer should have no dependencies", () => {22 expect(require("../package.json").dependencies).toBeUndefined()23})24
1121 unmodified lines
1146 expect(nextState.aProp).toBe(undefined)1147 })11481149 // 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 }11561154 // 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 })11631161 // Access known property on object draft.1162 expectRevoked(() => {1163 draft.a1164 })1164 // Access known property on object draft.1165 expectRevoked(() => {1166 draft.a1167 })11681166 // 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 })11731171 // 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)11781176 // 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)11831181 // 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 })11891187 // 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 })11941192 // 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 })11991197 // 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)12041202 // 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 })12101211 it("can access a child draft that was created before the draft was modified", () => {1212 produce({a: {}}, s => {1213 const before = s.a
485 unmodified lines
1699 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 lines
2420 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 lines
modified:__tests__/current.js+7 added-1 removed
12 unmodified lines
1314runTests("proxy", true)15runTests("es5", false)1617const isProd = process.env.NODE_ENV === "production"1819function runTests(name, useProxies) {20 describe("current - " + name, () => {21 beforeAll(() => {22 setAutoFreeze(true)
2 unmodified lines
2526 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 })3536 it("can handle simple arrays", () => {37 const base = [{x: 1}]
175 unmodified lines
modified:__tests__/manual.js+12 added-9 removed
modified:__tests__/map-set.js+16 added-1 removed
3 unmodified lines
4 nothing,5 original,6 isDraft,7 immerable,8 enableAllPlugins8 enableAllPlugins,9 enableMapSet10} from "../src/immer"11import {each, shallowCopy, isEnumerable, DRAFT_STATE} from "../src/common"1213enableAllPlugins()
266 unmodified lines
280 draft.clear()281 })282 expect(result).toBe(set)283 })284285 test("#692 - idempotent plugin loading", () => {286 let mapType1287 produce(new Map(), draft => {288 mapType1 = draft.constructor289 })290291 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 line
2import produce, {original, setUseProxies, enableAllPlugins} from "../src/immer"34enableAllPlugins()56const isProd = process.env.NODE_ENV === "production"78describe("original", () => {9 const baseState = {10 a: [],11 b: {}
29 unmodified lines
41 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 })5657 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 lines
41- The ES5 fallback implementation is roughly twice as slow as the proxy implementation, in some cases worse.4243## Performance tips4445- 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 data4647When 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.4849### You can always opt-out5051Realize 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.5253### For expensive search operations, read from the original state, not the draft5455Immer 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.5657### Pull produce as far up as possible5859Always 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 lines
6<center>7<div data-ea-publisher="immerjs" data-ea-type="image" class="horizontal bordered"></div>8</center>9101. For performance tips, see [Performance Tips](https://immerjs.github.io/immer/docs/performance/#performance-tips).111. 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).121. 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.131. 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.141. 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.151. Immer [does not support exotic objects](https://github.com/immerjs/immer/issues/504) such as window.location.161. 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).171. For arrays, only numeric properties and the `length` property can be mutated. Custom properties are not preserved on arrays.181. 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:191. 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 tipes1112For performance tips, see [Performance Tips](https://immerjs.github.io/immer/docs/performance/#performance-tips).1314### Don't reassign the recipe argument1516Never 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).1718### Immer only supports unidirectional trees1920Immer 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.2122### Never explicitly return `undefined` from a producer2324It 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.2526### Don't mutate exotic objects2728Immer [does not support exotic objects](https://github.com/immerjs/immer/issues/504) such as window.location.2930### Classes should be made draftable or not mutated3132You 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).3334### Only valid indices and length can be mutated on Arrays3536For arrays, only numeric properties and the `length` property can be mutated. Custom properties are not preserved on arrays.3738### Data not originating from the state will never be drafted3940Note 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.4142```javascript43function onReceiveTodo(todo) {44 const nextTodos = produce(todos, draft => {45 draft.todos[todo.id] = todo
7 unmodified lines
53 draft.todos[todo.id] = todo54 })55}56```5758### Immer patches are not necessarily optimal5960The 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.6162### Always use the result of nested producers6364Nested `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:6566```javascript67produce(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 lines
28 },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 lines
52 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 lines
51 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 line
61export 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}6768/** ES5 Plugin */69
43 unmodified lines
modified:.travis.yml+6 added-5 removed
1language: node_js2node_js:3 - "10.18.1"4 # - "node"3 # - "10.18.1"4 - "node"5env:6 - NODE_ENV=TEST7cache:8 yarn: true
2 unmodified lines
11before_script:12 - yarn global add if-node-version13script: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 017jobs: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-release
added:ignoreObseleteSnapshots.js+6 added
1module.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 lines
13 },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}