Skip to content

Commit 8dfaffb

Browse files
authored
docs: support MDX props injection for brand name customization (module-federation#4552)
1 parent 3946a4f commit 8dfaffb

24 files changed

Lines changed: 54 additions & 63 deletions

apps/website-new/docs/en/blog/error-load-remote.mdx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ title: Error handling for remote module rendering in Module Federation.
55
# Error handling for remote module rendering in Module Federation.
66
import BlogGifGrid from '@components/BlogGifGrid.tsx';
77

8-
:::tip Version Requirements
9-
This solution requires upgrading the `@module-federation/runtime` version to 0.8.10 or higher.
10-
:::
11-
128

139
## Background
1410
Remote module loading process may fail due to network resource loading failure or business logic rendering failure.
@@ -50,7 +46,7 @@ These three solutions are for different scenarios, can be used separately, or co
5046

5147
For weak network environment or producer has not started the service, we can add retry mechanism to request resources multiple times, which will increase the probability of resource loading success.
5248

53-
Module Federation official provides retry plugin [@module-federation/retry-plugin](https://module-federation.io/zh/plugin/plugins/retry-plugin.html) to support retry mechanism for resources, support fetch and script resources retry.
49+
Module Federation official provides retry plugin [@module-federation/retry-plugin](https://module-federation.io/zh/plugin/plugins/retry-plugin.html) to support retry mechanism for resources, support fetch and script resources retry.
5450

5551
#### Pure runtime registration
5652

@@ -313,7 +309,7 @@ export default defineConfig({
313309
```
314310

315311
:::info Tips
316-
The following example shows how to handle errors in different lifecycle stages.
312+
The following example shows how to handle errors in different lifecycle stages.
317313

318314
If your application scenario is simple, you can refer to the **simplified version** below, which provides a unified error handling solution.
319315

apps/website-new/docs/en/configure/dts.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- Type: `boolean | PluginDtsOptions`
44
- Required: No
55
- Default value: `true`
6-
- Usage scenario: used to control `Module Federation` generation/consumption type behavior
6+
- Usage scenario: used to control <code>{props.brandName || props.name || 'Module Federation'}</code> generation/consumption type behavior
77

88
After configuration, the producer will automatically generate a compressed type file `@mf-types.zip` (default name) during build, and the consumer will automatically pull the type file of `remotes` and decompress it to `@mf-types` (default name).
99

apps/website-new/docs/en/configure/exposes.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- Type: `PluginExposesOptions`
44
- Required: No
55
- Default value: `undefined`
6-
- Usage: Determines the modules and file entries exposed by `Module Federation`.
6+
- Usage: Determines the modules and file entries exposed by <code>{props.brandName || props.name || 'Module Federation'}</code>.
77

88
:::tip
99
A producer-specific parameter, setting `exposes` indicates that this is a producer.

apps/website-new/docs/en/configure/manifest.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
- Type: `boolean | PluginManifestOptions`
44
- Default value: `undefined`
55

6-
Controls whether the plugin generates manifest artifacts and how they are produced. When enabled, the plugin emits `mf-manifest.json` and `mf-stats.json` (names can be customized via `fileName`) on every build so that other tools can consume them directly through `processAssets` or from the final build output.
6+
Controls whether the plugin generates manifest artifacts and how they are produced. When enabled, the plugin emits <code>{props.manifest || 'mf-manifest.json' }</code> and <code>{props.stats || 'mf-stats.json' }</code> (names can be customized via `fileName`) on every build so that other tools can consume them directly through `processAssets` or from the final build output.
77

8-
- `mf-stats.json`: captures the full build statistics, including the assets for exposes/shared/remotes, `metaData` (plugin version, build info, `remoteEntry`, etc.), and any additional asset analysis. Ideal for debugging or merging stats across environments.
9-
- `mf-manifest.json`: a runtime-oriented manifest distilled from the stats. It keeps the stable structure that Module Federation consumers read when loading remote modules. The exposes/shared/remotes entries describe what is actually available to consumers.
8+
- <code>{props.stats || 'mf-stats.json'}</code>: captures the full build statistics, including the assets for exposes/shared/remotes, `metaData` (plugin version, build info, `remoteEntry`, etc.), and any additional asset analysis. Ideal for debugging or merging stats across environments.
9+
- <code>{props.manifest || 'mf-manifest.json'}</code>: a runtime-oriented manifest distilled from the stats. It keeps the stable structure that {props.brandName || 'Module Federation'} consumers read when loading remote modules. The exposes/shared/remotes entries describe what is actually available to consumers.
1010

1111
The `PluginManifestOptions` types are as follows:
1212

apps/website-new/docs/en/configure/shared.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,11 @@ At this point, you can add the corresponding dependencies to the `shared` config
168168

169169
### How to use shared dependencies
170170

171-
Depending on the use case, {props.name || 'Module Federation'} supports two forms of shared dependency configuration: array and object. The former is suitable for most scenarios, while the latter is suitable for complex customization needs.
171+
Depending on the use case, {props.brandName || props.name || 'Module Federation'} supports two forms of shared dependency configuration: array and object. The former is suitable for most scenarios, while the latter is suitable for complex customization needs.
172172

173173
**Array Format (General Scenario)**
174174

175-
Simply add the corresponding dependencies to the `shared` configuration in the {props.name || 'Module Federation'} build configuration, for example:
175+
Simply add the corresponding dependencies to the `shared` configuration in the {props.brandName || props.name || 'Module Federation'} build configuration, for example:
176176

177177
import ArrayShared from '@components/common/configure/array-shared';
178178
import React from 'react';
@@ -181,7 +181,7 @@ import React from 'react';
181181

182182
**Object Format (Customized Configuration)**
183183

184-
Add the shared dependencies in the `shared` configuration of the {props.name || 'Module Federation'}, with the `key` being the dependency name and the `value` being the provided configuration.
184+
Add the shared dependencies in the `shared` configuration of the {props.brandName || props.name || 'Module Federation'}, with the `key` being the dependency name and the `value` being the provided configuration.
185185

186186
import ObjectShared from '@components/common/configure/object-shared'
187187

apps/website-new/docs/en/configure/treeShakingDir.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ The directory used to output tree-shaking shared fallback assets.
66
- Required: No
77
- Default: `undefined`
88

9-
When shared dependency tree shaking is enabled, Module Federation will extract the exports of unused shared modules. This option specifies the output directory for those fallback assets.
9+
When shared dependency tree shaking is enabled, {props.brandName || props.name || 'Module Federation'} will extract the exports of unused shared modules. This option specifies the output directory for those fallback assets.

apps/website-new/docs/en/guide/build-plugins/plugins-rspack.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Rspack
22

3-
- Capable of building modules that meet the `Module Federation` loading specifications.
4-
- Can consume modules that adhere to the `Module Federation` specifications using aliases.
3+
- Capable of building modules that meet the <code>{props.brandName || props.name || 'Module Federation'}</code> loading specifications.
4+
- Can consume modules that adhere to the <code>{props.brandName || props.name || 'Module Federation'}</code> specifications using aliases.
55
- Can set shared dependency configurations for modules, so that when the host environment of the loaded module already has the corresponding dependency, it will not be loaded again.
66
- When a module has remote types, it will automatically download and consume the types of the remote modules.
77
- Consuming remote modules will have hot update capabilities.
@@ -18,10 +18,10 @@ import { PackageManagerTabs } from '@theme';
1818

1919
<PackageManagerTabs
2020
command={{
21-
npm: `npm add ${props.pkgName || '@module-federation/enhanced'}`,
22-
yarn: `yarn add ${props.pkgName || '@module-federation/enhanced'}`,
23-
pnpm: `pnpm add ${props.pkgName || '@module-federation/enhanced'}`,
24-
bun: `bun add ${props.pkgName || '@module-federation/enhanced'}`,
21+
npm: `npm add ${props.rspackPackage || props.pkgName || '@module-federation/enhanced'}`,
22+
yarn: `yarn add ${props.rspackPackage || props.pkgName || '@module-federation/enhanced'}`,
23+
pnpm: `pnpm add ${props.rspackPackage || props.pkgName || '@module-federation/enhanced'}`,
24+
bun: `bun add ${props.rspackPackage || props.pkgName || '@module-federation/enhanced'}`,
2525
}}
2626
/>
2727

apps/website-new/docs/en/guide/build-plugins/plugins-rspress.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Requires [Rspress version 2.0.0-beta.16](https://v2.rspress.rs/plugin/system/introduction) or higher.
55
:::
66

7-
Helps users build and consume {props.name || 'Module Federation'} products in **Rspress**.
7+
Helps users build and consume {props.brandName || props.name || 'Module Federation'} products in **Rspress**.
88

99
## Quick Start
1010

@@ -64,7 +64,7 @@ import ConfigType from '@components/common/rspress/config-type';
6464

6565
### {props.pluginOptionName || 'moduleFederationOptions'}
6666

67-
[{props.name || 'Module Federation'} Configuration](../../../configure/index)
67+
[{props.brandName || props.name || 'Module Federation'} Configuration](../../../configure/index)
6868

6969
### rspressOptions
7070

apps/website-new/docs/en/guide/build-plugins/plugins-webpack.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Webpack
22

3-
- Capable of building modules that meet the {props.name || 'Module Federation'} loading specification.
4-
- Capable of consuming modules of the {props.name || 'Module Federation'} specification using aliases.
3+
- Capable of building modules that meet the {props.brandName || props.name || 'Module Federation'} loading specification.
4+
- Capable of consuming modules of the {props.brandName || props.name || 'Module Federation'} specification using aliases.
55
- Capable of setting the shared dependency configuration for modules. When the host environment where the module is loaded already has the corresponding dependency, it will not be loaded repeatedly.
66
- When a module has a remote type, the type of the remote module will be automatically downloaded for consumption.
77
- Hot-reloading capability when consuming remote modules.
@@ -19,7 +19,7 @@ You can install the plugin with the following command:
1919
import InstallKit from '@components/common/install-kit';
2020

2121
<InstallKit
22-
pkgName={props.pkgName}
22+
pkgName={props.enhancedPackage || props.pkgName}
2323
/>
2424

2525
### Create {props.configName || 'module-federation.config.js'}

apps/website-new/docs/en/plugin/dev/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Plugin System
22

3-
Module Federation provides a lightweight runtime plugin system for implementing most of its features and allowing users to extend functionalities.
3+
{props.brandName || props.name || 'Module Federation'} provides a lightweight runtime plugin system for implementing most of its features and allowing users to extend functionalities.
44

5-
Plugins developed by developers can modify the default behavior of `Module Federation` and add various additional features, including but not limited to:
5+
Plugins developed by developers can modify the default behavior of <code>{props.brandName || props.name || 'Module Federation'}</code> and add various additional features, including but not limited to:
66

77
- Obtaining context information
88
- Registering lifecycle hooks
9-
- Modifying Module Federation configurations
9+
- Modifying {props.brandName || props.name || 'Module Federation'} configurations
1010
- ...
1111

1212
## Developing Plugins

0 commit comments

Comments
 (0)