Skip to content

[Bug] HMR / auto-reload not working in host shell when remote MFE rebuilds (Angular 22) #54

@hoan02

Description

@hoan02

When using @angular-architects/native-federation@22.0.0 with Angular 22:

Setup

  • Host app (port 4200) loads remote MFE-1 via native federation
  • MFE-1 (port 4201) served via @angular-architects/native-federation:build builder
  • buildNotifications: { enable: true } configured on MFE-1
  • Host uses initFederation() from @softarc/native-federation-orchestrator to load remote MFE-1

Problem

When code changes in MFE-1:

  1. MFE-1 rebuilds successfully
  2. The host shell does NOT auto-reload — SSE build notifications don't trigger
  3. Developers must manually F5/refresh the browser to see changes

Console shows SSE connection opens ([Federation SSE] Client connected) but completed events don't propagate to trigger a reload in the host shell.

What I've tried

  • Enabling buildNotifications in angular.json on the remote MFE-1
  • Creating a custom EventSource in the host to listen for build events
  • Using useShimImportMap({ shimMode: true }) — shim mode may interfere with native EventSource behavior
  • The SSE connection establishes, but BUILD_COMPLETED events don't cause a page reload

Workaround (temporary)

Patched the MFE-1 builder (builder.js in node_modules) to write a build-timestamp.json to the output directory on each rebuild, then poll it from the host. Not ideal.

Related

Expected behavior

When a remote MFE finishes rebuilding in development mode, the host shell should automatically detect the change and reload/refresh the page — restoring the fast feedback loop developers expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions