Lokalne uruchamianie i debugowanie aplikacji federacyjnej
Dowiedz się, jak uruchamiać aplikacje hosta i zdalne razem, przeglądać federowane moduły w przeglądarce oraz debugować typowe problemy podczas lokalnego programowania.
Lokalne uruchamianie i debugowanie aplikacji federacyjnej to bezpłatna lekcja Micro Frontends Architecture with Module Federation na CoddyKit. To lekcja 4 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Micro Frontends Architecture with Module Federation, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Micro Frontends Architecture with Module Federation zawiera 4 lekcji w sumie.
Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.
Local Development Setup
A federated app is really several apps. To develop, you run each remote and the host at the same time, each on its own port.
Assigning Ports
Give every app a fixed dev-server port so the host can reliably reference each remote during development.
devServer: { port: 3001 } // remote
devServer: { port: 3000 } // hostRunning Everything at Once
Manually opening many terminals is tedious. A tool like concurrently starts all dev servers with one command.
"scripts": {
"dev": "concurrently \"npm:dev:host\" \"npm:dev:remote\""
}Pointing the Host at Remotes
During development the host references each remote by its dev-server URL plus the exposed entry file.
remotes: {
cart: "cart@http://localhost:3001/remoteEntry.js"
}Inspecting remoteEntry.js
Every remote exposes a remoteEntry.js manifest. Open it directly in the browser to confirm the remote is running and to see what modules it exposes.
Using Browser DevTools
In the Network tab, watch for remoteEntry.js and the exposed module chunks loading. A 404 here is the most common federation error.
Common Error: Module Not Found
The error Cannot find module cart/Widget usually means the exposed path in the remote config does not match what the host imports. Names must match exactly.
exposes: { "./Widget": "./src/Widget" } // remote
import Widget from "cart/Widget"; // hostCommon Error: Shared React Twice
If React hooks throw Invalid hook call, two React copies are loading. Confirm singleton: true on React in every app config.
Hot Reload Limitations
Changes inside a remote may not hot-reload in the host automatically. Refresh the host, or restart the remote dev server, after editing exposed modules.
Logging Federation Resolution
Set verbose webpack stats or add console logs in your bootstrap to confirm which remote and shared versions resolved at run time.
console.log("loading remote cart...");
import("cart/Widget").then(m => mount(m.default));A Local Debug Checklist
When something breaks, check in order:
- Are all dev servers running?
- Does
remoteEntry.jsload (no 404)? - Do exposed names match imports?
- Is React a singleton everywhere?
Quick Check
Test your local debugging knowledge.
Recap
You learned to run and debug federated apps locally:
- Run host and remotes together on fixed ports
- Use
concurrentlyfor one-command startup - Inspect
remoteEntry.jsand the Network tab - Fix module-not-found and double-React errors
- Follow a quick debug checklist
Smooth local debugging speeds up MFE development.
Ucz się JavaScript dzięki korepetycjom AI — za darmo
Pisz i uruchamiaj kod w przeglądarce, otrzymuj natychmiastową pomoc od korepetytora AI dostępnego 24/7 i kontynuuj naukę w sieci lub w aplikacji.
- Kursy
- 12
- Lekcje
- 48
Często zadawane pytania
Czy lekcja „Lokalne uruchamianie i debugowanie aplikacji federacyjnej” jest bezpłatna?
Tak — pełny tekst „Lokalne uruchamianie i debugowanie aplikacji federacyjnej” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Micro Frontends Architecture with Module Federation, przejdź na CoddyKit PRO. Kurs Micro Frontends Architecture with Module Federation zawiera 4 lekcji w sumie.
Co nauczysz się w „Lokalne uruchamianie i debugowanie aplikacji federacyjnej”?
Dowiedz się, jak uruchamiać aplikacje hosta i zdalne razem, przeglądać federowane moduły w przeglądarce oraz debugować typowe problemy podczas lokalnego programowania. Ćwiczysz Micro Frontends Architecture with Module Federation z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.
Czy potrzebuję doświadczenia, aby zacząć Micro Frontends Architecture with Module Federation?
Nie wymagamy żadnego doświadczenia. Micro Frontends Architecture with Module Federation w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 4 z 4.
Ile czasu zajmuje lekcja „Lokalne uruchamianie i debugowanie aplikacji federacyjnej”?
Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.
Czy mogę pisać i uruchamiać kod w tej lekcji Micro Frontends Architecture with Module Federation?
Tak. Każda lekcja Micro Frontends Architecture with Module Federation zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.
Wszystkie lekcje w tym kursie
- Konfiguracja projektu
- Udostępnianie modułów i komponentów
- Tworzenie prostej aplikacji federacyjnej
- Lokalne uruchamianie i debugowanie aplikacji federacyjnej