logologo
Guide
Practice
Configuration
Plugins
Showcase
Blog
Ecosystem
Module Federation Examples
Practical Module Federation
Zephyr Cloud
Nx
简体中文
English
Guide
Practice
Configuration
Plugins
Showcase
Blog
Module Federation Examples
Practical Module Federation
Zephyr Cloud
Nx
简体中文
English
logologo

Getting Started

Introduction
Setting Up the Environment
Quick Start Guide
Feature Navigation
Glossary of Terms
npm Packages

basic

Runtime

Runtime Access
Runtime API
Runtime Hooks
Rsbuild Plugin
Rspack Plugin
Webpack Plugin
Rspress Plugin
Vite Plugin
Metro
Type Hinting
Command Line Tool
Style Isolation

Data Solution

Data Fetching
Data Caching
Prefetch

Frameworks

Modern.js
Next.js

Deployment

Deploy with Zephyr Cloud

Debug

Enable debug mode
Chrome DevTools
Global variables

Troubleshooting

Overview

Runtime

RUNTIME-001
RUNTIME-002
RUNTIME-003
RUNTIME-004
RUNTIME-005
RUNTIME-006
RUNTIME-007
RUNTIME-008
RUNTIME-009

Build

BUILD-001
BUILD-002

Type

Overview
TYPE-001
Other
Edit this page on GitHub
Previous PageType Hinting
Next PageStyle Isolation

#Command Line Tool

Module Federation provides lightweight command-line tools: @module-federation/enhanced and @module-federation/modern-js .

#View All Commands

If you need to view all available CLI commands, please run the following command in the project directory:

npx mf -h

Output:


Usage: mf <command> [options]

Options:
  -V, --version   output the version number
  -h, --help      display help for command

Commands:
  dts [options]   generate or fetch the mf types
  help [command]  display help for command

#Common Options

Module Federation CLI provides some common options that can be used for all commands:

OptionDescription
-c, --config <config>Specify the configuration file path, which can be a relative or absolute path. The default value is module-federation.config.ts
-m, --mode <mode>Specify the running environment, you can choose "dev" or "prod". The default value is "dev". After setting, "development" or "production" will be automatically injected into the process.env.NODE_ENV environment variable according to the value.
-h, --helpShow command help

#mf dts

The mf dts command is used to pull or generate TypeScript type declaration files.


Usage: mf dts [options]

generate or fetch the mf types

Options:
  --root <root>         specify the project root directory
  --output <output>     specify the generated dts output directory
  --fetch <boolean>     fetch types from remote, default is true (default: true)
  --generate <boolean>  generate types, default is true (default: true)
  -c --config <config>  specify the configuration file, can be a relative or absolute path
  -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. (default: "dev")
  -h, --help            display help for command
注意

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 run correctly.

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.