Front-end development has grown so much over the last decade from pure HTML and CSS design to topics such as high interactivity, accessibility, testability, and security. In order to meet these needs, most application teams have made distinctions between backend and front-end development teams.
In addition to that, the application functionality grows steadily and, at a certain point, it becomes impractical to have multiple teams collaborate on a single code base.
The term "Micro Front-ends" has been a buzzword for breaking up growing front-end code into easy-to-maintain parts. The front-end is divided into its multiple functions or parts. These parts are implemented and deployed by independent teams. This increases the testability, reusability, and offers the possibility to select different technologies for each micro front-end.
I will stop at this point and, without further ado, let's build sample micro front-ends using Angular elements.
Building Micro Front-Ends
We will build a sample travel booking system in this article. Let's spin up two Angular projects using CLI: travel-booking and flight-booking.
We will need a few dependencies to build and run Angular custom elements. Install the following dependencies inside flight-booking using following commands.
ngadd@angular/elementsngaddngx-build-plus
These dependencies can also be installed via npm. @angular/elements provides support for Angular elements. ngx-build-plus is a build tool for Angular which is an extension of Angular CLI.
Note: You may need to update the version for the document-register-element module to 1.8.1 in /flight-booking/package.json as described in this issue.
Let us also install the HTTP-server module inside the flight-booking project.
npmi-ghttp-server--save
Create a component booking in flight-booking/src/app/. Let's modify the component as follows: flight-booking/src/app/booking/booking.component.html
<!--The content below is only a placeholder and can be replaced.-->
<divstyle="text-align:center">
<ahref="javascript:alert('Welcome to Flight Booking App!!');"style="font-size:25px;">{{ title }}</a>
To build the project in a single JS file, we need to tell angular to use the ngx-build-plus module. Modify flight-booking/angular.json in three places as follows:
Here, Angular requires zones. and custom-elements-es5-adapter.js provides custom element support within the browser. We also included main.js from our custom elements.
Modify travel-booking/angular.json to override the default server port.
Run the application using ng serve.The final application will look like this:
Wrapping Up
Using simple examples, this article demonstrates how we can build a micro front-end architecture using Angular elements. I hope you enjoyed my article. Let me know your experiences if you are working with micro front-end architecture.
Really Nice blog. It will be helpful for those who are unaware about it.Thanks for sharing this blog. If anybody looking to develop mobile apps using latest Technology. I would recommend Webi7 for mobile apps development companies in bangalore
4 Comments
thank you!web portal development Company
ReplyDeleteWeb Portal development Services
THANK YOU FOR THE INFORMATION
ReplyDeletePLEASE VISIT US
Website development in Bangalore
ReplyDeleteAwesome Article Keep on sharing
Full Stack online Training
Full Stack Training
Full Stack Developer Online Training
Full Stack Training in Hyderabad
Full Stack Training in Ameerpet
Full Stack Training Institute
Really Nice blog. It will be helpful for those who are unaware about it.Thanks for sharing this blog. If anybody looking to develop mobile apps using latest Technology. I would recommend Webi7 for mobile apps development companies in bangalore
ReplyDelete