#angular #moduleFederation
What is micro-frontend ?
Micro-frontends are a way to break down a large frontend application into smaller, independently deployable modules, similar to microservices on the backend. Angular micro-frontends use Webpack 5โs Module Federation feature to enable this architecture. Module Federation allows multiple teams to build and deploy features in isolation while composing them together at runtime.
Why Micro-Frontends?
Micro-frontends bring several benefits to modern web development:
โ Independent Deployment: Teams can build, test, and deploy individual parts of the frontend independently.
โ Better Scalability: Teams can work on their domain-specific features without interference from other teams.
โ Technology Agnostic: Different micro-frontends can use different frameworks.
What is Module Federation?
Module Federation is a feature in Webpack 5 that allows multiple applications to share code or load remote code at runtime. This is especially useful for micro-frontends, as it allows one Angular application to load modules from another application seamlessly.
How to Implement Angular Micro-Frontends Using Module Federation
We will break the setup into two parts:
โ Host Application: The main shell that loads different micro-frontends.
โ Remote Applications: Individual Angular micro-frontend apps that are federated into the host.
โ Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
#angular #signals #input #dynamic #ngComponentOutlet
โ Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
#angular #rxjs #shareReplay #let
โ Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
โค3
#angular #info #guide
Not having an architecture (or a plan) at all!
What is unfortunately often forgotten is that if we want to be able to keep moving fast also one year after we started our project, then we also need to make sure that our project doesnโt become an overconnected ball of mud or to use more technical term, we donโt end up with a tangled dependency graph with lotโs of circular dependenciesโฆ
One of the best way to know if this is your case is the constant feeling of being stuck in a spider web when trying to fix one thing leads you to a journey of changing half of the codebase, adding condition after condition just to make it work just this one more time.
Not thinking about eager and lazy parts of the app
Typical example is when we have some feature specific service which manages some kind of feature specific state and then we realize that it would be really great to be able to get that state also in some service in the eager core.
In that case, itโs very easy to just import and inject the feature service in the core service and overlook this eager / lazy boundary violation (or just miss it during the PR review). The outcome will be that the service (and everything else it imports) will suddenly become part of the eager Javascript bundle!
This is bad for performance and for architecture as well as weโre introducing dependencies between parts which should have been isolated (or only depend on each other in one direction, eg feature can consume core, but not the other way around!
Not lazy loading ALL the features
Another common offender that tends to happen also in reasonably architected projects is that even though they mostly embraced the eager / lazy split and have most of the logic implemented as the lazy loaded features, for some reason, some of the features are โforgottenโโฆ
The best way to remedy this is to always implement everything including the first (original feature) as a first lazy loaded feature.
Using more than one way to achieve the same
Letโs take routing as an example, currently there are at least 4 ways to do it
โ eager route to a component with component
โ lazy route to a component with `loadComponent`
โ lazy route to a module with `loadChildren`
โ lazy route to routes based feature (feature-x.routes.ts) with `loadChildren`
In this case, we most likely want to pick one and stick with it.
I would personally recommend to always define lazy route with the routes based feature with loadChildren which is the most modern and flexible way of doing things. Then, in case our lazy feature contains sub navigation, we can lazy load additional components with loadComponent .
Focusing on DRY instead of ISOLATION
The DRY is a principle aimed at reducing the code repetition in the codebase, replacing duplicate code with abstractions.
If the same information or logic is repeated in multiple places, any new requirement which necessitates a change in how it should work will require us to change the logic consistently in all these places which can lead to errors and inconsistencies.
The argument weโre trying to make is that in frontend codebases itโs better to have some amount of duplicated code (e.g. in multiple lazy features) because that will allow them to evolve independently as the requirements change, and they do change!
Madge
Madge is a developer tool for generating a visual graph of your module dependencies, finding circular dependencies, and giving you other useful info
โ madge npm docs
Not using standalone components
Using standalone components instead of NgModules means that our dependency graph becomes more granular and this higher resolution allows us to gain better insight of how each parts of app relate to each other and discover more issues!
Besides that, it allows lazy features to cherry pick only those UI components which is actually needs instead of depending on all of them, as was often the case when applications grouped and exposed them in commonly used SharedModule !
โ Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
โค3๐1
๐ How to design user-friendly forms: Validation and errors
#guide
#guide
Before a form is submitted, validation takes place. This means that required fields must be completed and input values must have a correct format. If something is wrong or missing, an error message will be shown to help the user meet the requirements.
Three types of error messages might appear in your form:
1) An error has occurred: It is necessary to clearly show that an error has occurred when filling out the form. Ideally, this message is shown in red colour;
2) Where the error occurred: It is necessary to highlight the field in which the error occurred;
3) How the error can be fixed: Put information on what needs to be different for the form to be validated correctly.
Itโs important to note that the list of errors will be read by screen readers making your website accessible. Once all the checks have passed, the form can be successfully submitted.
โค1
๐ How to design user-friendly forms: Optional vs. required
#guide
#guide
When designing forms, we often include both optional and required fields. Typically, we designate a required field by adding an asterisk (*) to it. Although we still find this method applied, it is increasingly being replaced by a different approach that uses words instead of symbols to indicate optional fields. Forms should collect the most important information and have a few optional fields. This will make it easier for people to comprehend the information, without overwhelming them with it.
This method offers a more intuitive approach, particularly for forms that are more extensive and complex.
#angular #signals #signalStore #guide
What is NGRX signalStore?
NgRx SignalStore is a fully-featured state management solution that offers a robust way to manage application state. With its native support for Signals, it provides the ability to define stores in a clear and declarative manner. The simplicity and flexibility of SignalStore, coupled with its opinionated and extensible design, establish it as a versatile solution for effective state management in Angular.
โ Article link
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
โค1๐1