size-limit
- Version 14.2.0
- Published
- 50.2 kB
- 2 dependencies
- MIT license
Install
npm i size-limityarn add size-limitpnpm add size-limitOverview
CLI tool for Size Limit
Index
Functions
Interfaces
Type Aliases
Functions
function sizeLimitAPI
sizeLimitAPI: ( plugins: readonly (Plugin | readonly Plugin[])[], files: string[] | object) => Promise<object>;Run Size Limit and return the result.
Parameter plugins
The list of plugins like
@size-limit/timeParameter files
Path to files or internal config Project size
Interfaces
interface Check
interface Check {}Represents the options for the size-limit check.
property brotli
brotli?: boolean;With
falseit will disable any compression.
property compareWith
compareWith?: string;Path to
stats.jsonfrom another build to compare (when--whyis using).
property config
config?: string;A path to a custom webpack, esbuild or rolldown config.
property disableModuleConcatenation
disableModuleConcatenation?: boolean;property disablePlugins
disablePlugins?: string[];Plugin npm package names to skip for this check. For example:
["@size-limit/webpack"],["@size-limit/esbuild"],["@size-limit/rolldown"], or["@size-limit/time"].
property entry
entry?: string | string[];When using a custom bundler config, an entry point could be given. It could be a string or an array of strings. By default, the total size of all entry points will be checked.
property gzip
gzip?: boolean;With
trueit will use Gzip compression and disable Brotli compression.
property hidePassed
hidePassed?: boolean;property highlightLess
highlightLess?: boolean;property ignore
ignore?: string[];An array of files and dependencies to exclude from the project size calculation.
property import
import?: string | Record<string, string>;Partial import to test tree-shaking. It could be
"{ lib }"to testimport { lib } from 'lib',*to test all exports, or{ "a.js": "{ a }", "b.js": "{ b }" }to test multiple files.
property limit
limit?: string;Size or time limit for files from the path option. It should be a string with a number and unit, separated by a space. Format:
100 B,10 kB,500 ms,1 s.
property modifyEsbuildConfig
modifyEsbuildConfig?: (config: object) => object;(
.size-limit.jsonly) Function that can be used to do last-minute changes to the esbuild config, like adding a plugin. Annotate the parameter withBuildOptionsto read properties.
property modifyRolldownConfig
modifyRolldownConfig?: (config: object) => object;(
.size-limit.jsonly) Function that can be used to do last-minute changes to the rolldown config, like adding a plugin. Annotate the parameter withRolldownOptionsto read properties.
property modifyWebpackConfig
modifyWebpackConfig?: (config: object) => object;(
.size-limit.jsonly) Function that can be used to do last-minute changes to the webpack config, like adding a plugin. Annotate the parameter withConfigurationto read properties.
property module
module?: boolean;property name
name?: string;The name of the current section. It will only be useful if you have multiple sections.
property path
path: string | string[];Relative paths to files. The only mandatory option. It could be a path
"index.js", a"dist/app-*.js"or an array["index.js", "dist/app-*.js", "!dist/app-exclude.js"].
property rolldown
rolldown?: boolean;With
falseit will disable rolldown.
property running
running?: boolean;With
falseit will disable calculating running time.
property time
time?: TimeOptions;Options for
@size-limit/timeplugin.
property uiReports
uiReports?: object;Custom UI reports list.
See Also
property webpack
webpack?: boolean;With
falseit will disable webpack.
interface Plugin
interface Plugin extends PluginSteps, PluginWaits {}Size Limit plugin.
A plugin package must export an array of plugins as its default export and have a name starting with
@size-limit/orsize-limit-to be loaded.import type { Plugin } from 'size-limit'export default [{name: 'size-limit-example',async step20(config, check) {// Measure the check and set `check.size`},wait20: 'Measuring'}] satisfies Plugin[]
property before
before?: PluginHook;Called before the first step.
property finally
finally?: PluginHook;Called after the last step, even when a step has thrown.
property name
name: string;NPM package name of the plugin, for example
@size-limit/file. It is also the name to use in thedisablePluginsoption.
interface PluginCheck
interface PluginCheck extends Omit<Check, 'entry' | 'import' | 'path' | 'time'> {}The check passed to the plugin hooks: the check from the config after Size Limit has resolved it, together with the fields added by the plugins which have already run.
property bundles
bundles?: string[];Built files to measure instead of
files, set by a bundler plugin.
property entry
entry?: string[];Entry points, normalized into an array.
property esbuild
esbuild?: boolean;With
falseit will disable esbuild.
property esbuildConfig
esbuildConfig?: Record<string, unknown>;esbuild build options, set by
@size-limit/esbuild. Useesbuildtypes for its exact shape.
property esbuildMetafile
esbuildMetafile?: Record<string, unknown>;esbuild build metadata, set by
@size-limit/esbuild. Useesbuildtypes for its exact shape.
property esbuildOutfile
esbuildOutfile?: string;Directory with the esbuild output, set by
@size-limit/esbuild.
property esbuildVisualizerFile
esbuildVisualizerFile?: string;Path to the esbuild bundle analyzer report, set by
@size-limit/esbuild-why.
property files
files?: string[];Absolute paths of the files to measure, after globbing. It is not set when the check is defined by
entryand a bundler plugin providesbundles.
property import
import?: Record<string, string>;Partial imports to test tree-shaking, keyed by the absolute path of a file.
property loadTime
loadTime?: number;Time to load the files, in seconds, set by
@size-limit/time.
property missed
missed?: boolean;With
truethe check has missed all of its files. It is set after the last step.
property passed
passed?: boolean;With
falsethe check has failed. It is set after the last step.
property path
path?: string | string[];Path of the check before it was resolved into
files. It is not set when the check is defined byentry.
property rolldownConfig
rolldownConfig?: Record<string, unknown>;rolldown configuration, set by
@size-limit/rolldown. Userolldowntypes for its exact shape.
property rolldownOutput
rolldownOutput?: string;Directory with the rolldown output, set by
@size-limit/rolldown.
property rolldownVisualizerFile
rolldownVisualizerFile?: string;Path to the rolldown bundle analyzer report, set by
@size-limit/rolldown-why.
property runTime
runTime?: number;Time to execute the files, in seconds, set by
@size-limit/time.
property size
size?: number;Total size of
bundlesorfilesin bytes, set by@size-limit/file.
property sizeLimit
sizeLimit?: number;Size limit in bytes, parsed from the
limitoption.
property time
time?: Omit<TimeOptions, 'latency' | 'networkSpeed'> & { latency?: number; networkSpeed?: number;};Options of
@size-limit/timeafter normalization:latencyin seconds andnetworkSpeedin bytes.
property timeLimit
timeLimit?: number;Time limit in seconds, parsed from the
limitoption.
property totalTime
totalTime?: number;Total time of the check, in seconds, set by
@size-limit/time.
property webpackConfig
webpackConfig?: Record<string, unknown>;webpack configuration, set by
@size-limit/webpack. Usewebpacktypes for its exact shape.
property webpackOutput
webpackOutput?: string;Directory with the webpack output, set by
@size-limit/webpack.
interface PluginConfig
interface PluginConfig {}Configuration of the current run, passed to the plugin hooks.
property checks
checks: PluginCheck[];Checks to run.
property cleanDir
cleanDir?: boolean;With
truethesaveBundledirectory will be cleaned before the build, set by the--clean-dirargument.
property compareWith
compareWith?: string;Absolute path to
stats.jsonfrom another build to compare, set by the--compare-withargument.
property configPath
configPath?: string;Path to the config file relative to
cwd. It is set only when the config comes from a config file.
property cwd
cwd?: string;Directory the checks are resolved from. It is set only when the config comes from a config file.
property failed
failed?: boolean;With
trueat least one check has failed. It is set after the last step.
property missed
missed?: boolean;With
trueat least one check has missed all of its files. It is set after the last step.
property project
project?: string;Package name, set by the
--whyargument.
property saveBundle
saveBundle?: string;Absolute path to the directory from the
--save-bundleargument.
property why
why?: boolean;With
trueit will open the bundle analyzer, set by the--whyargument.
interface TimeOptions
interface TimeOptions {}Represents the options for the size-limit check time property to customize
@size-limit/timeplugin.
property latency
latency?: string;Delay for calculating loading time that simulates network latency It should be a string with a number and unit, separated by a space. Format:
500 ms,1 s. @default: "0"
property loadingMessage
loadingMessage?: string;A message for loading time details "on slow 3G"
property networkSpeed
networkSpeed?: string;A network speed to calculate loading time of files. It should be a string with a number and unit, separated by a space. Format:
100 B,10 kB. "50 kB"
Type Aliases
type PluginHook
type PluginHook = (config: PluginConfig, check: PluginCheck) => Promise<void> | void;A hook called by Size Limit. It is called once per check which has not disabled the plugin with the
disablePluginsoption.
type PluginStep
type PluginStep = | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100;Numbers of the steps that Size Limit runs, from
0to100inclusive:calc()callsstep0,step1, …step100in order, andwait0…wait100name the spinner of the matching step.
type SizeLimitConfig
type SizeLimitConfig = Check[];Package Files (1)
Dependencies (2)
Dev Dependencies (0)
No dev dependencies.
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/size-limit.
- Markdown[](https://www.jsdocs.io/package/size-limit)
- HTML<a href="https://www.jsdocs.io/package/size-limit"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 2956 ms. - Missing or incorrect documentation? Open an issue for this package.
