Skip to content

Commit

Permalink
chore: add test and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
2heal1 committed Jul 10, 2024
1 parent 473687c commit 83c9037
Show file tree
Hide file tree
Showing 16 changed files with 222 additions and 209 deletions.
20 changes: 10 additions & 10 deletions apps/website-new/docs/en/plugin/plugins/auto-preload.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Helps auto preload assets when load remote.

## Usage

This Runtime Plugin is Provided by the `@module-federation/node` package
This Runtime Plugin is Provided by the `@module-federation/auto-preload` package

<PackageManagerTabs
command={{
npm: 'npm add @module-federation/enhanced @module-federation/node --save',
yarn: 'yarn add @module-federation/enhanced @module-federation/node --save',
pnpm: 'pnpm add @module-federation/enhanced @module-federation/node --save',
bun: 'bun add @module-federation/enhanced @module-federation/node --save',
npm: 'npm add @module-federation/auto-preload --save',
yarn: 'yarn add @module-federation/auto-preload --save',
pnpm: 'pnpm add @module-federation/auto-preload --save',
bun: 'bun add @module-federation/auto-preload --save',
}}
/>

Expand All @@ -29,7 +29,7 @@ The runtime plugin can be applied at compile-time or runtime
new ModuleFederationPlugin({
// other options
runtimePlugins: [
require.resolve('@module-federation/node/runtimePlugin')
require.resolve('@module-federation/auto-preload')
]
});
```
Expand All @@ -41,15 +41,15 @@ The runtime plugin can be applied at compile-time or runtime
new ModuleFederationPlugin({
// other options
runtimePlugins: [
require.resolve('@module-federation/node/runtimePlugin')
require.resolve('@module-federation/auto-preload')
]
});
```
</Tab>
<Tab label="Module Federation Runtime">
```typescript title="app.js"
import {init} from '@module-federation/runtime';
import nodeRuntimePlugin from '@module-federation/node/runtimePlugin';
import { init } from '@module-federation/runtime';
import autoPreloadPlugin from '@module-federation/auto-preload';
init({
name: '@demo/app-main',
remotes: [
Expand All @@ -59,7 +59,7 @@ The runtime plugin can be applied at compile-time or runtime
alias: 'app2',
},
],
plugins: [nodeRuntimePlugin()],
plugins: [autoPreloadPlugin()],
});
```
</Tab>
Expand Down
2 changes: 1 addition & 1 deletion apps/website-new/docs/en/plugin/plugins/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Module Federation on the server-side enables many possibilities for backend arch

## Usage

This Runtime Plugin is Provided by the `module-federation/node` package
This Runtime Plugin is Provided by the `@module-federation/node` package

<PackageManagerTabs
command={{
Expand Down
5 changes: 5 additions & 0 deletions apps/website-new/docs/zh/plugin/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"type": "dir",
"name": "dev",
"label": "插件开发"
},
{
"type": "dir",
"name": "plugins",
"label": "Plugins"
}
]
1 change: 1 addition & 0 deletions apps/website-new/docs/zh/plugin/plugins/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["index","auto-preload"]
67 changes: 67 additions & 0 deletions apps/website-new/docs/zh/plugin/plugins/auto-preload.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { PackageManagerTabs, Tabs, Tab } from '@theme';

# Auto Preload Plugin

当加载远程模块时,会自动预加载相应的远程模块资源。

## Usage

该运行时插件由 `@module-federation/auto-preload` 提供

<PackageManagerTabs
command={{
npm: 'npm add @module-federation/auto-preload --save',
yarn: 'yarn add @module-federation/auto-preload --save',
pnpm: 'pnpm add @module-federation/auto-preload --save',
bun: 'bun add @module-federation/auto-preload --save',
}}
/>


### 配置

此插件可在**运行时阶段****构建插件**中应用。你可以根据你的场景灵活选择。

<Tabs>
<Tab label="Rspack">
```typescript title="rspack.config.js"
const {ModuleFederationPlugin} = require('@module-federation/enhanced/rspack');

new ModuleFederationPlugin({
// other options
runtimePlugins: [
require.resolve('@module-federation/auto-preload')
]
});
```
</Tab>
<Tab label="Webpack">
```typescript title="webpack.config.js"
const {ModuleFederationPlugin} = require('@module-federation/enhanced/webpack');

new ModuleFederationPlugin({
// other options
runtimePlugins: [
require.resolve('@module-federation/auto-preload')
]
});
```
</Tab>
<Tab label="Module Federation Runtime">
```typescript title="app.js"
import { init } from '@module-federation/runtime';
import autoPreloadPlugin from '@module-federation/auto-preload';
init({
name: '@demo/app-main',
remotes: [
{
name: '@demo/app2',
entry: 'http: //localhost:3006/mf-manifest.json',
alias: 'app2',
},
],
plugins: [autoPreloadPlugin()],
});
```
</Tab>
</Tabs>
68 changes: 68 additions & 0 deletions apps/website-new/docs/zh/plugin/plugins/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { PackageManagerTabs, Tabs, Tab } from '@theme';

# Node Plugin


服务器端的模块联邦为后端架构提供了多种可能性,并支持应用程序的服务器端渲染。

## 使用

该运行时插件由 `@module-federation/node` 提供

<PackageManagerTabs
command={{
npm: 'npm add @module-federation/enhanced @module-federation/node --save',
yarn: 'yarn add @module-federation/enhanced @module-federation/node --save',
pnpm: 'pnpm add @module-federation/enhanced @module-federation/node --save',
bun: 'bun add @module-federation/enhanced @module-federation/node --save',
}}
/>


### 配置

此插件可在**运行时阶段****构建插件**中应用。你可以根据你的场景灵活选择。

<Tabs>
<Tab label="Rspack">
```typescript title="rspack.config.js"
const {ModuleFederationPlugin} = require('@module-federation/enhanced/rspack');

new ModuleFederationPlugin({
// other options
runtimePlugins: [
require.resolve('@module-federation/node/runtimePlugin')
]
});
```
</Tab>
<Tab label="Webpack">
```typescript title="webpack.config.js"
const {ModuleFederationPlugin} = require('@module-federation/enhanced/webpack');

new ModuleFederationPlugin({
// other options
runtimePlugins: [
require.resolve('@module-federation/node/runtimePlugin')
]
});
```
</Tab>
<Tab label="Module Federation Runtime">
```typescript title="app.js"
import {init} from '@module-federation/runtime';
import nodeRuntimePlugin from '@module-federation/node/runtimePlugin';
init({
name: '@demo/app-main',
remotes: [
{
name: '@demo/app2',
entry: 'http: //localhost:3006/mf-manifest.json',
alias: 'app2',
},
],
plugins: [nodeRuntimePlugin()],
});
```
</Tab>
</Tabs>
Loading

0 comments on commit 83c9037

Please sign in to comment.