Make react and lingui eager module-federation singletons to stabilize the federated i18n context#914
Open
raix wants to merge 1 commit into
Open
Conversation
… the federated i18n context
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary & Motivation
Make the federated translation context a single instance so a federated component's
useLinguican no longer throwused without I18nProvideron a direct or reloaded page load.singleton: true,@lingui/coreand@lingui/reactwere duplicated at runtime — a probe recorded two distincti18n/LinguiContext/useLinguiinstances across the remote loads. A remote consumed early on a direct load (account'sAuthSyncModalvia thewithSystemTranslationsgate) fell back to its own bundled copy, getting a secondLinguiContextwith no provider.react/react-domwere not duplicated (pluginReacthandles those), which is why only the Lingui path broke.react,react-dom,@lingui/core, and@lingui/reactaseagersingletons in the module-federationsharedmap (inModuleFederationPlugin.ts).eagerplaces them in the shared scope during the host's synchronous startup, before any remote consumes them, so there is no per-remote fallback copy. The four are required together — eager Lingui synchronously requires react, so react/react-dom must be eager too.@tanstack/react-routerand@tanstack/react-querystay non-eager singletons.Checklist