Skip to content

[codex] add federation hmr parity controls to zephyr wrappers#354

Draft
ScriptedAlchemy wants to merge 2 commits intomainfrom
codex/zephyr-mf-hmr-parity
Draft

[codex] add federation hmr parity controls to zephyr wrappers#354
ScriptedAlchemy wants to merge 2 commits intomainfrom
codex/zephyr-mf-hmr-parity

Conversation

@ScriptedAlchemy
Copy link
Copy Markdown
Contributor

Summary

This PR adds explicit Module Federation HMR parity controls to Zephyr's webpack/rspack/rsbuild plugin path and changes the default mutation behavior so local development remotes are no longer rewritten away from native dev/HMR flows.

Problem

In Zephyr-wrapped federated builds, local dev remotes could be rewritten to Zephyr delegate/runtime forms during config mutation. That behavior breaks the expected local Module Federation development experience where remote changes propagate through native HMR/Fast Refresh. DTS consume settings were also easy to miss in build/watch flows, especially when tools run with production env defaults while still watching.

Root Cause

Zephyr's remotes mutation pipeline did not have an HMR-aware mode. It always treated remotes uniformly and did not preserve local dev endpoints. There was also no central place to normalize dev/watch behavior and apply DTS consume-type defaults for HMR-compatible development.

What Changed

  • Added federation HMR normalization utilities in zephyr-xpack-internal:
    • ZephyrFederationHmrOptions
    • normalizeFederationHmrOptions
    • isLocalDevRemote
    • shouldPreserveLocalDevRemotes
    • applyFederationDtsOptions
  • Extended federated config mutation:
    • mutWebpackFederatedRemotesConfig now accepts options.federationHmr.
    • Detects local dev remotes and preserves them in dev-like mode.
    • Skips Zephyr runtime plugin insertion when preserving local remotes.
    • Applies DTS consume-type build defaults for dev/watch parity.
  • Exposed the new option through all Zephyr wrappers:
    • zephyr-webpack-plugin
    • zephyr-rspack-plugin
    • zephyr-rsbuild-plugin
  • Exported the new HMR option types from zephyr-xpack-internal.

Behavioral Effect for Users

  • Local remote URLs/manifests in dev/watch are preserved by default, allowing native MF HMR/Fast Refresh behavior to continue instead of being overridden.
  • DTS consume behavior is normalized in dev-like workflows so type updates are available during build/watch flows.
  • Consumers can opt out or fine-tune with federationHmr options.

Validation

Executed in zephyr-packages:

  • pnpm nx run-many -t build --projects=zephyr-xpack-internal,zephyr-webpack-plugin,zephyr-rspack-plugin,zephyr-rsbuild-plugin --skip-nx-cache
  • pnpm nx run-many -t lint --projects=zephyr-xpack-internal,zephyr-webpack-plugin,zephyr-rspack-plugin,zephyr-rsbuild-plugin --skip-nx-cache
  • Pre-commit hooks ran broader affected test/lint matrix and passed.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Feb 11, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 20981f7

Command Status Duration Result
nx affected -t build --skipRemoteCache ❌ Failed 41s View ↗
nx affected -t test ✅ Succeeded 1m 46s View ↗
nx affected -t lint ✅ Succeeded 9s View ↗
nx affected --exclude=!libs/** -t build --skipR... ✅ Succeeded 13s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-11 11:57:18 UTC

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Feb 11, 2026

View your CI Pipeline Execution ↗ for commit 20981f7

Command Status Duration Result
nx affected -t lint ✅ Succeeded 9s View ↗
nx affected --exclude=!libs/** -t build --skipR... ✅ Succeeded 13s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-11 11:52:33 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants