Runtime Access
- O features and capabilities de Module Federation
- O glossary de Module Federation
- How para consume and export modules
Atualmente, Module Federation fornece two formas para register e carregar módulos:
-
One é para declare it no plugin de build (geralmente no
module-federation.config.tsarquivo). -
O other way é para diretamente register e carregar módulos por meio do
runtimeAPI.
O two modes não são conflicting e pode ser usado together. Você pode flexibly choose o módulo registration método e timing according para your actual scenario.
Differences entre o two approaches
If the build plugin is used, an MF instance will be automatically created and stored in memory when the project starts. You can directly call methods of the MF instance via the .
If the build plugin is not used, you need to manually create an MF instance before calling the corresponding API.
An object created by the ModuleFederation class that contains all runtime functionality. You can enter __FEDERATION__.__INSTANCES__ in the console to view the full instance information.
Instalação
Different projeto tipos deve instale e importe Runtime de diferente entries. Most projetos deve instale @module-federation/enhanced e importe API de runtimes de @module-federation/enhanced/runtime. Se your Modern.js projeto já usa uma Module Federation plugin, importe API de runtimes do plugin's /runtime entry so o framework plugin e manual Runtime calls use o mesmo Runtime instance.
@module-federation/enhanced
Modern.js
For Modern.js v2 projetos, instale @module-federation/modern-js e importe API de runtimes de @module-federation/modern-js/runtime.
Módulo Registration
Módulo Carregamento
Carregamento Anonymous Módulos
Carregamento Named Módulos
Carregamento Utility Funções
Read Next
- Runtime API:
createInstance,loadRemote,registerRemotes, e other runtime APIs. - Runtime Plugins: extend o carregamento em runtime flow.
- Runtime Hooks: lifecycle hooks disponível para runtime plugins.