Skip to content

Commit b5f462d

Browse files
committed
docs: lib.autoExternal
1 parent 7deda98 commit b5f462d

File tree

2 files changed

+79
-2
lines changed

2 files changed

+79
-2
lines changed
Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,83 @@
11
# lib.autoExternal
22

3-
- **Type:** `boolean`
3+
- **Type:**
4+
5+
```ts
6+
type AutoExternal =
7+
| boolean
8+
| {
9+
dependencies?: boolean;
10+
optionalDependencies?: boolean;
11+
devDependencies?: boolean;
12+
peerDependencies?: boolean;
13+
};
14+
```
15+
416
- **Default:** `true`
517

618
Whether to automatically externalize dependencies and do not bundle them.
19+
20+
## Default Value
21+
22+
The default value of `autoExternal` is `true`, which means the following dependency types will **not be bundled**:
23+
24+
- `dependencies`
25+
- `optionalDependencies`
26+
- `peerDependencies`
27+
28+
And the following dependency types will be **bundled**:
29+
30+
- `devDependencies`
31+
32+
It is equivalent to the following configuration:
33+
34+
```ts
35+
export default {
36+
lib: [
37+
{
38+
format: 'esm',
39+
autoExternal: {
40+
dependencies: true,
41+
optionalDependencies: true,
42+
peerDependencies: true,
43+
devDependencies: false,
44+
},
45+
},
46+
],
47+
};
48+
```
49+
50+
## Example
51+
52+
### Customize Externalized Dependency Types
53+
54+
To disable the processing of a specific type of dependency, you can configure `autoExternal` as an object like this:
55+
56+
```ts title="rslib.config.ts"
57+
export default {
58+
lib: [
59+
{
60+
format: 'esm',
61+
autoExternal: {
62+
dependencies: false,
63+
peerDependencies: false,
64+
},
65+
},
66+
],
67+
};
68+
```
69+
70+
### Disable Default Behavior
71+
72+
If you want to disable the default behavior, you can set `autoExternal` to `false`:
73+
74+
```ts title="rslib.config.ts"
75+
export default {
76+
lib: [
77+
{
78+
format: 'esm',
79+
autoExternal: false,
80+
},
81+
],
82+
};
83+
```

website/docs/en/guide/advanced/third-party-deps.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ console.info(__WEBPACK_EXTERNAL_MODULE_react__['default']);
5353

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

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

5858
## Exclude specified third-party dependencies
5959

0 commit comments

Comments
 (0)