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
Overview
Name
Filename
Remotes
Exposes
Shared
runtimePlugins
Get Public Path
Implementation
DTS
Dev
Manifest
shareStrategy
experiments
Edit this page on GitHub
Previous PageRemotes
Next PageShared

#Exposes

  • Type: PluginExposesOptions
  • Required: No
  • Default value: undefined
  • Usage: Determines the modules and file entries exposed by Module Federation.
TIP

A producer-specific parameter, setting exposes indicates that this is a producer.

After configuration, the exposed modules will be separated into a distinct chunk, and if there are any asynchronous chunks, they will be extracted into individual chunks as well (the specific extraction behavior depends on the chunk splitting rules).

The PluginExposesOptions type is as follows:

interface PluginExposesOptions {
  [exposeKey: string]: string | ExposesConfig;
}

interface ExposesConfig {
  // File entry
  import: string;
}

The exposeKey is essentially consistent with the Package Entry Points specification (except for not supporting regular expression matching).

Example:

module.exports = {
  plugins: [
    new ModuleFederationPlugin({
      name: 'provider',
      exposes: {
        // Note: "./" is not supported. Exporting as `.` indicates a default export
        '.': './src/index.tsx',
        './add': './src/utils/add.ts',
        './Button': './src/components/Button.tsx',
      },
    }),
  ],
};