Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
107 changes: 106 additions & 1 deletion website/docs/en/config/lib/auto-external.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,111 @@
# lib.autoExternal

- **Type:** `boolean`
- **Type:**

```ts
type AutoExternal =
| boolean
| {
dependencies?: boolean;
optionalDependencies?: boolean;
devDependencies?: boolean;
peerDependencies?: boolean;
};
```

- **Default:** `true`

Whether to automatically externalize dependencies and do not bundle them.

## autoExternal.dependencies

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

Whether to externalize dependencies of type `dependencies`.

## autoExternal.optionalDependencies

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

Whether to externalize dependencies of type `optionalDependencies`.

## autoExternal.peerDependencies

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

Whether to externalize dependencies of type `peerDependencies`.

## autoExternal.devDependencies

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

Whether to bundle dependencies of type `devDependencies`.

## Default Value

The default value of `autoExternal` is `true`, which means the following dependency types will **not be bundled**:

- `dependencies`
- `optionalDependencies`
- `peerDependencies`

And the following dependency types will be **bundled**:

- `devDependencies`

It is equivalent to the following configuration:

```ts
export default {
lib: [
{
format: 'esm',
autoExternal: {
dependencies: true,
optionalDependencies: true,
peerDependencies: true,
devDependencies: false,
},
},
],
};
```

## Example

### Customize Externalized Dependency Types

To disable the processing of a specific type of dependency, you can configure `autoExternal` as an object like this:

```ts title="rslib.config.ts"
export default {
lib: [
{
format: 'esm',
autoExternal: {
dependencies: false,
peerDependencies: false,
},
},
],
};
```

### Disable Default Behavior

If you want to disable the default behavior, you can set `autoExternal` to `false`:

```ts title="rslib.config.ts"
export default {
lib: [
{
format: 'esm',
autoExternal: false,
},
],
};
```
2 changes: 1 addition & 1 deletion website/docs/en/guide/advanced/third-party-deps.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ console.info(__WEBPACK_EXTERNAL_MODULE_react__['default']);

If you want to modify the default processing, you can use the following API.

- [`lib.autoExternal`](/config/lib/auto-external)
- [lib.autoExternal](/config/lib/auto-external)

## Exclude specified third-party dependencies

Expand Down
Loading