Plugin System
Module Federation fornece uma lightweight runtime plugin system for implementing mais de its features e allowing users para extend functionalities.
Plugins developed by developers can modify the default behavior of Module Federation and add various additional features, including but not limited to:
- Obtaining context information
- Registering lifecycle hooks
- Modifying Module Federation configurações -...
Developing Plugins
Plugins são fornecido no form de uma função semelhante a () => ModuleFederationRuntimePlugin.
Plugin Exemplo
custom-runtime-plugin.ts
Registering plugins (either método é acceptable):
- Build-time registration de plugins
rspack.config.ts
- Runtime registration de plugins
Plugin Structure
Função-based plugins pode accept um opções objeto e retornar um plugin instance, managing internal estado por meio de closure mechanisms.
O roles de each part são as seguintes:
- O
namepropriedade é usado para label o plugin name. fnVarious hooks.
Naming Conventions
O naming conventions for plugins são as seguintes:
- O plugin função é chamado
xxx-plugine é exported com uma name. - O
namedo plugin follows oxxx-pluginformat.
Here é um exemplo:
Hooks Introduction
Refer para Runtime Hooks