Skip to content

npm link + shared libraries stale federation rebuilds and no browser reload in local dev (NF v4 / Angular 21) #55

@mohsenvafa

Description

@mohsenvafa

Summary

We use Native Federation v4 on Angular 21 with a shell + 3 MFE remotes. Shared libraries (@cr-portal/common, @cr-portal-domain/core) are developed locally via npm link (ng-packagr dist/ symlinked into the host’s node_modules, with ng build --watch in the lib repos).

In local dev, changes to linked libraries don’t reliably show up in the browser. The dev server often logs a federation rebuild (Re-bundling… Done!), but we still need a manual browser refresh — and sometimes a dev-server restart — to see updates. This is much worse than normal ng serve live reload.

We previously got it working with a custom patch (file watcher + forced remapping rebuild + browser reload via SSE), but removed it because it was too fragile to maintain across upgrades.


Environment

Package | Version -- | -- Angular (@angular/core, CLI, @angular/build, Material, etc.) | 21.2.12 @angular-architects/native-federation-v4 | 21.2.1 @softarc/native-federation | 4.1.3 @softarc/native-federation-orchestrator | 4.2.2 @softarc/native-federation-node | 3.3.4 TypeScript | 5.9.3 es-module-shims | 1.5.12 Node | >=20.19.0 (22.x also tested)

We removed all patches and are using manual refresh for now.


Suggestion

Please consider first-class support for npm link / locally linked shared packages in NF v4 dev mode, for example:

  • Watch linked package paths under node_modules (or configurable watch roots)
  • Reliable cache invalidation when sharedMappings resolve through symlinks
  • Wire up host browser reload when federation rebuild completes (SSE / buildNotificationsEndpoint)
  • Document a supported npm-link local dev workflow for v4

Willing to help

Happy to provide:

  • Terminal logs (rebuild + SSE lines)
  • Details of the patch approach that worked but was abandoned

Thanks for looking into this.

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