UNPKG

2.88 kBTypeScriptView Raw
1/**
2 * Represents the options for the size-limit check.
3 */
4export interface Check {
5 /**
6 * With `false` it will disable any compression.
7 */
8 brotli?: boolean
9
10 /**
11 * Path to `stats.json` from another build to compare (when `--why` is using).
12 */
13 compareWith?: string
14
15 /**
16 * A path to a custom webpack config.
17 */
18 config?: string
19
20 disableModuleConcatenation?: boolean
21
22 /**
23 * When using a custom webpack config, a webpack entry could be given.
24 * It could be a string or an array of strings. By default,
25 * the total size of all entry points will be checked.
26 */
27 entry?: string | string[]
28
29 /**
30 * With `true` it will use Gzip compression and disable Brotli compression.
31 */
32 gzip?: boolean
33
34 hidePassed?: boolean
35
36 highlightLess?: boolean
37
38 /**
39 * An array of files and dependencies to exclude from
40 * the project size calculation.
41 */
42 ignore?: string[]
43
44 /**
45 * Partial import to test tree-shaking. It could be `"{ lib }"` to test
46 * `import { lib } from 'lib'`, `*` to test all exports, or
47 * `{ "a.js": "{ a }", "b.js": "{ b }" }` to test multiple files.
48 */
49 import?: string | Record<string, string>
50
51 /**
52 * Size or time limit for files from the path option.
53 * It should be a string with a number and unit, separated by a space.
54 * Format: `100 B`, `10 kB`, `500 ms`, `1 s`.
55 */
56 limit?: string
57
58 modifyEsbuildConfig?: (config?: any) => any
59
60 /**
61 * (`.size-limit.js` only) Function that can be used to do last-minute
62 * changes to the webpack config, like adding a plugin.
63 */
64 modifyWebpackConfig?: (config?: any) => any
65
66 module?: boolean
67
68 /**
69 * The name of the current section.
70 * It will only be useful if you have multiple sections.
71 */
72 name?: string
73
74 /**
75 * Relative paths to files. The only mandatory option.
76 * It could be a path `"index.js"`, a
77 * {@link https://github.com/SuperchupuDev/tinyglobby pattern}
78 * `"dist/app-*.js"` or an array
79 * `["index.js", "dist/app-*.js", "!dist/app-exclude.js"]`.
80 */
81 path: string | string[]
82
83 /**
84 * With `false` it will disable calculating running time.
85 */
86 running?: boolean
87
88 /**
89 * Custom UI reports list.
90 *
91 * @see {@link https://github.com/statoscope/statoscope/tree/master/packages/webpack-plugin#optionsreports-report Statoscope docs}
92 */
93 uiReports?: object
94
95 /**
96 * With `false` it will disable webpack.
97 */
98 webpack?: boolean
99}
100
101export type SizeLimitConfig = Check[]
102
103/**
104 * Any function with any arguments.
105 */
106type AnyFunction = (...args: any[]) => any
107
108/**
109 * Run Size Limit and return the result.
110 *
111 * @param plugins The list of plugins like `@size-limit/time`
112 * @param files Path to files or internal config
113 * @return Project size
114 */
115declare function sizeLimitAPI(
116 plugins: AnyFunction[],
117 files: string[] | object
118): Promise<object>
119
120export default sizeLimitAPI
121
\No newline at end of file