Okay, so, building a micro frontend. That was lots of words from me. It's live demo time, which obviously never goes wrong, so please bear with me.
So, I've mentioned, oh, good. I've mentioned modular. It does have a way of scaffolding applications. It's based very similar on your create React app, however, what we're looking at here, I'm going to use a, this is a minimal monorepo. It has a couple of packages in so far. One package is simply an express server that, mocking out the application registry that I talked about before, is gonna serve up our built content, so you can see the demo. And we also have an example of how you would create a host app.
Now, create React app would be able to serve these components, so it looks very similar to normal, using Webpack and Webpack dev server. Recently, we switched up to Webpack 5 and added support for ES build. With ES build, instead of generating a commons.js bundle, we're now creating an ES module bundle. So, what I'm gonna do in here is run a quick command to, there we go, to start up as an express server. It's also gonna start a Webpack dev server that builds this host application. It should, there we go, good. It's gonna very slowly load on localhost. My application, we'll just assume that that's the case. I'll come back to it.
So, thereafter, other things that modular has in it. Now, I mentioned this delivering of development at scale. At scale, we often have the need to create new applications and those new applications are created from templates. So, modular has a feature that can either use templates based on, that come directly from NPM or from within your repositories. So, I'm gonna use them, they're coming from my repository. So, I'm gonna add a new module into my monorepo. Gonna look at the card. Ah, I am, there we go, I can't type with people watching me. So, bringing modular commands to add a new package into my template, I've created some templates already, but just so you can see how they get added in. Why am I running through this? The templates that we add are actually, they can all be run as independent applications. So in the code view, I've now got a new application.
Comments