Skip to content

Commit 103902b

Browse files
authored
docs: add basic description and JSDoc for lib options (#372)
1 parent 406396d commit 103902b

File tree

12 files changed

+83
-1
lines changed

12 files changed

+83
-1
lines changed

packages/core/src/types/config/index.ts

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,78 @@ export type Redirect = {
7272
};
7373

7474
export interface LibConfig extends RsbuildConfig {
75+
/**
76+
* Whether to bundle the library.
77+
* @default true
78+
*/
7579
bundle?: boolean;
80+
/**
81+
* Output format for the generated JavaScript files.
82+
* @default undefined
83+
*/
7684
format?: Format;
85+
/**
86+
* Whether to automatically set the file extension based on the `format` option in the JS and DTS output files.
87+
* @default true
88+
*/
7789
autoExtension?: boolean;
90+
/**
91+
* Whether to automatically externalize dependencies and do not bundle them.
92+
* @default true
93+
*/
7894
autoExternal?: AutoExternal;
95+
/**
96+
* Configure the redirect of the import paths.
97+
* @default {}
98+
*/
7999
redirect?: Redirect;
80-
/** Support esX and browserslist query */
100+
/**
101+
* Support esX and browserslist query
102+
* @default 'esnext'
103+
*/
81104
syntax?: Syntax;
105+
/**
106+
* Whether to import SWC helper functions from `@swc/helpers` instead of inlining them.
107+
* @default false
108+
*/
82109
externalHelpers?: boolean;
110+
/**
111+
* Inject content into the top of each JS, CSS or DTS file.
112+
* @default {}
113+
*/
83114
banner?: BannerAndFooter;
115+
/**
116+
* Inject content into the bottom of each JS, CSS or DTS file.
117+
* @default {}
118+
*/
84119
footer?: BannerAndFooter;
120+
/**
121+
* Configure the shims for CommonJS and ESM output.
122+
*
123+
* @default
124+
* ```js
125+
* const defaultShims = {
126+
* cjs: {
127+
* 'import.meta.url': true,
128+
* },
129+
* esm: {
130+
* __filename: false,
131+
* __dirname: false,
132+
* require: false,
133+
* },
134+
* };
135+
* ```
136+
*/
85137
shims?: Shims;
138+
/**
139+
* Configure the generation of the TypeScript declaration files.
140+
* @default false
141+
*/
86142
dts?: Dts;
143+
/**
144+
* The export name of the UMD bundle.
145+
* @default undefined
146+
*/
87147
umdName?: string;
88148
}
89149

website/docs/en/config/lib/auto-extension.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
- **Type:** `boolean`
44
- **Default:** `true`
5+
6+
Whether to automatically set the file extension based on the `format` option in the JS and DTS output files.

website/docs/en/config/lib/auto-external.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
- **Type:** `boolean`
44
- **Default:** `true`
5+
6+
Whether to automatically externalize dependencies and do not bundle them.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ type Banner = {
1111
```
1212

1313
- **Default:** `{}`
14+
15+
Inject content into the top of each JS, CSS or DTS file.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
- **Type:** `boolean`
44
- **Default:** `true`
5+
6+
Whether to bundle the library.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ type Dts =
1515
```
1616

1717
- **Default:** `undefined`
18+
19+
Configure the generation of the TypeScript declaration files.

website/docs/en/config/lib/external-helpers.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
- **Type:** `boolean`
44
- **Default:** `false`
5+
6+
Whether to import SWC helper functions from `@swc/helpers` instead of inlining them.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ type Footer = {
1111
```
1212

1313
- **Default:** `{}`
14+
15+
Inject content into the bottom of each JS, CSS or DTS file.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
- **Type:** `string`
44
- **Default:** `undefined`
5+
6+
Output format for the generated JavaScript files.

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ type Redirect = {
99
```
1010

1111
- **Default:** `{}`
12+
13+
Configure the redirect of the import paths.

0 commit comments

Comments
 (0)