yarn @reduxjs/toolkit 1.3.0-alpha.10
v.1.3.0-alpha.10

latest releases: 2.2.5, 2.2.4, 2.2.3...
4 years ago

This release reduces bundle sizes by updating to the latest Immer 6 alpha to help reduce bundle sizes and inlining the nanoid dependency.

Note: Due to the Immer upgrade, this RTK alpha version requires at least TypeScript 3.7 if you are consuming it in a TypeScript app. The final version of RTK 1.3 will hopefully support TS 3.5+ once immerjs/immer#541 has been merged in.

Changes

Bundle Size Improvements

Immer has always been the largest chunk of code added to your bundle from using RTK. Until now, RTK specifically depended on Immer 4.x, since 5.x added support for handling Maps and Sets (which aren't useful in a Redux app) and that support added to its bundle size.

Immer's code was written in a way that kept it from tree-shaking properly. Fortunately, Immer author Michel Weststrate has been hard at work refactoring the code to better support tree-shaking, and his effort are now available as Immer 6.x alpha.

Per the updated Immer alpha installation docs, Immer now uses a plugin architecture internally, and additional functionality has to be explicitly enabled as an opt-in. There are currently three Immer plugins that can be enabled: ES5 support (for environments without ES6 Proxies), Map/Set support, and JSON Patch support.

In this alpha, Redux Toolkit force-enables ES5 support. This is because we expect RTK to be used in multiple environments that do not support Proxies, such as Internet Explorer and React Native. It's also how Immer previously behaved, so we want to keep that behavior consistent and not break code given that this is a minor release of RTK. (In a hypothetical future major release, we may stop force-enabling the ES5 plugin and ask you to do it if necessary.)

Overall, this should drop a couple KB off your app's minified bundle size.

You may choose to enable the other plugins in your app code if that functionality is desired.

Inlined nanoid

We received reports that the nanoid library, which we used for generating unique request IDs in createAsyncThunk, prints warnings on React Native due to a lack of crypto availability. Since we don't need anything cryptographically secure, just reasonably random, we've inlined the function from nanoid/no-secure and dropped the nanoid dependency.

Documentation

We've added TypeScript usage guides for createAsyncThunk and createEntityAdapter to the alpha docs:

Alpha docs: createAsyncThunk and createEntityAdapter TypeScript usage guide

Changelog

v1.3.0-alpha.9...v1.3.0-alpha.10

Don't miss a new toolkit release

NewReleases is sending notifications on new releases.