Redux-toolkit: Upgrade Immer version

Created on 10 Jan 2020  路  7Comments  路  Source: reduxjs/redux-toolkit

Hello,

Loving what you're doing with the Toolkit, it greatly cleans up the Redux boilerplate.

I'm bringing the Toolkit into a project where I already have Immer@^5.0.0 and since the Toolkit is using Immer@^4.0.1 I'm getting it installed twice.

Do you have plans to update Immer soon?

Thanks!

Most helpful comment

Note that I filed https://github.com/immerjs/immer/issues/500 yesterday to see if they can maybe make some improvements to tree shaking on their end.

All 7 comments

As it stands, immer v5 is 50% bigger than v4 and has no features that are useful for RTK, so until some tree-shaking issues on their side are resolved, we'd prefer not to.

If you're using yarn, you can use resolutions to tell it to only install one version of immer. RTK should run perfectly fine with v5, we just don't want to make it the default because of above reasons for now.

Got it. Thank you!

I tried using Immer via the RTK export, which would remove the extra version management, but I need Immer's setAutoFreeze which RTK does not export.

You should be able to directly import it from immer though - after all, that should be installed when RTK is installed ;)
We're only re-exporting what's relevant for actual RTK use.

Now that I think about it, are Maps and Sets not valid for use in Redux stores? Because they're not serializable?

Exactly.

Cool. Thanks a lot for your help! :)

Note that I filed https://github.com/immerjs/immer/issues/500 yesterday to see if they can maybe make some improvements to tree shaking on their end.

Was this page helpful?
0 / 5 - 0 ratings