1. Introduction to Redux Toolkit 2.0
My name is Mark Erickson and I'm excited to talk about what's new in Redux Toolkit 2.0. Redux Toolkit simplifies Redux logic and includes RTK query for data fetching. We released RTK 1.0 in 2019 and are now working on RTK 2.0, which aims to improve compatibility and add new features. However, the ESM common JS compatibility has been challenging and I've written a blog post about it.
All right, good afternoon. My name is Mark Erickson, and today I am very excited to talk to you about what's new in Redux Toolkit 2.0.
A couple quick things about myself. I am a senior front-end engineer at Replay, where we are building a true time-traveling debugger for JavaScript. We've got a booth out there in the lobby. If you haven't seen it yet, please come by. We'd love to show you how much easier it makes debugging applications.
I will answer questions anywhere there is a text box on the internet. I collect all kinds of interesting links. I write ridiculously long blog posts. I am a Redux maintainer, but most people know me as that guy with the Simpsons avatar. I know. Sometimes I wear a name tag just so people recognize me.
Redux Toolkit is the standard way to write Redux logic today. It provides methods to simplify standard Redux patterns, like creating stores, writing reducers, funcs, and even data fetching. It includes a sub-piece called RTK query, which is specifically meant to simplify data fetching in Redux apps, and it wraps around the Redux core APIs.
We released RTK 1.0 in October 2019, which if you think about it means it's been around half as long as the original Redux library, and yet, many people don't know about it. The latest version has been RTK 1.9. We shipped 1.9 a year ago. The latest patch release was 1.9.7.
At the start of this year, we began work for RTK 2.0, and we had a few different goals. The first is correct ES module common JS compatibility, whatever that actually means. We wanted to modernize the JavaScript build artifacts so that they use modern syntax, no longer targeting IE 11. We wanted to add some new features, remove some deprecated APIs, and we wanted to ship some updated TypeScript types along with the packaging.
Now, unfortunately, it turns out that this whole ESM common JS thing is really, really hard. I went through multiple rounds of iteration where I tried to change some settings, tried to change some build configuration, and multiple tools would not work right. It turns out that the package exports field is really complex, but the bigger issue is that every different build tool has their own idea of how they interpret these things. I was actually messing with this in the speaker's room an hour ago. It's not done yet. I actually ended up writing a very long blog post a few months ago, talking about the pain and suffering that I've dealt with trying to get this stuff to work.
2. Shipping Major Versions and TypeScript Upgrades
The plan was to ship major versions of RTK, Redux core, Reselect, and React Redux together. The Redux core was converted to TypeScript in 2019 but never shipped. All packages require packaging updates and some TypeScript type upgrades.
I talked about it on a couple podcasts as well. Now, the original plan was just to ship major versions of RTK and the Redux core. Then we realized that we actually probably needed to ship major versions of all the other libraries like Reselect and React Redux as well. The Redux core actually got converted to TypeScript in 2019, and then we never actually shipped it because version 4 was good enough and we were worried about breakage. We decided that all these packages need to get shipped, new major versions together. They all need the same packaging updates with a couple slight variations, and we were going to try and do some work to upgrade some of the TypeScript types and some of the exports that we were defining.
Comments