Skip to content

[v6] Drop Module Federation v1 support and migrate fully to v2 #1420

Description

@dannyhw

Motivation

Re.Pack currently ships two Module Federation implementations side by side: ModuleFederationPluginV1 (built on webpack's/Rspack's native container API) and ModuleFederationPluginV2 (built on @module-federation/enhanced). The generic Repack.plugins.ModuleFederationPlugin export still resolves to V1 and logs a notice on every build stating that the next major will repoint it at V2. v6 is that major.

MF v1 is no longer being iterated on upstream — all Module Federation development happens in the @module-federation/* v2 packages. Carrying both implementations doubles the plugin surface, the documentation, the tester apps and the test matrix, and it blocks a set of cleanups that only make sense once V1 is gone.

Part of #1414 (Roadmap to V6), which already lists MF v2+ as a minimum-version target and "updated docs for MF v2" as a deliverable.

Breaking changes

  • Repack.plugins.ModuleFederationPlugin starts resolving to the V2 implementation. Configs written against the V1 option shape need migrating.
  • ModuleFederationPluginV1 is removed.
  • @module-federation/enhanced effectively becomes a required peer dependency instead of an optional one. V1 needed no extra install; V2 hard-fails without it (ensureModuleFederationPackageInstalled in packages/repack/src/plugins/ModuleFederationPluginV2.ts).
  • The build-side Federated namespace (createRemote, SHARED_REACT, SHARED_REACT_NATIVE in packages/repack/src/utils/federated.ts) is removed — it is only consumed by V1.

Scope

Core

  • Repoint ModuleFederationPlugin at the V2 implementation and drop the beforeCompile deprecation notice in packages/repack/src/plugins/ModuleFederationPlugin.ts
  • Keep ModuleFederationPluginV2 exported as an alias so existing v5 configs continue to work unchanged
  • Remove packages/repack/src/plugins/ModuleFederationPluginV1.ts, its export from plugins/index.ts, and its unit tests
  • Remove packages/repack/src/utils/federated.ts and its re-export from utils/index.ts
  • Decide the fate of the client-side Federated namespace (importModule, createURLResolver in packages/repack/src/modules/ScriptManager/federated.ts) — superseded by the MF v2 resolver runtime plugin, but it is public API and may be used independently of the build plugin
  • Move @module-federation/enhanced out of peerDependenciesMeta.optional and raise the peer floor to a 2.x range

Apps and tests

  • Migrate apps/tester-federation to V2, or fold it into apps/tester-federation-v2 and delete it — once both are on V2 they largely duplicate each other, so consolidating into a single tester-federation app is probably the better outcome
  • Drop the with Module Federation v1 case in tests/integration/src/plugins/NativeEntryPlugin.test.ts
  • Update the MF version matrix in the same file (currently 0.15.0 / 0.21.0 / 2.0.1) to match the new supported range

Docs

  • Remove website/src/latest/api/plugins/module-federation-v1.mdx and rename module-federation-v2.mdx to module-federation.mdx
  • Rewrite website/src/latest/docs/features/module-federation.md, which currently just redirects readers to the Re.Pack 4.x docs with a caveat that they are out of date
  • Add an MF v1 → v2 section to the v5 → v6 migration guide

Prerequisite

This depends on first bumping @module-federation/enhanced in packages/repack from 0.8.9 to 2.x. That bump is a small standalone change but does have breakage of its own:

  • FederationRuntimePlugin was renamed to ModuleFederationRuntimePlugin and FederationHost to ModuleFederation, affecting all three runtime plugins in packages/repack/src/modules/FederationRuntimePlugins/
  • runtimePlugins widened to (string | [string, Record<string, unknown>])[], so adaptRuntimePlugins needs to handle the tuple form — which also unlocks passing options to runtime plugins
  • the jest.mock('@module-federation/enhanced/rspack') automock in ModuleFederationPluginV2.test.ts no longer produces a constructor and needs an explicit factory

As a bonus, moving to @module-federation/enhanced >= 2.4.0 also releases the webpack hold at ~5.105.0 in pnpm-workspace.yaml, which exists solely because older MF versions depend on a webpack internal removed in 5.106.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:repackThe issue is about logic/code inside of Re.Pack.type:featureProposal or idea for a new feature or enhancement.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions