0
# Size Limit Preset for Big Libraries
1
2
Size Limit preset for big open source libraries (> 10 kB) that combines webpack, file, and time plugins to provide comprehensive performance monitoring including tracking the time of JavaScript download and execution for the library and all its dependencies.
3
4
## Package Information
5
6
- **Package Name**: @size-limit/preset-big-lib
7
- **Package Type**: npm
8
- **Language**: JavaScript (ES Module)
9
- **Installation**: `npm install @size-limit/preset-big-lib`
10
- **Peer Dependencies**: size-limit@11.2.0
11
12
## Core Imports
13
14
```javascript
15
import preset from "@size-limit/preset-big-lib";
16
```
17
18
For CommonJS (if supported by bundler):
19
20
```javascript
21
const preset = require("@size-limit/preset-big-lib");
22
```
23
24
**Package.json access:**
25
26
```javascript
27
import packageJson from "@size-limit/preset-big-lib/package.json";
28
```
29
30
## Basic Usage
31
32
This preset is designed to be used with Size Limit configuration. It provides a pre-configured combination of plugins for comprehensive performance monitoring of large libraries.
33
34
```javascript
35
// size-limit.config.js
36
import preset from "@size-limit/preset-big-lib";
37
38
export default [
39
{
40
name: "My Big Library",
41
path: "dist/index.js",
42
plugins: preset,
43
limit: "50 kB"
44
}
45
];
46
```
47
48
Or in package.json:
49
50
```json
51
{
52
"size-limit": [
53
{
54
"name": "My Big Library",
55
"path": "dist/index.js",
56
"plugins": ["@size-limit/preset-big-lib"],
57
"limit": "50 kB"
58
}
59
]
60
}
61
```
62
63
## Architecture
64
65
This preset combines three Size Limit plugins:
66
67
- **@size-limit/webpack**: Provides webpack bundling analysis for accurate dependency tracking
68
- **@size-limit/file**: Measures the actual file size of the bundled output
69
- **@size-limit/time**: Measures JavaScript download and execution time
70
71
The preset exports these plugins as a combined array, making it easy to apply comprehensive performance monitoring to large libraries without manual plugin configuration.
72
73
## Capabilities
74
75
### Preset Configuration
76
77
The main and only export of this package - a combined array of Size Limit plugins optimized for big libraries.
78
79
```javascript { .api }
80
/**
81
* Size Limit preset combining webpack, file, and time plugins
82
* Exports: [...webpack, ...file, ...time]
83
*/
84
export default Array<SizeLimitPlugin>;
85
86
interface SizeLimitPlugin {
87
// Internal Size Limit plugin interface
88
// Specific structure depends on Size Limit implementation
89
}
90
```
91
92
**Usage:**
93
94
The preset is used by importing it and applying it to Size Limit configuration. When applied, it provides:
95
96
1. **Webpack bundling analysis** - Analyzes the library and all its dependencies through webpack
97
2. **File size measurement** - Tracks the actual file size of the bundled output
98
3. **Execution time measurement** - Measures JavaScript download and execution time
99
100
**Configuration Example:**
101
102
```javascript
103
import preset from "@size-limit/preset-big-lib";
104
105
// Apply to Size Limit configuration
106
const config = [
107
{
108
name: "Main Bundle",
109
path: "dist/main.js",
110
plugins: preset, // Uses the combined plugin array
111
limit: "100 kB"
112
}
113
];
114
```
115
116
## Dependencies
117
118
This preset includes the following Size Limit plugins as dependencies:
119
120
- **@size-limit/webpack@11.2.0** - Webpack bundling analysis plugin
121
- **@size-limit/file@11.2.0** - File size measurement plugin
122
- **@size-limit/time@11.2.0** - JavaScript execution time measurement plugin
123
- **size-limit@11.2.0** - Core Size Limit library (also required as peer dependency)
124
125
The preset simply re-exports these plugins in a combined array format, providing a convenient way to apply comprehensive performance monitoring to large libraries without manually configuring individual plugins.