Skip to content

Commit ee16ba9

Browse files
committed
chore: update
1 parent 3c17d7c commit ee16ba9

File tree

9 files changed

+67
-40
lines changed

9 files changed

+67
-40
lines changed

packages/core/src/cli/mf.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ export async function startMFDevServer(
1414
}
1515

1616
async function initMFRsbuild(
17-
rslibConfig: RslibConfig,
17+
config: RslibConfig,
1818
options: Pick<CommonOptions, 'lib'> = {},
1919
): Promise<RsbuildInstance | undefined> {
2020
const { environments, environmentWithInfos } =
21-
await composeRsbuildEnvironments(rslibConfig);
21+
await composeRsbuildEnvironments(config);
2222

2323
const selectedEnvironmentIds = environmentWithInfos
2424
.filter((env) => {
@@ -42,13 +42,13 @@ async function initMFRsbuild(
4242
const rsbuildInstance = await createRsbuild({
4343
rsbuildConfig: {
4444
mode: 'development',
45-
root: rslibConfig.root,
46-
plugins: rslibConfig.plugins,
45+
root: config.root,
46+
plugins: config.plugins,
4747
dev: {
48-
...(rslibConfig.dev ?? {}),
48+
...(config.dev ?? {}),
4949
writeToDisk: true,
5050
},
51-
server: rslibConfig.server,
51+
server: config.server,
5252
tools: {
5353
rspack: {
5454
optimization: {

packages/plugin-dts/src/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
import { type ChildProcess, fork } from 'node:child_process';
22
import { dirname, extname, join } from 'node:path';
33
import { fileURLToPath } from 'node:url';
4-
import {
5-
type EnvironmentConfig,
6-
type RsbuildPlugin,
7-
logger,
8-
} from '@rsbuild/core';
4+
import { type RsbuildConfig, type RsbuildPlugin, logger } from '@rsbuild/core';
95
import ts from 'typescript';
106
import { loadTsconfig, processSourceEntry } from './utils';
117

@@ -43,8 +39,8 @@ export type DtsGenOptions = PluginDtsOptions & {
4339
tsconfigPath: string;
4440
tsConfigResult: ts.ParsedCommandLine;
4541
rootDistPath: string;
46-
cleanDistPath: NonNullable<EnvironmentConfig['output']>['cleanDistPath'];
47-
userExternals?: NonNullable<EnvironmentConfig['output']>['externals'];
42+
cleanDistPath: NonNullable<RsbuildConfig['output']>['cleanDistPath'];
43+
userExternals?: NonNullable<RsbuildConfig['output']>['externals'];
4844
};
4945

5046
interface TaskResult {

packages/plugin-dts/src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from 'node:fs';
22
import fsP from 'node:fs/promises';
33
import { platform } from 'node:os';
44
import path, { basename, dirname, join, relative, resolve } from 'node:path';
5-
import { type EnvironmentConfig, logger } from '@rsbuild/core';
5+
import { type RsbuildConfig, logger } from '@rsbuild/core';
66
import MagicString from 'magic-string';
77
import color from 'picocolors';
88
import { convertPathToPattern, glob } from 'tinyglobby';
@@ -167,7 +167,7 @@ export async function processDtsFiles(
167167

168168
export function processSourceEntry(
169169
bundle: boolean,
170-
entryConfig: NonNullable<EnvironmentConfig['source']>['entry'],
170+
entryConfig: NonNullable<RsbuildConfig['source']>['entry'],
171171
): DtsEntry {
172172
if (!bundle) {
173173
return {

website/docs/en/config/lib/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
- **Type:**
44

55
```ts
6-
interface LibConfig extends RsbuildConfig {
6+
interface LibConfig extends EnvironmentConfig {
77
format?: Format;
88
bundle?: boolean;
99
autoExtension?: boolean;

website/docs/en/guide/advanced/module-federation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ However, if you want this Rslib Module to consume other producers at the same ti
9494

9595
Rslib support developing Module Federation Rslib project with a host application.
9696

97-
#### 1. Start `rslib mf dev` command of library
97+
#### 1. Start `rslib mf-dev` command of library
9898

9999
Adding the `dev` command to the `package.json` file:
100100

101101
```json title="package.json"
102102
{
103103
"scripts": {
104-
"dev": "rslib mf dev"
104+
"dev": "rslib mf-dev"
105105
}
106106
}
107107
```
@@ -152,14 +152,14 @@ Then start the host app with `rsbuild dev`.
152152

153153
Rslib support developing Module Federation Rslib project with Storybook.
154154

155-
#### 1. Start `rslib mf dev` command of library
155+
#### 1. Start `rslib mf-dev` command of library
156156

157157
Adding the `dev` command to the `package.json` file:
158158

159159
```json title="package.json"
160160
{
161161
"scripts": {
162-
"dev": "rslib mf dev"
162+
"dev": "rslib mf-dev"
163163
}
164164
}
165165
```

website/docs/en/guide/basic/cli.mdx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ The output is shown below:
1616
Usage: rslib <command> [options]
1717
1818
Options:
19-
-V, --version output the version number
20-
-h, --help display help for command
19+
-V, --version output the version number
20+
-h, --help display help for command
2121
2222
Commands:
23-
build [options] build the library for production
24-
inspect [options] inspect the Rsbuild / Rspack configs of Rslib projects
25-
mf [options] <dev> start Rsbuild dev server of Module Federation format
26-
help [command] display help for command
23+
build [options] build the library for production
24+
inspect [options] inspect the Rsbuild / Rspack configs of Rslib projects
25+
mf-dev [options] start Rsbuild dev server of Module Federation format
26+
help [command] display help for command
2727
```
2828

2929
## rslib build
@@ -40,7 +40,7 @@ Options:
4040
-r --root <root> specify the project root directory, can be an absolute path or a path relative to cwd
4141
--env-mode <mode> specify the env mode to load the `.env.[mode]` file
4242
--env-dir <dir> specify the directory to load `.env` files
43-
--lib <id> build the specified library (may be repeated)
43+
--lib <id> specify the library (repeatable, e.g. --lib esm --lib cjs)
4444
-w --watch turn on watch mode, watch for changes and rebuild
4545
-h, --help display help for command
4646
```
@@ -149,7 +149,7 @@ Options:
149149
-r --root <root> specify the project root directory, can be an absolute path or a path relative to cwd
150150
--env-mode <mode> specify the env mode to load the `.env.[mode]` file
151151
--env-dir <dir> specify the directory to load `.env` files
152-
--lib <id> inspect the specified library (may be repeated)
152+
--lib <id> specify the library (repeatable, e.g. --lib esm --lib cjs)
153153
--output <output> specify inspect content output path (default: ".rsbuild")
154154
--verbose show full function definitions in output
155155
-h, --help display help for command
@@ -192,9 +192,9 @@ Inspect config succeed, open following files to view the content:
192192
- Rspack Config (cjs): /project/dist/.rsbuild/rspack.config.cjs.mjs
193193
```
194194

195-
## rslib mf dev
195+
## rslib mf-dev
196196

197-
The `rslib mf dev` command is utilized to start Rsbuild dev server for the [Module Federation](/guide/advanced/module-federation) format.
197+
The `rslib mf-dev` command is utilized to start Rsbuild dev server for the [Module Federation](/guide/advanced/module-federation) format.
198198

199199
This enables you to develop and debug your mf format module within the host app.
200200

@@ -208,6 +208,7 @@ Options:
208208
-r --root <root> specify the project root directory, can be an absolute path or a path relative to cwd
209209
--env-mode <mode> specify the env mode to load the `.env.[mode]` file
210210
--env-dir <dir> specify the directory to load `.env` files
211+
--lib <id> specify the library (repeatable, e.g. --lib esm --lib cjs)
211212
-h, --help display help for command
212213
```
213214

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
11
# Lib 配置
2+
3+
- **类型:**
4+
5+
```ts
6+
interface LibConfig extends EnvironmentConfig {
7+
format?: Format;
8+
bundle?: boolean;
9+
autoExtension?: boolean;
10+
autoExternal?: AutoExternal;
11+
redirect?: Redirect;
12+
syntax?: Syntax;
13+
externalHelpers?: boolean;
14+
banner?: BannerAndFooter;
15+
footer?: BannerAndFooter;
16+
shims?: Shims;
17+
dts?: Dts;
18+
umdName?: string;
19+
}
20+
21+
interface RslibConfig extends RsbuildConfig {
22+
lib: LibConfig[];
23+
}
24+
```
25+
26+
- **默认值:** `undefined`
27+
28+
- **必选:** `true`
29+
30+
`lib` 配置是一个对象数组,每个对象代表一组不同的配置。这些配置包括所有 Rsbuild 配置以及 Rslib 特定的配置,可以生成不同格式的产物。

website/docs/zh/guide/advanced/module-federation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ export default defineConfig({
9494

9595
Rslib 支持宿主应用和 Rslib 模块联邦项目同时开发。
9696

97-
#### 1. 启动库的 `rslib mf dev` 命令
97+
#### 1. 启动库的 `rslib mf-dev` 命令
9898

9999
添加 `dev` 命令在 `package.json` 文件:
100100

101101
```json title="package.json"
102102
{
103103
"scripts": {
104-
"dev": "rslib mf dev"
104+
"dev": "rslib mf-dev"
105105
}
106106
}
107107
```
@@ -151,14 +151,14 @@ export default defineConfig({
151151

152152
Rslib 支持使用 Storybook 开发 Rslib 模块联邦项目。
153153

154-
#### 1. 启动库的 `rslib mf dev` 命令
154+
#### 1. 启动库的 `rslib mf-dev` 命令
155155

156156
添加 `dev` 命令在 `package.json` 文件:
157157

158158
```json title="package.json"
159159
{
160160
"scripts": {
161-
"dev": "rslib mf dev"
161+
"dev": "rslib mf-dev"
162162
}
163163
}
164164
```

website/docs/zh/guide/basic/cli.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Options:
2222
Commands:
2323
build [options] 构建用于生产环境的产物
2424
inspect [options] 检查 Rslib 项目的 Rsbuild 配置和 Rspack 配置
25-
mf [options] <dev> 为 Module Federation 格式的库启用 Rsbuild 开发服务器。
25+
mf-dev [options] 为 Module Federation 格式的库启用 Rsbuild 开发服务器。
2626
help [command] 显示命令帮助
2727
```
2828

@@ -40,7 +40,7 @@ Options:
4040
-r --root <root> 指定项目根目录,可以是绝对路径或者相对于 cwd 的路径
4141
--env-mode <mode> 指定 env 模式来加载 `.env.[mode]` 文件
4242
--env-dir <dir> 指定目录来加载 `.env` 文件
43-
--lib <id> 仅构建指定的库(可以重复
43+
--lib <id> 指定库(可重复,例如 --lib esm --lib cjs
4444
-w --watch 开启 watch 模式, 监听文件变更并重新构建
4545
-h, --help 显示命令帮助
4646
```
@@ -149,8 +149,8 @@ Options:
149149
-r --root <root> 指定项目根目录,可以是绝对路径或者相对于 cwd 的路径
150150
--env-mode <mode> 指定 env 模式来加载 `.env.[mode]` 文件
151151
--env-dir <dir> 指定目录来加载 `.env` 文件
152-
--lib <id> 检查指定的库(可以重复
153-
--output <output> 指定检查内容输出路径(默认:".rsbuild")
152+
--lib <id> 指定库(可重复,例如 --lib esm --lib cjs
153+
--output <output> 指定检查内容输出路径(默认:".rsbuild"
154154
--verbose 在输出中显示完整的函数定义
155155
-h, --help 显示命令帮助
156156
```
@@ -192,9 +192,9 @@ Inspect config succeed, open following files to view the content:
192192
- Rspack Config (cjs): /project/dist/.rsbuild/rspack.config.cjs.mjs
193193
```
194194

195-
## rslib mf dev
195+
## rslib mf-dev
196196

197-
`rslib mf dev` 命令用于为 [Module Federation](/guide/advanced/module-federation) 格式的库启用 Rsbuild 开发服务器。
197+
`rslib mf-dev` 命令用于为 [Module Federation](/guide/advanced/module-federation) 格式的库启用 Rsbuild 开发服务器。
198198

199199
这允许你在 host 应用中访问和调试 mf 格式的模块。
200200

@@ -208,6 +208,7 @@ Options:
208208
-r --root <root> 指定项目根目录,可以是绝对路径或者相对于 cwd 的路径
209209
--env-mode <mode> 指定 env 模式来加载 `.env.[mode]` 文件
210210
--env-dir <dir> 指定目录来加载 `.env` 文件
211+
--lib <id> 指定库(可重复,例如 --lib esm --lib cjs)
211212
-h, --help 显示命令帮助
212213
```
213214

0 commit comments

Comments
 (0)