Just like NPM Packages, Module Federation
products also generate types and enjoy type hot reloading, although the products are hosted on a remote CDN.
@module-federation/enhanced
enables the type prompt function by default. This article will introduce several common usage scenarios and specific configurations.
Building using the build plugin provided by @module-federation/enhanced
will automatically generate type files.
tsconfig.json
add paths
to tsconfig.json
:
info: No need to care the startup sequence of provider and consumer
After startup, the consumer will automatically pull the provider's type file.
After modifying the producer code, the consumer will automatically pull the producer's type.
It needs to add ./@mf-types/*
in the include
field to enjoy Federation Runtime
loadRemote
type hints and type hot reloading
Module Federation
will automatically extract third-party package types to ensure that exposes
file types can be accessed normally.
Module Federation
supports nested remotes and will automatically extract the nested remotes type.
Module Federation
supports loading dynamic types and generally supports hot updates.
A: It is most likely caused by the compiler monitoring changes in the type folder or dist
. Just add @mf-types
to the ignore file.
Take webpack/rspack as an example: