From e2186c573adb348aa6c8953ad0af35db9938225f Mon Sep 17 00:00:00 2001 From: Timeless0911 <1604889533@qq.com> Date: Mon, 24 Feb 2025 19:09:14 +0800 Subject: [PATCH 1/3] docs: enhance entry exclude in bundleless mode --- website/docs/en/config/lib/bundle.mdx | 14 ++++++++++++++ website/docs/zh/config/lib/bundle.mdx | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/website/docs/en/config/lib/bundle.mdx b/website/docs/en/config/lib/bundle.mdx index 5705badf0..f19a21959 100644 --- a/website/docs/en/config/lib/bundle.mdx +++ b/website/docs/en/config/lib/bundle.mdx @@ -73,6 +73,20 @@ export default { }; ``` +::: note + +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. + +```json +// tsconfig.json +{ + "include": ["src"], + "exclude": ["src/**/foo.*"] +} +``` + +::: + ## Example For below file structure of source code: diff --git a/website/docs/zh/config/lib/bundle.mdx b/website/docs/zh/config/lib/bundle.mdx index 241535a40..e85101f4d 100644 --- a/website/docs/zh/config/lib/bundle.mdx +++ b/website/docs/zh/config/lib/bundle.mdx @@ -71,6 +71,20 @@ export default { }; ``` +::: note + +当开启 [类型生成](/config/lib/dts) 时,记得在 `tsconfig.json` 中设置 [exclude](https://www.typescriptlang.org/tsconfig/#exclude) 字段,以避免相应的文件生成 TypeScript 类型声明文件。 + +```json +// tsconfig.json +{ + "include": ["src"], + "exclude": ["src/**/foo.*"] +} +``` + +::: + ## Example 对于以下的源代码文件结构: From 5d607b8b84c5b89bf468e362e7af4b1038ff326b Mon Sep 17 00:00:00 2001 From: Timeless0911 <1604889533@qq.com> Date: Mon, 24 Feb 2025 19:21:28 +0800 Subject: [PATCH 2/3] chore: update --- website/docs/en/config/lib/bundle.mdx | 4 ++-- website/docs/zh/config/lib/bundle.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/website/docs/en/config/lib/bundle.mdx b/website/docs/en/config/lib/bundle.mdx index f19a21959..29e90e1c4 100644 --- a/website/docs/en/config/lib/bundle.mdx +++ b/website/docs/en/config/lib/bundle.mdx @@ -67,7 +67,7 @@ export default { ], source: { entry: { - index: ['./src/**', '!**/foo.*'], + index: ['./src/**', '!src/**/*.test.ts'], }, }, }; @@ -81,7 +81,7 @@ If [DTS generation](/config/lib/dts) is enabled, remember to set [exclude](https // tsconfig.json { "include": ["src"], - "exclude": ["src/**/foo.*"] + "exclude": ["src/**/*.test.ts"] } ``` diff --git a/website/docs/zh/config/lib/bundle.mdx b/website/docs/zh/config/lib/bundle.mdx index e85101f4d..77da6bf57 100644 --- a/website/docs/zh/config/lib/bundle.mdx +++ b/website/docs/zh/config/lib/bundle.mdx @@ -65,7 +65,7 @@ export default { ], source: { entry: { - index: ['./src/**', '!**/foo.*'], + index: ['./src/**', '!src/**/*.test.ts'], }, }, }; @@ -79,7 +79,7 @@ export default { // tsconfig.json { "include": ["src"], - "exclude": ["src/**/foo.*"] + "exclude": ["src/**/*.test.ts"] } ``` From fa8c4da4b97d36f2a55491628fb0e3c088b15c9d Mon Sep 17 00:00:00 2001 From: Timeless0911 <1604889533@qq.com> Date: Mon, 24 Feb 2025 19:23:53 +0800 Subject: [PATCH 3/3] chore: update --- website/docs/en/config/lib/bundle.mdx | 4 +++- website/docs/zh/config/lib/bundle.mdx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/website/docs/en/config/lib/bundle.mdx b/website/docs/en/config/lib/bundle.mdx index 29e90e1c4..d66680f92 100644 --- a/website/docs/en/config/lib/bundle.mdx +++ b/website/docs/en/config/lib/bundle.mdx @@ -55,7 +55,7 @@ export default { }; ``` -You can also use with an exclamation mark to exclude some files. +You can also use with an exclamation mark to exclude some files. For example, exclude test files within the `src` folder: ```ts title="rslib.config.ts" export default { @@ -77,6 +77,8 @@ export default { 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. +For example, exclude test files within the `src` folder: + ```json // tsconfig.json { diff --git a/website/docs/zh/config/lib/bundle.mdx b/website/docs/zh/config/lib/bundle.mdx index 77da6bf57..21f678bf3 100644 --- a/website/docs/zh/config/lib/bundle.mdx +++ b/website/docs/zh/config/lib/bundle.mdx @@ -53,7 +53,7 @@ export default { }; ``` -你也可以使用感叹号来排除一些文件。 +你也可以使用感叹号来排除一些文件。例如,排除 `src` 文件夹中的测试文件: ```ts title="rslib.config.ts" export default { @@ -75,6 +75,8 @@ export default { 当开启 [类型生成](/config/lib/dts) 时,记得在 `tsconfig.json` 中设置 [exclude](https://www.typescriptlang.org/tsconfig/#exclude) 字段,以避免相应的文件生成 TypeScript 类型声明文件。 +例如,排除 `src` 文件夹中的测试文件: + ```json // tsconfig.json {