This repository demonstrates two approaches for structuring an Ionic Capacitor project with multiple modules (Core, WMS, ASRS).
./
/module_federation
/Core (Host App + Capacitor)
/WMS (Remote App)
/ASRS (Remote App)
/npm_package
/Core (Host App + Capacitor)
/WMS (Library Package)
/ASRS (Library Package)
Both approaches now share a consistent navigation flow and user experience:
- Login Page (
/login): Entry point. Enter any username to proceed. - Dashboard (
/app/home): Main landing page with quick links. - Side Menu: Accessible via the hamburger icon, providing navigation to:
- Home
- Profile
- WMS Module
- ASRS Module
- Profile Page (
/app/profile): Displays user info and Logout button.
In this approach, Core is the host application that dynamically loads WMS and ASRS at runtime. This allows for independent deployment and updates of the modules.
-
Install Dependencies: Navigate to each folder (
Core,WMS,ASRS) and runnpm install. -
Run WMS (Remote):
cd module_federation/WMS npm run dev # Runs on http://localhost:5001
-
Run ASRS (Remote):
cd module_federation/ASRS npm run dev # Runs on http://localhost:5002
-
Run Core (Host):
cd module_federation/Core npm run dev # Runs on http://localhost:5000 (or similar, check console)
Note: Ensure WMS and ASRS are running before accessing them from Core.
- Core: Deployed to the device (via Capacitor) or Edge Server. Points to remote URLs for WMS and ASRS.
- WMS/ASRS: Deployed to an Edge Server.
- Updates: You can update WMS or ASRS on the server without redeploying the Core app on the device (unless shared dependencies change significantly).
In this approach, WMS and ASRS are built as libraries (NPM packages) and installed into Core at build time.
-
Build WMS Library:
cd npm_package/WMS npm install npm run build -
Build ASRS Library:
cd npm_package/ASRS npm install npm run build -
Run Core:
cd npm_package/Core npm install npm run devNote: The
package.jsonin Core usesfile:../WMSandfile:../ASRSto link the local packages.
- Monolithic Build:
CorebundlesWMSandASRScode into a single application. - Updates: To update WMS or ASRS, you must rebuild and redeploy the entire Core application.
| Feature | Module Federation | NPM Package |
|---|---|---|
| Integration | Runtime (Dynamic) | Build-time (Static) |
| Deployment | Independent modules | Monolithic bundle |
| Updates | Instant (for remotes) | Requires app update |
| Complexity | Higher (config, sharing) | Lower (standard import) |
| Native Access | Via exposed Core components | Via props/context from Core |