Skip to content

Commit e6282bf

Browse files
authored
docs: add documentation for more resolve options (#1392)
1 parent c130a93 commit e6282bf

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

website/docs/en/config/rsbuild/resolve.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Options for module resolution.
66

77
## resolve.aliasStrategy <RsbuildDocBadge path="/config/resolve/alias-strategy" text="resolve.aliasStrategy" />
88

9-
Control the priority between the `resolve.alias` option and the `paths` option in `tsconfig.json`.
9+
Set the strategy for path alias resolution, to control the priority relationship between the paths option in `tsconfig.json` and the [resolve.alias](/config/rsbuild/resolve#resolvealias) option.
1010

1111
## resolve.alias <RsbuildDocBadge path="/config/resolve/alias" text="resolve.alias" />
1212

@@ -52,13 +52,21 @@ It is worth noting that in bundle mode, both `resolve.alias` and [output.externa
5252
Now, the code `import { useState } from 'react'` will be replaced with `import { useState } from 'preact/compat'`.
5353

5454
::: note
55-
In bundleless mode, since there is no bundling concept, all modules will be externalized. Rslib will automatically transform the modules resolved to the [outBase](../lib/out-base) directory based on the mappings configured in `resolve.alias` or [compilerOptions.paths](https://www.typescriptlang.org/tsconfig/#paths) in `tsconfig.json`.
55+
In bundleless mode, since there is no bundling concept, all modules will be externalized. Rslib will automatically transform the modules resolved to the [outBase](/config/lib/out-base) directory based on the mappings configured in `resolve.alias` or [compilerOptions.paths](https://www.typescriptlang.org/tsconfig/#paths) in `tsconfig.json`.
5656
:::
5757

58+
## resolve.conditionNames <RsbuildDocBadge path="/config/resolve/condition-names" text="resolve.conditionNames" />
59+
60+
Specifies the condition names used to match entry points in the [exports field](https://nodejs.org/api/packages.html#packages_exports) of a package.
61+
5862
## resolve.dedupe <RsbuildDocBadge path="/config/resolve/dedupe" text="resolve.dedupe" />
5963

6064
Force Rsbuild to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size.
6165

6266
## resolve.extensions <RsbuildDocBadge path="/config/resolve/extensions" text="resolve.extensions" />
6367

6468
Automatically resolve file extensions when importing modules. This means you can import files without explicitly writing their extensions.
69+
70+
## resolve.mainFields <RsbuildDocBadge path="/config/resolve/main-fields" text="resolve.mainFields" />
71+
72+
Controls the priority of fields in a package.json used to locate a package's entry file. It is the ordered list of package.json fields Rspack will try when resolving an npm package's entry point.

website/docs/zh/config/rsbuild/resolve.mdx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { RsbuildDocBadge } from '@components/RsbuildDocBadge';
66

77
## resolve.aliasStrategy <RsbuildDocBadge path="/config/resolve/alias-strategy" text="resolve.aliasStrategy" />
88

9-
控制 `resolve.alias` 选项与 `tsconfig.json` 中的 `paths` 选项的优先级
9+
设置路径别名解析的策略,用于控制 `tsconfig.json` 中的 `paths` 选项与 [resolve.alias](/config/rsbuild/resolve#resolvealias) 选项之间的优先级关系
1010

1111
## resolve.alias <RsbuildDocBadge path="/config/resolve/alias" text="resolve.alias" />
1212

@@ -52,13 +52,21 @@ import { RsbuildDocBadge } from '@components/RsbuildDocBadge';
5252
此时,代码 `import { useState } from 'react'` 将被替换为 `import { useState } from 'preact/compat'`
5353

5454
::: note
55-
在 bundleless 模式下,由于没有打包这个概念,所有模块都会被外部化,Rslib 会自动根据 `resolve.alias``tsconfig.json`[compilerOptions.paths](https://www.typescriptlang.org/tsconfig/#paths) 配置的映射关系,对最终解析到 [outBase](../lib/out-base) 目录下的模块进行转换。
55+
在 bundleless 模式下,由于没有打包这个概念,所有模块都会被外部化,Rslib 会自动根据 `resolve.alias``tsconfig.json`[compilerOptions.paths](https://www.typescriptlang.org/tsconfig/#paths) 配置的映射关系,对最终解析到 [outBase](/config/lib/out-base) 目录下的模块进行转换。
5656
:::
5757

58+
## resolve.conditionNames <RsbuildDocBadge path="/config/resolve/condition-names" text="resolve.conditionNames" />
59+
60+
指定用于匹配包 [exports 字段](https://nodejs.org/api/packages.html#packages_exports) 入口点的 condition names(条件名称)。
61+
5862
## resolve.dedupe <RsbuildDocBadge path="/config/resolve/dedupe" text="resolve.dedupe" />
5963

6064
强制 Rsbuild 从项目根目录解析指定的包,这可以用于移除重复包和减少包大小。
6165

6266
## resolve.extensions <RsbuildDocBadge path="/config/resolve/extensions" text="resolve.extensions" />
6367

6468
自动添加导入文件的扩展名。这意味着你可以导入文件,而不需要显式地写它们的扩展名。
69+
70+
## resolve.mainFields <RsbuildDocBadge path="/config/resolve/main-fields" text="resolve.mainFields" />
71+
72+
控制用于定位包入口文件的 package.json 字段优先级。Rspack 在解析 npm 包入口时,会按该列表的顺序依次尝试这些字段。

0 commit comments

Comments
 (0)