Skip to content

Commit 40667c5

Browse files
authored
docs: enhance entry exclusion in bundleless mode (#789)
1 parent 4b1e0a4 commit 40667c5

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default {
5555
};
5656
```
5757

58-
You can also use with an exclamation mark to exclude some files.
58+
You can also use with an exclamation mark to exclude some files. For example, exclude test files within the `src` folder:
5959

6060
```ts title="rslib.config.ts"
6161
export default {
@@ -67,12 +67,28 @@ export default {
6767
],
6868
source: {
6969
entry: {
70-
index: ['./src/**', '!**/foo.*'],
70+
index: ['./src/**', '!src/**/*.test.ts'],
7171
},
7272
},
7373
};
7474
```
7575

76+
::: note
77+
78+
If [DTS generation](/config/lib/dts) is enabled, remember to set [exclude](https://www.typescriptlang.org/tsconfig/#exclude) field in `tsconfig.json` to avoid generating TypeScript declaration files for the corresponding files.
79+
80+
For example, exclude test files within the `src` folder:
81+
82+
```json
83+
// tsconfig.json
84+
{
85+
"include": ["src"],
86+
"exclude": ["src/**/*.test.ts"]
87+
}
88+
```
89+
90+
:::
91+
7692
## Example
7793

7894
For below file structure of source code:

website/docs/zh/config/lib/bundle.mdx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export default {
5353
};
5454
```
5555

56-
你也可以使用感叹号来排除一些文件。
56+
你也可以使用感叹号来排除一些文件。例如,排除 `src` 文件夹中的测试文件:
5757

5858
```ts title="rslib.config.ts"
5959
export default {
@@ -65,12 +65,28 @@ export default {
6565
],
6666
source: {
6767
entry: {
68-
index: ['./src/**', '!**/foo.*'],
68+
index: ['./src/**', '!src/**/*.test.ts'],
6969
},
7070
},
7171
};
7272
```
7373

74+
::: note
75+
76+
当开启 [类型生成](/config/lib/dts) 时,记得在 `tsconfig.json` 中设置 [exclude](https://www.typescriptlang.org/tsconfig/#exclude) 字段,以避免相应的文件生成 TypeScript 类型声明文件。
77+
78+
例如,排除 `src` 文件夹中的测试文件:
79+
80+
```json
81+
// tsconfig.json
82+
{
83+
"include": ["src"],
84+
"exclude": ["src/**/*.test.ts"]
85+
}
86+
```
87+
88+
:::
89+
7490
## Example
7591

7692
对于以下的源代码文件结构:

0 commit comments

Comments
 (0)