Skip to content

[Feature]: Support per-shared dependency negotiation behavior (strict vs fallback) #69

Description

@leo2823

Is your feature request related to a problem?

No response

Describe the solution you'd like

In Module Federation, the negotiation behavior can be configured per shared dependency.

For example, it is possible to have:

  • shared dependencies that throw an error if version negotiation fails (singleton: true + strictVersion: true);
  • shared dependencies that fall back to loading another compatible version when negotiation fails.

In Native Federation v4, this behavior appears to be controlled globally by the strictExternalCompatibility option passed to initFederation(). As a result, it is not possible to configure the negotiation strategy for individual shared dependencies. We would like to configure some shared dependencies as strict while allowing others to fall back to their own implementation when version negotiation fails.

Additionally, is there a way to let a remote resolve its own shared dependency even if the host already provides the same package? At the moment, Native Federation v4 seems to always prioritize the host's shared dependency.

Example:

  • Host provides:

    • lodash-es@4.17.23
    • requiredVersion: ^4.17.23
  • Remote (front-office) provides:

    • lodash-es@4.18.1
    • requiredVersion: ^4.18.0

This results in:
[NF][3]: [front-office][lodash-es@4.18.1] Is not compatible with requiredRange '^4.17.23' from remote '__NF-HOST__'.
In this scenario, we would expect loading a single version lodash-es@4.18.1 into the global scope instead of failing, similarly to how Module Federation behaves.

  • Is there currently a configuration that allows negotiation behavior to be configured per shared dependency instead of globally?
  • Is it possible to let loading shared dependency from a remote even when the host provides the same package?

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions