Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling enablePluginName() is not idempotent #692

Closed
3 tasks done
Labels

Comments

@blixt
Copy link

blixt commented Oct 27, 2020

馃悰 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)
@aleclarson
Copy link
Member

馃帀 This issue has been resolved in version 7.0.15 馃帀

The release is available on:

Your semantic-release bot 馃摝馃殌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment