-
-
Notifications
You must be signed in to change notification settings - Fork 860
Closed
Labels
Description
🚀 Feature Proposal
Hi folks,
I've collected a bunch of issues that are together I think worthy of being put in a separate major version:
- Disable support for getters / setters by default. Support getters and setters on plain object supports a non-idiomatic pattern where objects aren't purely data and can have side effects. Even though in general Immer does handle does correctly (descriptors are copied etc) there is are still 2 issues with it 1) it has a huge performance impact, and 2) side effects might be triggered non-intentionally. Given that getters / setters is an unidiomatic usage of "immutable" data, I'm proposing to make their support opt in. Unexpected access to
getter
property in irrelevant plain objects #1012 Immer takes a long time to update the data. #867 [breaking change] implement and default to useStrictShallowCopy, omitting getters #941 - Drop promise based producer support. Immer supports returning a promise from a producer. I don't think I ever saw usage of that in the wild, and it is a bit of an oxymoron as it makes it easy to leak drafts. Since producers should be like enter-write-exit without happening anything in the mean time, and it complicates the code base unnecessarily, I'm proposing to simply drop it.
- Drop support for ES5 mode. Proxies are now in all major browsers, and legacy support can stay on Immer 9, I think it is now the time to create a smaller (and simpler) Immer package by removing the ES5 fallback.
- Drop the default export. It is now valid to do both
import produce from 'immer'
andimport {produce} from 'immer'
. Since both default exports and offering two ways to achieve exactly the same are anti patterns, and removing simplifies ESM support, I'm proposing to drop the default export. This is quite a breaking change, but on the upside easily handled by a simple search and replace. Possible breaking change in package exports in v9.0.13 #937 (comment) / Migrate the RTK package to be full ESM reduxjs/redux-toolkit#3095 - Don't use array.length assignment in JSON patches. See [breaking change] Do not replace array.length as patch when removing items #964, array.length assignments should not be used to shorten arrays in JSON patches. Since this can both increase payload sizes and affect logic based on patches, saved this for a major bump.
- Give ESM another try? See fix: Fix importing ES module from Node.js (#901) #921. Sigh.
[ ] Support map/set by default -> avoid control issues like import and callenableMapSet()
error happens even after enableMapSet() is called. #1022
Notes to self:
- TS 5
- verify all error codes still in use
- clean up old language constructions, iterators etc
- communicate that Immer now expects Symbol / Map / Set / Proxy to be present in env
- update size & perf tables
- chinese translation update
- errors -> array
cc @markerikson
childrentime, yolio2003 and dhlolodavidkpiano, NDufy, sajmoni, Dassderdie, sunghwan2789 and 3 moreJeanMechechildrentime