Skip to content

Commit

Permalink
chore: update
Browse files Browse the repository at this point in the history
  • Loading branch information
Timeless0911 committed Dec 22, 2024
1 parent a735c83 commit 23130d5
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 40 deletions.
12 changes: 6 additions & 6 deletions packages/core/src/cli/mf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export async function startMFDevServer(
}

async function initMFRsbuild(
rslibConfig: RslibConfig,
config: RslibConfig,
options: Pick<CommonOptions, 'lib'> = {},
): Promise<RsbuildInstance | undefined> {
const { environments, environmentWithInfos } =
await composeRsbuildEnvironments(rslibConfig);
await composeRsbuildEnvironments(config);

const selectedEnvironmentIds = environmentWithInfos
.filter((env) => {
Expand All @@ -42,13 +42,13 @@ async function initMFRsbuild(
const rsbuildInstance = await createRsbuild({
rsbuildConfig: {
mode: 'development',
root: rslibConfig.root,
plugins: rslibConfig.plugins,
root: config.root,
plugins: config.plugins,
dev: {
...(rslibConfig.dev ?? {}),
...(config.dev ?? {}),
writeToDisk: true,
},
server: rslibConfig.server,
server: config.server,
tools: {
rspack: {
optimization: {
Expand Down
10 changes: 3 additions & 7 deletions packages/plugin-dts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { type ChildProcess, fork } from 'node:child_process';
import { dirname, extname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import {
type EnvironmentConfig,
type RsbuildPlugin,
logger,
} from '@rsbuild/core';
import { type RsbuildConfig, type RsbuildPlugin, logger } from '@rsbuild/core';
import ts from 'typescript';
import { loadTsconfig, processSourceEntry } from './utils';

Expand Down Expand Up @@ -43,8 +39,8 @@ export type DtsGenOptions = PluginDtsOptions & {
tsconfigPath: string;
tsConfigResult: ts.ParsedCommandLine;
rootDistPath: string;
cleanDistPath: NonNullable<EnvironmentConfig['output']>['cleanDistPath'];
userExternals?: NonNullable<EnvironmentConfig['output']>['externals'];
cleanDistPath: NonNullable<RsbuildConfig['output']>['cleanDistPath'];
userExternals?: NonNullable<RsbuildConfig['output']>['externals'];
};

interface TaskResult {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-dts/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from 'node:fs';
import fsP from 'node:fs/promises';
import { platform } from 'node:os';
import path, { basename, dirname, join, relative, resolve } from 'node:path';
import { type EnvironmentConfig, logger } from '@rsbuild/core';
import { type RsbuildConfig, logger } from '@rsbuild/core';
import MagicString from 'magic-string';
import color from 'picocolors';
import { convertPathToPattern, glob } from 'tinyglobby';
Expand Down Expand Up @@ -167,7 +167,7 @@ export async function processDtsFiles(

export function processSourceEntry(
bundle: boolean,
entryConfig: NonNullable<EnvironmentConfig['source']>['entry'],
entryConfig: NonNullable<RsbuildConfig['source']>['entry'],
): DtsEntry {
if (!bundle) {
return {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/config/lib/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- **Type:**

```ts
interface LibConfig extends RsbuildConfig {
interface LibConfig extends EnvironmentConfig {
format?: Format;
bundle?: boolean;
autoExtension?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions website/docs/en/guide/advanced/module-federation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ However, if you want this Rslib Module to consume other producers at the same ti

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

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

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

```json title="package.json"
{
"scripts": {
"dev": "rslib mf dev"
"dev": "rslib mf-dev"
}
}
```
Expand Down Expand Up @@ -152,14 +152,14 @@ Then start the host app with `rsbuild dev`.

Rslib support developing Module Federation Rslib project with Storybook.

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

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

```json title="package.json"
{
"scripts": {
"dev": "rslib mf dev"
"dev": "rslib mf-dev"
}
}
```
Expand Down
21 changes: 11 additions & 10 deletions website/docs/en/guide/basic/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ The output is shown below:
Usage: rslib <command> [options]
Options:
-V, --version output the version number
-h, --help display help for command
-V, --version output the version number
-h, --help display help for command
Commands:
build [options] build the library for production
inspect [options] inspect the Rsbuild / Rspack configs of Rslib projects
mf [options] <dev> start Rsbuild dev server of Module Federation format
help [command] display help for command
build [options] build the library for production
inspect [options] inspect the Rsbuild / Rspack configs of Rslib projects
mf-dev [options] start Rsbuild dev server of Module Federation format
help [command] display help for command
```

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

## rslib mf dev
## rslib mf-dev

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

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

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

Expand Down
29 changes: 29 additions & 0 deletions website/docs/zh/config/lib/index.mdx
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
# Lib 配置

- **类型:**

```ts
interface LibConfig extends EnvironmentConfig {
format?: Format;
bundle?: boolean;
autoExtension?: boolean;
autoExternal?: AutoExternal;
redirect?: Redirect;
syntax?: Syntax;
externalHelpers?: boolean;
banner?: BannerAndFooter;
footer?: BannerAndFooter;
shims?: Shims;
dts?: Dts;
umdName?: string;
}

interface RslibConfig extends RsbuildConfig {
lib: LibConfig[];
}
```

- **默认值:** `undefined`

- **必选:** `true`

`lib` 配置是一个对象数组,每个对象代表一组不同的配置。这些配置包括所有 Rsbuild 配置以及 Rslib 特定的配置,可以生成不同格式的产物。
8 changes: 4 additions & 4 deletions website/docs/zh/guide/advanced/module-federation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ export default defineConfig({

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

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

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

```json title="package.json"
{
"scripts": {
"dev": "rslib mf dev"
"dev": "rslib mf-dev"
}
}
```
Expand Down Expand Up @@ -151,14 +151,14 @@ export default defineConfig({

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

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

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

```json title="package.json"
{
"scripts": {
"dev": "rslib mf dev"
"dev": "rslib mf-dev"
}
}
```
Expand Down
13 changes: 7 additions & 6 deletions website/docs/zh/guide/basic/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Options:
Commands:
build [options] 构建用于生产环境的产物
inspect [options] 检查 Rslib 项目的 Rsbuild 配置和 Rspack 配置
mf [options] <dev> 为 Module Federation 格式的库启用 Rsbuild 开发服务器。
mf-dev [options] 为 Module Federation 格式的库启用 Rsbuild 开发服务器。
help [command] 显示命令帮助
```

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

## rslib mf dev
## rslib mf-dev

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

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

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

Expand Down

0 comments on commit 23130d5

Please sign in to comment.