I want to show how, for instance, you could do something similar with Nx. And you might know Nx maybe from a mono-repo thing. Maybe some of you have been here yesterday. So not going to talk about mono-repos, but actually about a similar thing that we did, which is what we call standalone applications.
So Nx has facilities built in that is not just useful for a mono-repo setup, but can even help you set up something that is very close to what Create React app did, but with some modern features. So you can create a new workspace like this one here. And this will boot you up. You can already see you have different choices in terms of bundling mechanisms, like V-to-APK or RSPEC.
And I did this already, so we save some time installing stuff. But basically this is what you will get out of such a workspace. So you can already see it's pretty similar to what a Create React app might look like. So you have a source folder at the root, one app only. There's a couple of other things in here. And you can just literally do an npm start, right, and it would boot up your application in develop mode. Now here's its Vite, and it serves it up in your browser. Now, why would you choose this? Like, you're getting a step further. Because we've, for instance, like coming a bit from the monorepo scenario, we suggest people to modularize their applications.
So instead of sticking everything into this source folder, what you can do actually is leverage some of the nx generators and, let's say, set up a new library in here. So I can say the nx react plugin provides your library generator. And let me create some products library. And as a directory, I'm going to use modules. You can choose whatever you want, really. So what test run do you want to use? Do you want to use VTEST as fast as one? Don't need a bundle right now. And so what will happen here, you can see I created such a library which allows me to represent that unit or business context for developing products. You can see here, there's a clear entry point which allows me also to think about private and public APIs. And I can expand it like this. If you don't know these commands, these generators by heart, which is totally understandable, we also have an extension for vscode and WebStorm. And so what you could do here, for instance, go here, say generate library react. Let's say I want an orders library as well. Choose a bunch of stuff and then run just a generator.
Comments