Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion packages/core/src/types/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,78 @@ export type Redirect = {
};

export interface LibConfig extends RsbuildConfig {
/**
* Whether to bundle the library.
* @default true
*/
bundle?: boolean;
/**
* Output format for the generated JavaScript files.
* @default undefined
*/
format?: Format;
/**
* Whether to automatically set the file extension based on the `format` option in the JS and DTS output files.
* @default true
*/
autoExtension?: boolean;
/**
* Whether to automatically externalize dependencies and do not bundle them.
* @default true
*/
autoExternal?: AutoExternal;
/**
* Configure the redirect of the import paths.
* @default {}
*/
redirect?: Redirect;
/** Support esX and browserslist query */
/**
* Support esX and browserslist query
* @default 'esnext'
*/
syntax?: Syntax;
/**
* Whether to import SWC helper functions from `@swc/helpers` instead of inlining them.
* @default false
*/
externalHelpers?: boolean;
/**
* Inject content into the top of each JS, CSS or DTS file.
* @default {}
*/
banner?: BannerAndFooter;
/**
* Inject content into the bottom of each JS, CSS or DTS file.
* @default {}
*/
footer?: BannerAndFooter;
/**
* Configure the shims for CommonJS and ESM output.
*
* @default
* ```js
* const defaultShims = {
* cjs: {
* 'import.meta.url': true,
* },
* esm: {
* __filename: false,
* __dirname: false,
* require: false,
* },
* };
* ```
*/
shims?: Shims;
/**
* Configure the generation of the TypeScript declaration files.
* @default false
*/
dts?: Dts;
/**
* The export name of the UMD bundle.
* @default undefined
*/
umdName?: string;
}

Expand Down
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/auto-extension.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- **Type:** `boolean`
- **Default:** `true`

Whether to automatically set the file extension based on the `format` option in the JS and DTS output files.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/auto-external.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- **Type:** `boolean`
- **Default:** `true`

Whether to automatically externalize dependencies and do not bundle them.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/banner.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ type Banner = {
```

- **Default:** `{}`

Inject content into the top of each JS, CSS or DTS file.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/bundle.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- **Type:** `boolean`
- **Default:** `true`

Whether to bundle the library.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/dts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ type Dts =
```

- **Default:** `undefined`

Configure the generation of the TypeScript declaration files.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/external-helpers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- **Type:** `boolean`
- **Default:** `false`

Whether to import SWC helper functions from `@swc/helpers` instead of inlining them.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/footer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ type Footer = {
```

- **Default:** `{}`

Inject content into the bottom of each JS, CSS or DTS file.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/format.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- **Type:** `string`
- **Default:** `undefined`

Output format for the generated JavaScript files.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/redirect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ type Redirect = {
```

- **Default:** `{}`

Configure the redirect of the import paths.
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ type EcmaScriptVersion =

type Syntax = EcmaScriptVersion | string[];
```

- **Default:** `'esnext'`
2 changes: 2 additions & 0 deletions website/docs/en/config/lib/umd-name.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@

- **Type:** `string`
- **Default:** `undefined`

The export name of the UMD bundle.
Loading