0Pricing
Micro Frontends Architecture with Module Federation · Aula

Aplicações hospedeiras e remotas

Aprenda a distinção entre aplicações hospedeiras e remotas em uma configuração federada e entenda o papel de cada uma.

Aplicações hospedeiras e remotas é uma aula grátis de Micro Frontends Architecture with Module Federation no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Micro Frontends Architecture with Module Federation, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Micro Frontends Architecture with Module Federation inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

What are Hosts & Remotes?

In Module Federation, applications play distinct roles: some are hosts, and others are remotes. Think of it like a main stage (host) that invites guest performers (remotes) to share their acts.

This setup allows large applications to be broken down into smaller, independently developed and deployed pieces.

The Host: Your Main App

The Host application is the primary application that boots up first. Its main job is to consume (or load) modules that are exposed by other applications, called Remotes.

It's like the main website that pulls in different widgets or sections from other services.

Host's Key Responsibilities

The Host application has a few crucial responsibilities:

  • Loading Remotes: It tells Webpack which remote applications it needs to load.
  • Providing Context: It often provides the overall application shell, routing, and shared dependencies.
  • Integrating Modules: It renders components or uses functions provided by the remote applications.

The Remote: A Shared Piece

A Remote application is a separate, self-contained application that exposes specific parts of its code for others to consume. It can also consume modules from other remotes (or even act as a host itself!).

These exposed parts could be components, utility functions, or even entire pages.

Remote's Key Responsibilities

The Remote application focuses on:

  • Developing Features: It builds specific features or UI components independently.
  • Exposing Modules: It explicitly defines which parts of its codebase can be shared with host applications.
  • Independent Deployment: It can be built and deployed without affecting the host or other remotes, as long as its exposed interfaces remain consistent.

ModuleFederationPlugin: The Link

Webpack's ModuleFederationPlugin is the magic behind this interaction. Both host and remote applications use this plugin in their Webpack configurations.

It orchestrates how modules are exposed by remotes and consumed by hosts, making them available at runtime.

Remote: Exposing Modules

On the Remote side, you use the exposes property in the ModuleFederationPlugin configuration.

This tells Webpack which files or modules from your remote application should be made available to others.

// webpack.config.js (remote app)
new ModuleFederationPlugin({
  name: 'remoteApp',
  exposes: {
    './Button': './src/Button.js',
    './Header': './src/Header.js'
  }
})

Host: Consuming Remotes

On the Host side, you use the remotes property to declare which remote applications you want to consume from.

You specify a unique name for the remote and its entry point URL.

// webpack.config.js (host app)
new ModuleFederationPlugin({
  name: 'hostApp',
  remotes: {
    remoteApp: 'remoteApp@http://localhost:3001/remoteEntry.js'
  }
})

How They Interact

When the Host application loads, it fetches the remoteEntry.js file from the configured remote URL. This entry file contains a manifest of all modules the remote exposes.

The Host can then dynamically import and use these exposed modules as if they were part of its own codebase.

Quick Check

Which of the following best describes the primary role of a Host application in a Module Federation setup?

Host & Remote Recap

We've learned about the fundamental roles of Host and Remote applications in Module Federation.

  • Host apps are the main integrators, consuming functionality.
  • Remote apps are independent units that expose specific modules.

Understanding these roles is key to building scalable micro frontends. Next, we'll dive deeper into setting up your first federated application!

Perguntas Frequentes

A aula “Aplicações hospedeiras e remotas” é grátis?

Sim — o texto completo de “Aplicações hospedeiras e remotas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Micro Frontends Architecture with Module Federation, atualize para CoddyKit PRO. O curso de Micro Frontends Architecture with Module Federation inclui 4 aulas no total.

O que vou aprender em “Aplicações hospedeiras e remotas”?

Aprenda a distinção entre aplicações hospedeiras e remotas em uma configuração federada e entenda o papel de cada uma. Você pratica Micro Frontends Architecture with Module Federation com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Micro Frontends Architecture with Module Federation?

Nenhuma experiência prévia é necessária. Micro Frontends Architecture with Module Federation no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.

Quanto tempo leva a aula “Aplicações hospedeiras e remotas”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Micro Frontends Architecture with Module Federation?

Sim. Cada aula de Micro Frontends Architecture with Module Federation inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Revisão dos fundamentos do Webpack
  2. Introdução à federação de módulos
  3. Aplicações hospedeiras e remotas
  4. Configuração de Dependências Compartilhadas
← Voltar para Micro Frontends Architecture with Module Federation