'version-first' | 'loaded-first'
'version-first'
(set by webpack plugin/bundler runtime)Control the loading strategy of shared dependencies:
'version-first'
: Version priority, ensuring that the highest version of shared dependencies is used. All remotes entry files will be automatically loaded during initialization to register shared dependencies and ensure version compatibility. This strategy is recommended when there are strict version requirements.
'loaded-first'
: Prioritize reuse of already loaded shared dependencies. Remotes are loaded on-demand rather than during initialization. This strategy is recommended when you want to reuse loaded dependencies for performance.
The 'version-first'
strategy automatically loads remote entry files during application startup to initialize shared dependencies. If any remote is offline or unreachable, this will trigger the errorLoadRemote
hook with lifecycle: 'beforeLoadShare'
during startup. Without proper error handling, this can cause application initialization failures.
The 'loaded-first'
strategy defers remote loading until modules are actually requested, which means offline remotes only cause failures when those specific remotes are accessed, not during application startup.
What happens with version-first and offline remotes:
initializeSharing()
module.getEntry()
failserrorLoadRemote
hook is called with lifecycle: 'beforeLoadShare'
Required error handling for version-first:
For production applications with potential network issues, consider:
'loaded-first'
strategy for better resilience'beforeLoadShare'
lifecycleSee Error Load Remote Solutions for detailed offline handling strategies.