Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions module-federation/angular-vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ pnpm dev

## What's Inside

- `remote/` exposes `PromoCardComponent` as `angular_remote/PromoCard`
- `remote/` exposes `PromoCardComponent` as `angular_vite_remote/PromoCard`
- `host/` imports the remote component at runtime and renders it with `NgComponentOutlet`
- Both apps use Vite, standalone Angular components, zoneless change detection, and shared Module Federation config
- Vite runs `@module-federation/vite` directly and `vite-plugin-zephyr` alongside it
- The host declares `zephyr:dependencies` so Zephyr can resolve `angular_remote` during deployment
- The host declares `zephyr:dependencies` so Zephyr can resolve `angular_vite_remote` during deployment

## Why Analog's Vite Plugin?

Expand Down
4 changes: 2 additions & 2 deletions module-federation/angular-vite/host/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "angular_host",
"name": "angular_vite_host",
"private": true,
"version": "0.0.0",
"type": "module",
Expand Down Expand Up @@ -27,6 +27,6 @@
"vite-plugin-zephyr": "1.0.3"
},
"zephyr:dependencies": {
"angular_remote": "workspace:*"
"angular_vite_remote": "workspace:*"
}
}
4 changes: 2 additions & 2 deletions module-federation/angular-vite/host/src/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import { Component, signal, Type } from '@angular/core';
<section class="remote-slot" aria-label="Federated remote component">
<div class="section-heading">
<h2>Remote loaded by the host</h2>
<p>The card is compiled and served by <code>angular_remote</code>.</p>
<p>The card is compiled and served by <code>angular_vite_remote</code>.</p>
</div>
@if (remoteComponent()) {
<ng-container *ngComponentOutlet="remoteComponent()" />
Expand Down Expand Up @@ -403,7 +403,7 @@ export class AppComponent {
}

private async loadRemote(): Promise<void> {
const remote = await import('angular_remote/PromoCard');
const remote = await import('angular_vite_remote/PromoCard');
this.remoteComponent.set(remote.PromoCardComponent);
}
}
3 changes: 1 addition & 2 deletions module-federation/angular-vite/host/src/remotes.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
declare module 'angular_remote/PromoCard' {
declare module 'angular_vite_remote/PromoCard' {
import type { Type } from '@angular/core';

export const PromoCardComponent: Type<unknown>;
}

8 changes: 4 additions & 4 deletions module-federation/angular-vite/host/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import { defineConfig } from 'vite';
import { withZephyr, type ModuleFederationOptions } from 'vite-plugin-zephyr';

const mfConfig: ModuleFederationOptions = {
name: 'angular_host',
name: 'angular_vite_host',
filename: 'remoteEntry.js',
remotes: {
angular_remote: {
angular_vite_remote: {
type: 'module',
name: 'angular_remote',
name: 'angular_vite_remote',
entry: 'http://localhost:5174/remoteEntry.js',
entryGlobalName: 'angular_remote',
entryGlobalName: 'angular_vite_remote',
shareScope: 'default',
},
},
Expand Down
6 changes: 3 additions & 3 deletions module-federation/angular-vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "pnpm --parallel --filter angular_host --filter angular_remote dev",
"dev": "pnpm --parallel --filter angular_vite_host --filter angular_vite_remote dev",
"build": "pnpm build-remote && pnpm build-host",
"build-host": "pnpm --filter angular_host build",
"build-remote": "pnpm --filter angular_remote build"
"build-host": "pnpm --filter angular_vite_host build",
"build-remote": "pnpm --filter angular_vite_remote build"
},
"devDependencies": {
"@module-federation/vite": "1.15.1",
Expand Down
4 changes: 2 additions & 2 deletions module-federation/angular-vite/remote/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
min-height: 100%;
}

app-root {
app-promo-card {
display: block;
min-height: 100vh;
padding: 24px;
}
</style>
</head>
<body>
<app-root></app-root>
<app-promo-card></app-promo-card>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion module-federation/angular-vite/remote/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "angular_remote",
"name": "angular_vite_remote",
"private": true,
"version": "0.0.0",
"type": "module",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Component } from '@angular/core';
<dl>
<div>
<dt>Remote</dt>
<dd>angular_remote</dd>
<dd>angular_vite_remote</dd>
</div>
<div>
<dt>Expose</dt>
Expand Down
2 changes: 1 addition & 1 deletion module-federation/angular-vite/remote/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { defineConfig } from 'vite';
import { withZephyr, type ModuleFederationOptions } from 'vite-plugin-zephyr';

const mfConfig: ModuleFederationOptions = {
name: 'angular_remote',
name: 'angular_vite_remote',
filename: 'remoteEntry.js',
exposes: {
'./PromoCard': './src/promo-card.component.ts',
Expand Down
15 changes: 15 additions & 0 deletions scripts/src/tests/app-validations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,21 @@ export const APP_VALIDATIONS: Record<string, AppValidation> = {
remote2: {
uniqueText: ["Remote 2", "Module Federation"],
},
"angular-vite-host": {
uniqueText: [
"Angular + Vite",
"Remote loaded by the host",
"Federated starter card",
"angular_vite_remote",
],
},
"angular-vite-remote": {
uniqueText: [
"Federated starter card",
"angular_vite_remote",
"./PromoCard",
],
},

// Airbnb clone microfrontends
"airbnb-react-host": {
Expand Down
Loading