-
-
Notifications
You must be signed in to change notification settings - Fork 867
Description
🐛 Bug Report
Calling enableMapSet() multiple times results in the work of adding Map and Set support being performed every time. It should only be performed the first time so that big codebases with multiple entrypoints and tests can safely call it in the parts of the code that knows the feature will be used, without having to worry about other parts of the codebase having already called it.
Link to repro
https://codesandbox.io/s/immer-sandbox-forked-q2pu1?file=/src/index.ts
To Reproduce
Have a big codebase that may call enableMapSet in different modules that are used by different entrypoints, but it's very hard to predict in the entrypoint which modules will be used.
Observed behavior
The Map and Set types of immer are patched every time enableMapSet() is called.
Expected behavior
The second call to enableMapSet() should be a no-op.
Environment
We only accept bug reports against the latest Immer version.
- Immer version:
- I filed this report against the latest version of Immer
- Occurs with
setUseProxies(true) - Occurs with
setUseProxies(false)(ES5 only)