@module-federation/enhanced
and @module-federation/modern-js
provides a lightweight CLI.
To view all available CLI commands, run the following command in the project directory:
The output is shown below:
Module Federation CLI provides several common flags that can be used with all commands:
Flag | Description |
---|---|
-c, --config <config> |
Specify the configuration file, can be a relative or absolute path, default value is module-federation.ts |
-m, --mode <mode> |
Specify the runtime environment. You can choose "dev" or "prod". The default value is "dev". After setting, the process.env.NODE_ENV environment variable will be automatically injected with "development" or "production" according to the value. |
-h, --help |
Display help for command |
The mf dts
command is used to generate or fetch remote types.
The mf dts
command will automatically generate or pull type declaration files based on the configuration in module-federation.config.ts
. This means you must provide a valid configuration file, otherwise the command will not work properly.
If you only use the runtime API, you need to create a temporary module-federation.config.ts
file, write the remote configuration you need to get the type, and then run the mf dts
command.
If you are only using the runtime API, you need to create a temporary module-federation.config.ts
file, configure dts.consumeTypes.remoteTypeUrls, and then run the mf dts
command.