45: Version Responsibly with Michael Jackson
Versioning. How do we do it? It's a lot more complicated than "just use semver!"
This week Michael Jackson joins us again to discuss the pains of versioning, how to avoid them, and why it all comes down to communication.
Chantastic asks about upcoming how React Router v5 will take advantage of new features like Hooks and what versioning strategy they intend to employ with for legacy React Router users.
They fumble clumsily around what the various characters in a package.json file mean, discuss outrageous prefixing as a defense mechanism, and partying at the 2019 JSConfUS in Carlsbad.
Featuring
Announcements
Learn React in May!
New to React?
Want to learn to learn what the heck we're talking about?
Chantastic is doing a free React primer in the month of May.
Signup to learn more: https://chantastic.fm/news.
Links
- semver
- New Versioning Scheme — React moves from
0.14to15. - React Router v5
- NodeJS io.js Split
- npm tilde (~) ranges
- npm caret (^) ranges
- What's the difference between tilde(~) and caret(^) in package.json?
- React Training Spring Tour
__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED- unpkg.com
- JSConfUS 2019, Carlsbad — in Carlsbad, CA.
Transcript
[00:00:00] Michael Chan: This is React Podcast. I'm Chantastic. Versioning can be tricky. And for popular projects, we can take a lot of heat when we do it incorrectly. This problem only gets more difficult for library creators who make components and things that work on top of React. Right now we have a problem where there are so many new features that you might want to take advantage of as a library author. But what What do you need to do to communicate those changes effectively to the people using your code? To help us answer this question, we have the best help we could possibly have. Michael Jackson has been through this time and time again with React Router. He gives us some pointers on how we should be versioning our libraries as we take advantage of new features and lets us know what they'll be doing as they move from version 4 to version 5 for React Router. All of you library creators and aspiring library creators will really benefit from this Before we dive into this episode, I want to remind you one last time that this May we'll be doing a few short workshops to help you come up to speed in new things in React, like context, hooks, and some new important language features of JavaScript. If you feel like you've been running a little bit behind in all of those, don't worry, we'll help you out, help you get up to speed quickly on those. To join in, visit reactpodcast.com/news and we'll send you updates to let you know when those workshops will be. I hope to see you there. Now on to the show. Michael Jackson.
[00:01:45] Michael Jackson: What's up, dude?
[00:01:45] Michael Chan: It's good to have you back on the show, man.
[00:01:47] Michael Jackson: Thanks, man. It's awesome. I, uh, yeah, I love, I love the podcast. I love the React Podcast, so it's fun to be back.
[00:01:53] Michael Chan: Yeah, yeah. So today we- so we were at lunch the other day. I can't remember if we were- where was it? We're getting tacos or something like that.
[00:02:03] Michael Jackson: Yeah, I forget the name of that place.
[00:02:05] Michael Chan: I think I got a surf- Colima's?
[00:02:06] Michael Jackson: Yeah, Colima's.
[00:02:07] Michael Chan: Yeah, I got a surf and turf plate and you were eyeballing it the whole time.
[00:02:11] Michael Jackson: Oceanside. Yeah, man, you definitely ordered the better thing. I think I just got carne asada, which is, you know, decent.
[00:02:17] Michael Chan: It's good, but it's no surf and turf plate.
[00:02:20] Michael Jackson: No, it's not.
[00:02:20] Michael Chan: As I asked the guy and I was like, what would you get?
[00:02:23] Michael Jackson: Yeah, yeah, that's what you always gotta do. You gotta ask the guy there. And he'll tell you what to get.
[00:02:28] Michael Chan: He'll tell you what to get. Yeah. I had shrimp and- Or the lady, she'll tell you what to get. You know, honestly, whoever's behind the counter sometimes.
[00:02:35] Michael Jackson: Exactly.
[00:02:37] Michael Chan: They know, they know. Sometimes the guys get it wrong, but like anytime there's a lady behind the register, like she knows what I want.
[00:02:43] Michael Jackson: She won't lead you astray.
[00:02:44] Michael Chan: No, she won't lead me astray. She, she knows, she knows what's up. Um, so, but we were sitting there, you were eyeing my plate 'cause I ordered right. And uh we were talking about versioning.
[00:02:55] Michael Jackson: Versioning?
[00:02:56] Michael Chan: Versioning.
[00:02:57] Michael Jackson: I thought you said virgining. Yes, we were talking about versioning.
[00:03:02] Michael Chan: We're talking about versioning.
[00:03:03] Michael Jackson: Yeah, I mean, we- to be- to be- we talk about all kinds of things, so we've probably discussed virgining at some point. But yes, we were talking about versioning.
[00:03:12] Michael Chan: Is that something that either of us are eligible to do anymore? Uh,
[00:03:18] Michael Jackson: all my children are adopted, so-
[00:03:20] Michael Chan: Okay, okay, I didn't know this, I didn't know this. Let's talk about that then. Let's talk about versioning. Okay, so we want to talk about versioning, versioning, um, because in the React ecosystem, yes, there's React, and React Router is the second biggest package in that space. Uh, it's like the, the, the first largest dependency that people have, you know, are using in their React apps. And so not only like have you had to try to figure out versioning, had to take in a lot of heat for versioning, but also you're in this unique space where you're kind of coupled to the versioning plans of React.
[00:04:00] Michael Jackson: Right.
[00:04:01] Michael Chan: And so I just wanted to talk about that. I know that a lot of people have a lot of misconceptions about versioning, and so I just wanted to kind of bring that conversation out, talk about like versioning strategy and like why it's maybe a little bit more complicated than just, you know, oh, just use SemVer.
[00:04:16] Michael Jackson: Yeah, yeah, yeah. So, yeah, so, so I think the— when we talk about versioning, there are two things, right? There's the technical side of it, which is just picking numbers, you know, major, minor, patch. Um, and, uh, and if you read semver.org, it seems like very straightforward. Well, if it's a bug fix, it's a patch release. If it's— if you're adding a feature, it's a minor release. If it's a breaking change, it's a major release. And uh and people who write software, you know, I've heard them say sometimes like, oh, you know, it's uh you know, there there's no shortage of integers. So just just bump the integer, just just keep on bumping the number.
[00:04:57] Michael Chan: Keep going.
[00:04:57] Michael Jackson: And uh you know, anytime you need a new number, there there's one readily available. And I think that— I isn't that kind of what the browser makers did? Like, what are we on, like Chrome, like 53 or something like that?
[00:05:09] Michael Chan: I think it's higher than that. I think I think we're into the 70s now. Yeah.
[00:05:12] Michael Jackson: Like they just They just, at some point in time, they were just like, you know what? Every time we release, there's so much stuff that breaks old stuff that we're just gonna, we're just gonna bump the major version every single time. So-
[00:05:26] Michael Chan: Yeah. It's way different than the, the olden days where it was like, you'd have like, you know, Netscape and Internet Explorer and like the highest ver- I mean, in their lifespan, they got to like 11.
[00:05:36] Michael Jackson: Yeah. Yeah, yeah, yeah, exactly. IE 11. And then, and then at a certain point it was like Edge. And now who knows what version it is. Probably like some SHA or something. Um, so so there's a-
[00:05:48] Michael Chan: We'll eventually get there.
[00:05:49] Michael Jackson: Yeah, exactly. So there so there's like the technical side of it, right, which is picking numbers. And then there is the social side of it, which is, you know, how do how do people feel about having to keep up with your versions? You know, because I I could publish a new major version of my library every every week. And according to SemVer, that's okay. Mm-hmm. According to people, that's not okay, right? Like, well, what's the deal here? You know, I got to rewrite my code every single week, you know. So, so there's a, there's a fine line that you, that you kind of walk when you, when you do versioning, is you have to, you have to pick the right numbers, but then you also have to make sure that you communicate with people and that people understand why you're picking those numbers and how often you're gonna pick new numbers and things like that.
[00:06:37] Michael Chan: It's it's more a tool for communication. I remember when React was kind of taking fire for their plan to go from, I think it was 0.0.14 to 15.
[00:06:49] Michael Jackson: Yeah.
[00:06:49] Michael Chan: And they were like, well, there's this joke that we're like, oh, we'll just publish the other, like, you know, 14 versions and then get off our back. They'll just be the same thing.
[00:06:58] Michael Jackson: Yeah, yeah, yeah. I think they pulled one from Java's playbook. Didn't Java do that with Java? Yeah, Java at one point, like Java 5 or Java 4 was really Java 0.4. Gotcha. And then at a certain point, 0.5 just sort of morphed into 5. Yeah. And then they- it's because the zero dot, that's something that kind of interesting that happens to these projects where like they get big enough that the zero dot sort of sort of uh sort of loses its significance.
[00:07:30] Michael Chan: Yeah. Well, people start shorthanding. I mean, that happened with React. People started shorthanding to like 13 and 14, even though they were point- yeah, you know, point point 13.
[00:07:38] Michael Jackson: Exactly. You're not gonna say React 0.14 every time you talk about it. You're just gonna say React 14, right? It's- that is kind of an interesting phenomenon. I think it's a- I think it's an interesting way to, um, you know, sort of get started with a project, right? Because when you have- when you're in the zero dot something phase, um all bets are off, essentially.
[00:08:00] Michael Chan: No guarantees.
[00:08:01] Michael Jackson: Yeah, no guarantees. It's it's known to everybody that, hey, we're just experimenting here, stuff might break, we're not sure what the final API should be. Um and and honestly, that was one of my one of my biggest regrets with the router is we should have stayed there a little bit longer. But at a certain point, so many people are using the codebase, you know, so many people were using Java, so many people were using React that The, you know, the all bets are off philosophy doesn't really hold anymore because of this, this social aspect that I was talking about. Right. It's so popular that you can't break in 0.16, you know, like people are gonna, people are gonna be very upset with that. So-
[00:08:42] Michael Chan: So there's almost like a level of like dishonesty there. If you hold onto that versioning for too long.
[00:08:47] Michael Jackson: Yeah. Yeah. Yeah. There is.
[00:08:49] Michael Chan: Because like you're already like Node did this. Yeah. Whereas like they were holding onto that like point release version, but it was completely untrue because the way that they were behaving in the this was the I/O split. The way they were behaving was like that this was like long-term, you know, release software. Yeah. Uh, or long-term support software. Um, but it wasn't, it was like still in like 0.14 or whatever.
[00:09:11] Michael Jackson: Almost every major software project that I've ever seen has done this. Uh, another big one that did it recently was Rollup. Uh, Rollup was on like 0.50-something. And, uh, you know, but, but, you know, enough people in the community were using it that they were like, Okay, well, time to go to- time to go to 1.0, you know, and then they, they, you know, released 1.0, which I'm not saying they did anything wrong. Everybody, everybody does it. You just, you have a, you have a sort of a period of experimentation. Then if it gets big enough, you have to start pushing major versions.
[00:09:46] Michael Chan: And I think that that's one of the misconceptions that a lot of people have is, is that this versioning- versioning is not like this static thing, like, oh, you just need to use SemVer. It's It's a tool for communicating with the people who are using your software. Yeah. And it's a two-way communication. It's not just like a one-way thing where you're like, oh, okay, well, I like published it this version because X, Y, and Z. Like there's gonna be a point, especially in a popular project where you are kind of admitting to yourself like, oh, well, actually this is kind of stable in these ways. As a community, we've agreed that these are already stable. So, uh, yeah, I guess it's 1.0.
[00:10:21] Michael Jackson: Yeah, and that's, that's actually the way- that's exactly how it happened with the router. We were like, I think we were on 0.13 or 0.14, I can't remember, with the router. But so many people were using it that with us it was like, well, okay, I guess, I guess this is 1.0. Because if I release 0.15 and, and it's a different thing, like a bunch of people are gonna be really upset. So I guess this is 1.0, you know, even though we weren't necessarily ready for it. It just, because of this social aspect, it had to happen.
[00:10:53] Michael Chan: Yeah. Now, part of the reason that this is difficult is because uh npm actually does some certain certain things. npm or Yarn do some certain things for you when you're installing. Is that correct?
[00:11:06] Michael Jackson: Well, there, there's some nuance there, right? So they, they, uh, they typically will put the caret At the beginning of a version number.
[00:11:15] Michael Chan: Yeah.
[00:11:15] Michael Jackson: Um, which means that you are tied to the, the leftmost number that is not a zero.
[00:11:23] Michael Chan: Yes.
[00:11:24] Michael Jackson: Is what the caret means. So like if I, if I'm on, if I have caret 4.3.1, I can still get 4.3.4, 4.3.5, 4.3, anything in the 4.3 release.
[00:11:36] Michael Chan: Yes.
[00:11:39] Michael Jackson: But but for example, if I had caret, you know, 4.0.1, I would never get uh 4.1.
[00:11:49] Michael Chan: Oh, interesting. Okay, okay. I I honestly, I don't understand the caret.
[00:11:55] Michael Jackson: There's the caret and then there's the tilde.
[00:11:57] Michael Chan: Yeah.
[00:11:58] Michael Jackson: So the tilde, we should look this up, actually. We should totally look this up.
[00:12:02] Michael Chan: I mean, I kind of prefer just, you know, blind ignorance.
[00:12:05] Michael Jackson: The the the the the ranges are, there's a lot of nuance there. And honestly, I We actually got bit by this recently, so don't- don't- I'm not pretending like I'm an expert here. I'm gonna look it up real quick. npm.
[00:12:15] Michael Chan: I think it's important that people know that you're not an expert.
[00:12:17] Michael Jackson: Oh,
[00:12:18] Michael Chan: they're versioning.
[00:12:19] Michael Jackson: Oh, I am. Caret versus tilde. What does this even mean? Stack Overflow is gonna help us out. In the simplest terms, the tilde matches the most recent minor version, the middle number. So ~1.2.3 will match everything from 1.2.x but will not get 1.3.0.
[00:12:38] Michael Chan: Okay.
[00:12:39] Michael Jackson: The caret, on the other hand-
[00:12:40] Michael Chan: You were right on there. You were right on.
[00:12:41] Michael Jackson: Okay. Yeah. Well, I think that's what I said about- Oh, that's what you said about the caret. I think I said that was the caret. So that's the tilde. The caret, on the other hand, is more relaxed. It will update you to the most recent major version. Oh, the most recent major version. So caret 1.2.3 will match any 1.x.x release, including 1.3.0.
[00:13:03] Michael Chan: Okay. So-
[00:13:04] Michael Jackson: Oh, but we'll hold off on on 2.0.
[00:13:06] Michael Chan: Okay. So, so in summary, tildes get you all the patch releases, carets get you all of the minor minor releases.
[00:13:15] Michael Jackson: Yes. There you go. And so-
[00:13:18] Michael Chan: Easy when you put it that way.
[00:13:19] Michael Jackson: Yeah. Tildes get you patches, carets get you minor releases. Yeah, it is easy when you put it that way. So, so, so by default, npm, when you install stuff, uses the caret, which So they're they're uh basically what they're saying there is they're saying we trust everybody on npm that they're all following SemVer and that they're not releasing breaking changes in minor releases. Which which didn't used to be the case, actually, in the early days of Node. Like you would install stuff and I mean and it would just everything would break. So yeah. Uh I I remember like pinning things a lot in the early days of Node.
[00:13:52] Michael Chan: So in that case with the caret, If if I remember this correctly from a second ago, the caret would be fine in those cases where you're you're incrementing the uh minor releases. Like if you're on a 0.15. Because it's only gonna be getting you patches. The problem is is if you were gonna use it to go back.
[00:14:11] Michael Jackson: Well, I think that's where the 0 comes in. Because if you if you're on 0.15, I don't think the caret will get you 0.16.
[00:14:19] Michael Chan: Right, right, right, right.
[00:14:20] Michael Jackson: Because it's it that it's the the if there's a 0 on the left, it it only increments the Leftmost thing that's not a zero.
[00:14:28] Michael Chan: Yeah. Yeah.
[00:14:30] Michael Jackson: Or basically the leftmost thing that's not a zero is fixed. And then it increments the next thing over to the right.
[00:14:35] Michael Chan: Versioning.
[00:14:36] Michael Jackson: Oh, my gosh. Versioning. It's tricky.
[00:14:39] Michael Chan: So I want to talk about- I guess-
[00:14:43] Michael Jackson: It's a mess, honestly.
[00:14:44] Michael Chan: I think something that we've been experiencing in React is a difficulty to talk about certain features because they're not tied to a major version. So one of these things is hooks. Right. It's a huge conceptual change that changes the the way that a lot of your program is written. But it's just a minor addition to uh 16.
[00:15:06] Michael Jackson: Well, it's just a feature, right?
[00:15:07] Michael Chan: Yeah, it's just a feature.
[00:15:08] Michael Jackson: Yeah.
[00:15:09] Michael Chan: Um, but it's kind of hard, uh like kind of going back to the social aspect of it, it's kind of hard, you know, to think about- React 16 is such a a wide release.
[00:15:21] Michael Jackson: Oh, for sure.
[00:15:22] Michael Chan: It's so hard to know like, oh, okay, like, oh yeah, I'm in 16, I should be able to use hooks. But then you're like, oh, wait, no, I'm in 16- what, 6 or whatever or before. So I guess I don't have access to hooks, right? Or I'm in 16-2, so I don't have access to React fragment.
[00:15:39] Michael Jackson: Yeah.
[00:15:40] Michael Chan: You know, or I-
[00:15:41] Michael Jackson: yeah. 16 specifically, I think 16.3, I think it was, that had the new context API. And 16.8 that had hooks were kind of like landmark releases in the 16 uh branch, I guess you could say. But but but if they if they're, you know, from a from a social aspect, they could have been major releases. You know, they didn't they didn't technically take anything out, so it's okay to make it a minor release, uh because they're just adding features.
[00:16:14] Michael Chan: Um. But at some point, there's so many things tied to it. I mean, even the new like the profiler, you know, it you get a bunch of features if you're on a certain version of Yeah. React, uh, React 16, right? Yeah. And I don't know, I, I guess I'm interested in what your thoughts are on versioning for conceptual changes, even if they're just minor additions. Like, even if according to Sember, they're just minor. Because I think I saw Ember do this when they moved, transitioned from like V1 to V2. I think a lot of the APIs still- I think most of the API surface area still worked. Right. Um, it wasn't, they weren't making it V1 to V2 because of API breakages, but because there was a huge conceptual shift in how you're supposed to architect your app. And so I'm curious, like, what are your thoughts on that?
[00:17:05] Michael Jackson: That's interesting. Um, I, I hadn't, I haven't been following Ember for a while now, but I, I, I do like that strategy. I mean, for, you know, as a, so I, I do a lot of teaching, um, I uh I run a company called React Training and we we go around and we teach people React. And it is, I mean, you know, at some point I I have to tell people either, okay, if we're gonna if we're gonna do hooks, for example. So we're gonna be doing this hooks tour very soon, um coming up pretty soon in uh just after Easter. And uh so, you know, if we're gonna do hooks, we you you either have to say to somebody, okay, you need to use React 16.8 Or if it were released as a major version, you need to have React 18. And for some people, I think, you know, if, if it were released as a major version, which it wasn't, so it seems, I think, a little bit cleaner to some people to sort of use a major version. But, but then again, technically there's nothing wrong with it being in 16.8, you know? But I, I do think that-
[00:18:04] Michael Chan: It just feels like in some ways we're kind of like in that like minor release cycle again.
[00:18:08] Michael Jackson: Yeah. I do think a conceptual shift. Does kind of help to, um, it it does kind of help to indicate that with a major release, like like what the Ember people did. But, but again, there's nothing technically wrong with doing it in a minor release as well if you don't break anything. So.
[00:18:25] Michael Chan: So when React changes, as you're a, you know, a big project in the React space, is React make change makes changes like this, you know, particularly big versions like hooks, you know, what does that mean for React Router? As you know, you're kind of this companion project. What does that mean for basically how you're able to leverage these features, how you're able to expose them as public API for the router? Like, what does that entail when, you know, React has a minor version with a big feature that everyone's kind of- a big headline feature?
[00:19:05] Michael Jackson: Yeah, yeah. So, well, so for us, It's really kind of tricky because um we're we're kind of downstream, you could say, I guess, from them. You know, we publish components. And uh and React for us is a peer dependency, right? So we don't want- when you install React Router, we don't we don't automatically install React. We say, hey, you need to have React, you know, greater than or equal to React 15. installed. Um, and you know, people have been using the router over over the last 4 years now. And so there are there are a lot of apps out there in the wild that are still on React 15, that are still on React, you know, 16 less than 16.3, for example. Um, and and they need to be able to use the router. And so, you know, for us to change that peer dependency and say, okay, now we require React 16, uh would actually be a breaking change for a lot of people. Like that would You know, we would have to- we're essentially telling those people who are still on React 15, okay, in order to use this, you know, minor- if we were to do that in a minor release, for example, in order to use this new feature of the router and minor release, um, you have to upgrade your React version, right? Which is- which is, uh, in that point, you're not just upgrading the router, you're upgrading React itself, which is a it's it feels like a bigger— it's a much bigger job, right? I mean, even the React team has done a great job at, you know, backwards compatibility, et cetera.
[00:20:38] Michael Chan: Oh yeah, amazing job.
[00:20:39] Michael Jackson: Yeah, but it's but it's still, you know, uh uh uh uh it's it's a bigger amount of work, you know, by definition than just upgrading the router. It's now upgrading the router and React. So whenever— so when I— so that feels to me like something— again, this this like social side of versioning, right? That feels to me like something that should be for us a major release, even if we're just taking advantage of features in React that were introduced in a minor release. Yeah. You know, like, like, um, hooks, for example, right? So, you know, if we were to release some, some hooks, which we are obviously planning in the next version of React Router to, to have lots of hooks, um, but if I were to release hooks in the current, you know, 5.x branch of React Router, which is supposed to be backwards compatible with 15 and and versions of React prior to 16.8, um, how am I gonna release a hook in that situation? Because there's no like there's no like polyfill that I can drop in and get React hooks, right? So so I I can't say, okay, React 5 or you know React Router 5.1 gives you a hook, and then somebody on React 15 tries to run the hook and they're like, well, I can't run this. Oh, well, because you need to upgrade. You know, it's it's exactly what we were talking about. So, um, so I I I feel like, you know, we could release some hooks. Um, and and then, you know, there are different strategies. So one strategy, um, and we've seen this actually in in core React, is they'll release something with like an unstable underscore prefix. I really like that. Yeah, so they'll say like this is unstable, which essentially, you know, you're typing the word unstable. You're opting in every time. Use it use at your own risk. It's very obvious. That's what's going on there. Um, I think most of the time when they're using that prefix, um, what they mean is this might change, right? So this, this, you know, this might change, might break, it might not work the same as it works today. Um, we could potentially use that kind of a strategy, but with a slightly different meaning, right? Sure. So like I could release a hook in React Router 5 and say, okay, here's a hook to use, you know, the router or whatever. Uh you know, use our context, um you know, some of the hooks that we're planning for version 6. I could I could release them in 5 with like an unstable prefix. Um but it doesn't have the same meaning. Right. You know, it doesn't mean like these aren't fully baked yet. What it means is-
[00:23:10] Michael Chan: This might not work in your subversion.
[00:23:12] Michael Jackson: Exactly, exactly. So what we really exactly. So what we really need is a prefix that's like you know, you better be using the latest React underscore use context, you know, or some or something like that, right? Like it's it's it's it's got a different meaning, but we could potentially do something like that, right? An an an unstable prefix. Or uh or we could just make a new major version and bump the peer dep.
[00:23:41] Michael Chan: Yeah, yeah.
[00:23:41] Michael Jackson: And say, hey, React Router, you know, 6, you need to have React 16.8. But in any case, it's a minor bump for React, it's a major bump for us.
[00:23:52] Michael Chan: Yeah. What are some of the disadvantages of mapping, you know, given your project and how closely it ties to React, what would be the disadvantages to tying to the release cycle of React itself? So, so example being like, you know, they, they, uh, publish 16.8 and then you publish a version 16.8 that actually takes advantage of all the features in 16.8, um, and having that kind of like parity, I guess, with, with that.
[00:24:21] Michael Jackson: Yeah, well, so it's an interesting thought, right? One is by using the same version number across everything, it makes it really easy for people to reason about, right? Like they just look at, oh, I'm using React 16.8, ReactDOM 16.8, React Router 16.8, done. Um, and, and, and that's actually very convenient. I've, I've found that to be really convenient in situations like Webpack or Uh, or Babel, you know, like when Babel releases a new, you know, 7.0 or whatever, 7.1 or whatever, and and you're using a Babel plugin, it's like, oh, is this gonna be compatible? Well, as long as they've all got the 7, I think they probably should, you know, as long as I'm not using any 6 dot Babel plugins with Babel 7, it should be good.
[00:25:01] Michael Chan: And you can see it all there in the package.json.
[00:25:03] Michael Jackson: Yeah, exactly. Yeah. And you can kind of sniff out pretty easily. And and I've, I've done that before. Um, Babel actually is another really interesting one to talk about when it comes to versioning. But, um, but I digress. If we were to do that with React, I, I think we would still kind of have that problem that I was talking about earlier, right? So if, so if, for example, you know, React introduces hooks, for example, and then we would say, okay, uh, like, we, we- I don't think we can do that in a minor release. We can't say, um, without making them a dependency of ours. Sure. Right? So we could say React is now a dependency. Instead of bringing your own React, you just, you just install React Router and then you can magically import React, right? Mm-hmm. Uh, which, which people wouldn't like. I don't, I don't want to do that. Um, yeah, so I, I, I don't think that's an option for us really, just because we, again, yeah, we can't, uh, we can't, we can't take advantage of new features in minor releases because they're peer dep.
[00:26:07] Michael Chan: Right, because the problem still exists. Yeah. Because you- it's still a breaking change for you.
[00:26:11] Michael Jackson: Yeah, yeah, yeah, yeah.
[00:26:13] Michael Chan: Interesting.
[00:26:14] Michael Jackson: Yeah, so we we would have to make them like a regular dependency, and then we could do something like that, because then we have total control over the version of React that our users are using. But um, but since we don't have that, and I don't think I don't think people would like it if we did that, um, we can't. So anytime they- if anytime we want to take advantage of new features, for us it's a major version. Mm-hmm. Mm-hmm.
[00:26:40] Michael Chan: Is- so I want to flesh out a little bit more about that idea of having experimental features that uh you can opt into, uh in- I guess, and have it just blow up if you don't have the proper peer dependency, right? Um, what are some- like, what are some other strategies that you think might work in that regard, like maybe like foldering and you have to like kind of import through like an experimental folder to get to like the, you know, the, the modules that take advantage of the, you know, new feature or, you know, like you said, the, you know, requires 16. Yeah, yeah, yeah, yeah. Underscore.
[00:27:18] Michael Jackson: Silly prefixing. Yeah. So, so there are some interesting things that you can do with the bundling side, right? So you could say, for example, um instead of calling it- instead of using like an unstable prefix, you could just provide a separate module in your bundle. And by module, what I mean is file, right? Um, in your in your in your package, essentially, that's called like hooks.js, right? So, uh, so import React Router, you know, import useMatch or useLocation from react-router/hooks. Yeah. So that's a separate file in our package. And then, you know, we could say, uh, you know, obviously if you're importing from react-router/hooks, well, you better be on a release of React that supports hooks, right? So that that's one possible thing. And you could you could call it other things. You could call it like, you know, future or next or or something like that. Um, we currently use the term next for beta releases. So I I don't think I'd want to overload it there. Um, so like, for example, we use the npm-next tag when we're doing beta releases. And so you can say reinstall React Router at next and then you get the next thing. Um so yeah, we'd probably call it like future or hooks or something like that. And it's just a separate bundle. And if you're on React 15, well, you don't get to import that bundle. And if you do and we detect that you're not on React 16.8, we can warn you about that. Which I think is, that's a nice kind of middle ground because we could totally do that in the 5.x uh you know branch of the router. We could provide a separate bundle that, you know, you can only use if you're on 16.8.
[00:28:49] Michael Chan: Yeah, like the public documented side of this application is all going to be compatible with 15, but we're gonna give you those nice, you know, extras, you know, if you, if you deem that your application is capable of running it.
[00:29:02] Michael Jackson: Yeah, but it's up to you. Yeah. And then we could have some little feature detect again to say like, oh, you're not using the new, the latest version, you don't get to import this bundle. You know, which I, I think, yeah, again, I think that's a really nice middle ground. I think, uh, people who, people who do, people who do that would be, uh, well, cause essentially what you're doing is you're catering for both, right? You're catering both for the people who can't upgrade React yet while they don't have to do a major version of React Router, but the people who are on the bleeding edge can still use the latest and greatest stuff. You know, this, this conversation for me is actually really timely cause I'm in the middle of getting ready for the next major version of React Router, where we are taking advantage of hooks. And and it's it's gonna be great because everything's we're gonna be able to write a lot less code. Everything's gonna be a lot, lot smaller. The the router essentially, you know, could be just a bunch of mixins or could be just a bunch of hooks, you know, that you use to figure out, okay, what's the URL and render something based on that. Um, you know, we we we had components because we didn't have, you know, mixins went away and and so we had these components. But really, you know, if you want to do routing, it could just be a bunch of little little mixins, little hooks. Um, I use those as synonyms and they're they're not, but I I you you would accomplish the same purposes with with them. Um, but uh so anyway-
[00:30:31] Michael Chan: Fixins, is that what they-
[00:30:33] Michael Jackson: I think I think it's the one with code names for it. Augmenters is personally what I call them.
[00:30:37] Michael Chan: Yeah, yeah, augmenters.
[00:30:39] Michael Jackson: Uh, um, so so yeah, so so I'm thinking about, okay, so how do we do that? Um, because that's a that's a major conceptual shift, like we were talking about earlier. That's a major conceptual shift. And the last time there was a major conceptual shift in uh in React, and specifically in React Router, uh people got pretty upset.
[00:31:04] Michael Chan: Yep.
[00:31:04] Michael Jackson: Um there there was a we we we we basically figured out how to not uh isolate your route config into one little bundle, into one little spot, right? So every other router on the planet, you know, NGINX, Apache, Express, Rails, whatever router you're using, there's there's like an app and you sort of configure all of your routes.
[00:31:33] Michael Chan: Yep.
[00:31:33] Michael Jackson: And then the server knows about all the possible routes and that's it. Um and the thing we were going for with React Router was, yeah, that that should be possible. But then so with React Router version 4, that should be possible, absolutely. Um but it should also be possible to have routes that you might not be able to predict. Right up front, you know, and we call those dynamic routes. So what if you're building like a file browser UI, or there was some, there was some bit of UI that was sort of programmatically determined and you, you, you, you know, you couldn't possibly build them all up front. Um, Unpackage actually— so, uh, listeners might not know, I maintain this website called unpackage.com. Unpackage is basically a massive file browser UI for everything on npm. Uh, if I were to try and build a router that would, you know, try and state all of the paths up front that we could possibly match, it would be impossible because there are literally millions of files on npm and we we wouldn't be able to do that. So the dynamic routing uh comes in very handy in in lots of different situations. Of course, uh if you have dynamic routing, you can always go back and define all of your route config in one spot. Think about, for example, if you have a list of Uh uh you know we do this all the time in React. If you have an array of data and you want to render a list, you just map over the array and generate your list, right? So uh so it's easy to go from dynamic to static. It's impossible to go from static to dynamic. Yep. The other way around. Um so anyway, so we had this major conceptual shift, uh and uh and we we we thought that people would look at it and be like, oh, I I see what they're doing here. These are real components now. I can easily recreate my old static uh configuration with these new dynamic pieces. But that wasn't the case. A lot of people didn't make that connection. I think a lot of people still haven't made that connection. Like you can you can literally you can build anything, like any of your old static route config, you can build it in uh when you have these more powerful sort of dynamic components. So anyway, we're on the we're on the sort of edge of like another conceptual shift, right? Yeah. Another major shift, which is now Um, you know, now that we have these hooks, so we have these mixins, you know, uh, your your your apps can sort of take advantage of those. We can get our bundle size way down. You can just import um these tiny pieces. Um, but, you know, we can't do what we did last time essentially with uh with another major version right out the gate and just say, well, you know, we understand how you can rebuild your old app with this new stuff. Why doesn't everybody understand that? Sure. You know, which is kind of the, the mistake I think that we made last time is we didn't do a good enough job sort of educating people. Um, and so I think my strategy for this next- or I think our strategy rather for this next time around is really just going to be, uh, you know, giving people a separate- giving people a separate module in 5.x. Essentially what we just said, giving people a separate module in 5.x that is You know, React Router Future or React Router whatever, um, and that they can immediately start using in their 5.x branch or in their 5— in their React Router 5 app. Um, and that will be the sort of one of our like long-term supported releases, right? React Router 5, which is essentially 4. Um, if you want to know why we jumped from 4 to 5, I have a blog post about that. Go to go read the blog.
[00:35:05] Michael Chan: We'll link it.
[00:35:07] Michael Jackson: But anyway, so I think that's what I think that's what we'll do. And what will be in react-router/future will essentially be the the API that we would like to have in the future. But again, we're not gonna make you bump the major version. We're not gonna break anything on you. You can still use your React Router 5 app. If you're on the bleeding edge, and a lot of people are in React, you can just import from that bundle. You you don't even have to import anything from from the main React Router bundle if you want. You could just import everything from /future. Um and you'll get our entire like futuristic sort of API. Um and then at some point, we can we can sort of flesh out all of the future API there. Um and then at some point, um if you find that all you're doing is importing from react-router/future, it should be as easy as as, uh, you know, just flipping the switch in your package.json to go from 5 to 6 and and take off the /future suffix off of all of your imports and everything should work. Right? So essentially React Router 6 is going to be made available in React Router 5. Yep. In a separate bundle, uh, which I think is the better path forward. Probably the path that we should have done going from 3 to 4, but we didn't Again, we didn't- we did that one wrong. But I think I think that will be the path of least pain for everybody who's consuming the router right now. 4 to 5 is a is an easy jump. It's the same exact API. It's just if you were using our private context API, which we told you not to use, which we didn't document, um then you got burned.
[00:36:48] Michael Chan: It's culturally stable, though.
[00:36:50] Michael Jackson: Yeah, it is. Yeah, exactly.
[00:36:53] Michael Chan: They forced that one on you.
[00:36:54] Michael Jackson: Exactly. I should have I should have put it under a prefix like uh like the React team did. Do not use or you will be fired. I I I actually, I was I was playing around with a prefix called uh um this code is broken. Just just just just put it-
[00:37:12] Michael Chan: Let's see what happens.
[00:37:13] Michael Jackson: Yeah, just put it under a prefix called this code is broken. I want I want to make you type that. This code is broken.
[00:37:19] Michael Chan: So then when people send in their screenshots, like, why isn't this working? Do you see the imports? It says right there.
[00:37:25] Michael Jackson: Exactly. Or you try and get that merged into your company like codebase and they're like, yeah, you know, I was looking through your PR, man, but it said uh this code is broken. So, uh I don't know. I don't know if we want to merge that. Just like, just make it impossible to get it in.
[00:37:40] Michael Chan: Uh I think this is a strong strategy. Yeah.
[00:37:44] Michael Jackson: I think it would be like, as long as you type something that let like, that lets you know you are on, you're on, you're on your own.
[00:37:51] Michael Chan: It's like, it's like Wi-Fi naming. Uh have you ever had this in a neighborhood or or or like an apartment? Where like everyone just has like more and more profane, aggressive like Wi-Fi naming. I have it now. These battles. Oh, man. Oh, man. Especially around like election time. Oh, right. Yeah. So it's like, we're getting into this like prefix game where it's like, who can rank more inflammatory?
[00:38:14] Michael Jackson: That's hilarious. I'm gonna have to watch that uh this next election season. That'll be interesting. Now, the the I think the funniest one I've ever seen was a It was an FBI surveillance van uh network. It was called FBI Surveillance Van. And then I like looked out the window, I was like, what, what's going on? So that was my, I think one of my neighbor's uh Wi-Fi networks.
[00:38:35] Michael Chan: That's awesome. Well, Michael, thank you so much for your time. Thanks for clarifying all that. Thank you for uh kind of communicating the the different strategies and challenges of keeping everybody happy. When, you know, you're changing your versions of your apps.
[00:38:51] Michael Jackson: Yeah, I mean, I just want people to know that like it is something that we think about a lot. Yeah. You know, it's- and it's not as, uh, it's not as straightforward as just follow SemVer, you know, because if we- if like, that's what we did the last time. We followed SemVer and everybody was upset. So that was when I learned, oh, there's another side to this. There's a social side to this that people people don't like. So uh so we're gonna try and do that a little bit better this next time.
[00:39:19] Michael Chan: Yeah, and I I really like this idea of trying in some way to get all of the next APIs into the current version. So that it is easy to just flip that import. You know, the same way with, you know, uh was it unstable, right? Like you can do like import unstable as, you know, and then use the name that you want. And then just kind of remove that from your import. And it's like that, that's like an easy PR, right? And the same thing, if you can just import the location that you're importing your new API from, you know, that's an easy change too. And like kind of thinking about that, how do we get people from the current to the next, is, um, is a really important thing to consider when you're, you're doing like kind of like high- yeah, eyeball open source.
[00:40:04] Michael Jackson: Yeah.
[00:40:04] Michael Chan: So I appreciate your, your information there.
[00:40:06] Michael Jackson: And if you can do that, I think it's just I think it I think it'll give your project like a number one is is you're just taking care of people. Yeah. You know, you're taking care of people with- and this is for any project, even projects that aren't super, you know, high-profile like the router. Um, you know, whatever you're doing, when you're when you're dealing with SemVer, you're really just taking care of people. Yeah. You know, there are people who are using the software. Again, you're communicating with them, you know. So if you're irresponsible with it, it could and really make people's lives a lot worse. So I've gotten a lot of very angry messaging over the over the years from people uh who you know who've you know and I and I feel bad. I mean, I don't think their angry messaging is justified, but I feel bad that I've I've you know uh upset a few people. And and so trying to do that better going forward.
[00:40:58] Michael Chan: Yeah, well, it sounds to me like the lesson that you've learned from this is that SemVer adhering December doesn't opt you out of communicating with the people that you are- that are using your open source. And that it's just one part of this broader idea of like, how do I communicate about this package and how do I help people kind of move their apps forward?
[00:41:19] Michael Jackson: Yeah. And if, and if, like I said, if like, uh, yeah, like, like, like, uh, for example, uh, on this blog post that I wrote about, uh, the change between 4 and 5, um, you know, I just took the time to write a nice long blog post about it. And I got a couple of people reaching out and saying, thank you so much. You know, like, like they just, people just don't like to be left in the dark.
[00:41:39] Michael Chan: Yes.
[00:41:39] Michael Jackson: They just don't like to be left to figure it out for themselves, you know? So if anything you can provide and, you know, in the release notes or a changelog or a blog post or something that's just like, here, I didn't leave you alone on this. Here's how to do it. Um, I think is is appreciated. So we're gonna have a bunch of that kind of stuff with this next, uh, with this next release.
[00:42:00] Michael Chan: Cool. Well, um, I know that you got a tour coming up.
[00:42:03] Michael Jackson: Yeah.
[00:42:03] Michael Chan: Uh, this will probably air like, you know, April 25th. And so what's, uh, what's what's your May looking like?
[00:42:09] Michael Jackson: Oh man, it's pretty crazy. So, uh, so I'm going on a tour with, uh, with my friend Ryan Florence. We are gonna be hitting up 10 different cities across the United States.
[00:42:22] Michael Chan: Nuts.
[00:42:23] Michael Jackson: Uh, so no matter where you are, we're gonna be near you. So we're gonna be in, uh, Washington, D.C., New York, Boston, uh Denver, Austin, Texas, uh San Diego, Seattle, San Francisco, uh Phoenix, Arizona, Chicago. Sorry, I forgot Chicago. Uh but anyways, we're gonna be all across the U.S. So if you're if you're interested in that, you want to come and learn some cool stuff about hooks, uh go and head over to reacttraining.com and uh sign up there. We're Awesome. Kind of filling up in some of the some of the bigger cities, which is which is really nice. Really appreciate your support. But that's that's gonna be my my basically my 5 weeks in between Easter and uh Memorial Day is just gonna be traveling, traveling, traveling, 2 cities a week. So that I'm really looking forward to that.
[00:43:10] Michael Chan: That's crazy.
[00:43:10] Michael Jackson: Yeah, it's it's it's gonna be nuts, but it's also, I think it's gonna be a ton of fun. We're gonna hit up a couple of meetups along the way. I think we're gonna be at the the Boston React meetup. Uh we'll probably be at the Phoenix React meetup. Um I've got some friends in in some other places too that maybe we'll hit up. And so, yeah, hope to see you sometime uh when we're on tour this year.
[00:43:29] Michael Chan: Nice, nice. Well, I'm excited to uh to meet any of y'all who are coming down to San Diego. That's right. I will be there.
[00:43:35] Michael Jackson: Michael Chan's gonna be helping us out down here in San Diego, down here in Carlsbad. So come and join us. Seriously though, Carlsbad is- I just gotta-
[00:43:44] Michael Chan: Give us your Carlsbad pitch. No, I just gotta- It's been like 2 years now?
[00:43:47] Michael Jackson: Yeah, man. Yeah. I've loved it down here. We we had a we had a I had a React training workshop down here in Carlsbad last year.
[00:43:52] Michael Chan: Yeah.
[00:43:53] Michael Jackson: And, you know, we had people come down from, um, you know, from from San Clemente, from like further north even, from, you know, there were there were some guys there um from the NFL, uh, you know, who who I I think they're like in downtown LA. And then we had some people come up from San Diego, some people who were, uh, you know, some um servicemen and women who were uh part of the Navy down here. So it's just it's it was just a really cool group that we had last year down here. And uh Just, just being down here is just the best. I feel like it's- I feel like it's this little kind of undiscovered gem in between, uh, in between Orange County and San Diego, you know?
[00:44:32] Michael Chan: I agree, you
[00:44:33] Michael Jackson: know,
[00:44:33] Michael Chan: couldn't agree more.
[00:44:33] Michael Jackson: JSConf's coming back this year.
[00:44:35] Michael Chan: Yeah, I'll be there.
[00:44:36] Michael Jackson: They're gonna be back. Yeah, we got- we got all the React Training Crew tickets to JSConf.
[00:44:40] Michael Chan: Oh, heck yeah!
[00:44:40] Michael Jackson: Yeah, we're all gonna be there.
[00:44:41] Michael Chan: Oh, sweet!
[00:44:42] Michael Jackson: Yep. Yeah, it'll be fun.
[00:44:43] Michael Chan: That's gonna be the best conference ever.
[00:44:45] Michael Jackson: Yeah, man, it'll be- it'll be a blast.
[00:44:47] Michael Chan: Buy your ticket to JSConf. Today.
[00:44:49] Michael Jackson: Go to the beach.
[00:44:49] Michael Chan: Hang out with all of us.
[00:44:50] Michael Jackson: Yeah, we'll just go to the beach. No, I mean, we'll go to the beach.
[00:44:55] Michael Chan: There's some good tacos in La Costa.
[00:44:56] Michael Jackson: There are. Rudy's.
[00:44:58] Michael Chan: Yeah, yeah, it's right around the corner. We can walk there.
[00:45:01] Michael Jackson: That's right, dude. Just walk back and forth. Let's get a big walk. It's right next to the Omni, right? It's right there. The Omni is uh where they're doing the thing, right? It's right there. JSConf.
[00:45:08] Michael Chan: Come to Carlsbad JSConf, get some tacos with us.
[00:45:11] Michael Jackson: That'll be fun. We'll see you down here. Later this summer, or hopefully somewhere else around the country.
[00:45:18] Michael Chan: Thanks, Michael.
[00:45:19] Michael Jackson: Bye.
[00:45:19] Michael Chan: I hope that this chat was helpful for you. I know it was incredibly helpful for me. Just remember that it's all about communication. When you communicate well, people can make sense of the numbers. Thanks, Michael Jackson, for making this show possible and helping us learn that. Join us next week for an episode with Houssein Djirdeh. We talk about what progressive React means and how to make your apps fast and available for everyone. This episode of React Podcast was edited by Mikael Delport. It was produced by Mikael Delport and Sarah Jackson. React Podcast lives on Speck, a network for developers and designers. The goal? Help you level up. Find more shows at speck.fm. To chat with us, hit us up on Twitter @ReactPodcast. You can find me @Chantastic. For email updates, sign up at reactpodcast.com/news, and to chat, reactpodcast.com/chat. Please show your support by reviewing our show on iTunes and leaving us a comment. It helps us know that we're doing a great job and helps others find the show and level up in their own careers. Well, that's all for this show. We'll be in your ears again next week.
chantastic.fm