Cool. We have got lots of questions and confidently not enough time to do them all, so just a reminder, I'll do it again in a moment, there's a speaker Q&A room kind of near the reception, for those of you in the venue and for those of you online, go to Spatial Chat, click Q&A in order to join that space, because I just know we won't get through them all, but we'll try our best.
How do you define the difference between a monorepo and a modular monolith like the one you showed? Exactly, yeah. So we at NX, our team, we have actually a web page that's called monorepo.tools where we collect different monorepo solutions. We got a lot of contributions from different monorepo tool providers where we list what a monorepo is for us. Like we usually say it's when you have multiple applications. If you just have one application, sure you could technically see it as a monorepo because you have an app and multiple packages, but with that standalone project that's our modular monolith approach. If you want, where you have one project, that's the default. In fact, if you run NXserve, it's serving that project, you don't have to specify the name and once you then add another one, another application, as your deployment container, deployment bundling system, then I would start speaking of a monorepo. But obviously the line is fuzzy, there's no one rule basis.
Do you see this architecture for full stack applications as well? Somewhat like TRPC? Yeah, yeah. It totally works. I mean, especially the monorepo scenario works perfectly fine. And that's what, I mean the standalone project came just recently, but we had support for Node for a long time because a lot of our clients and users of NX like had a scenario where they had like React on the front end and then a Node back end, right? And so having them co-located, you could already share types. Now, things like TRPC makes that even more easier, right? Because you have the routing mechanism built in, so you can leverage that more. We actually have a blog post. So if you go to dev.to.nx, there's a blog post about how to use TRPC in an NX workspace, for instance. And again, it's just, how would you stick them together? How would they fit in? I think there's even a local generator that kind of makes things easier to set up as the stuff like that. But yeah, monorepos are very, very suited for having front end and back end co-located and therefore share things between them. Yeah, special types.
Next question. I think we might have time for two more. How does the build work for Node TypeScript projects with multiple modules? Do you need a bundler or is just TypeScript compilation enough? Yeah, so basically, we leverage their ESBuilt behind the scenes. So if you look at the project configuration, there will be an ESBuilt plugin base that we use to kind of build this from TypeScript. And obviously Node, you wouldn't necessarily need the actual build process. The only thing that we additionally do is that when you have those models, and with the TypeScript path mappings, once you build them to TypeScript, JavaScript, sorry, you obviously won't have the TypeScript path mappings anymore. So we have basically done a layer in between where we actually implement a module name resolver, and that kind of maps them. So we kind of generate a map for those modules such that you can still just deploy them as it would be a single Node application. It is in a dist folder, and then the models will be copied there, precompiled, and just linked over that module resolver that is kind of your entry point for a Node application. So that's kind of how we solved that thing.
Comments