Skip to content

Enable HMR Support for Remote (Producer) App in Vite Module Federation Dev Mode #733

@malikrajat

Description

@malikrajat

Hello Team,

I am using Vite with Module Federation via vite-plugin-federation in a micro-frontend architecture (origin-based federation).

Current Setup

Producer App (Remote)

  • Exposes modules via Module Federation.
  • Generates remoteEntry.js only during vite build.
  • Must run vite build before the host can consume it.
  • To serve it, I must run vite preview.
  • Consumer App (Host)

    • Runs using pnpm dev.
    • HMR works correctly within the host application.
    • Consumes remoteEntry.js from the producer.

Problem

In development mode:

  1. The producer app does not support HMR for exposed modules.

  2. Any change in the producer requires:

    • Re-running vite build
    • Restarting vite preview
  3. The consumer app must then re-fetch the updated remoteEntry.js.

This leads to:

  • Multiple terminals:

    • Producer: build + preview
    • Consumer: dev
  • Frequent restarts

  • Slower development workflow

  • No real-time HMR across federated boundaries

In contrast, the consumer (host) app benefits from Vite’s excellent HMR, but the remote app does not.

Expected Behavior

It would significantly improve developer experience if:

  • The producer app could run in dev mode

  • remoteEntry.js could be dynamically generated in memory (similar to Webpack dev server)

  • HMR updates from producer propagate to consumer without requiring:

    • Full rebuild
    • Preview restart
    • Manual refresh

Essentially, enabling cross-application HMR in a federated Vite setup.

Why This Matters

In real-world micro-frontend systems:

  • Multiple independent teams work on remotes
  • Fast feedback cycles are critical
  • Rebuilding and restarting services repeatedly impacts productivity

#Question

Is there:

  • A recommended dev-mode configuration for enabling remote HMR?
  • A roadmap item planned for this?
  • Any architectural limitation preventing this behavior?

If not currently supported, I would like to formally request this as a feature enhancement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions