or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-size-limit--preset-small-lib

Size Limit preset for small open source libraries that combines esbuild and file plugins to track bundle sizes

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@size-limit/preset-small-lib@11.2.x

To install, run

npx @tessl/cli install tessl/npm-size-limit--preset-small-lib@11.2.0

index.mddocs/

@size-limit/preset-small-lib

@size-limit/preset-small-lib is a Size Limit preset for small open source libraries. It provides a preconfigured setup that combines esbuild and file plugins to efficiently track the size of all files and dependencies in JavaScript libraries, enabling developers to automatically monitor and control bundle sizes in their CI pipelines.

Package Information

  • Package Name: @size-limit/preset-small-lib
  • Package Type: npm
  • Language: JavaScript (ES modules)
  • Module Type: ES module (type: "module")
  • Installation: npm install --save-dev size-limit @size-limit/preset-small-lib

Core Imports

Size Limit automatically loads this preset when installed. For advanced use cases where you need to import the preset directly:

import preset from "@size-limit/preset-small-lib";

For CommonJS environments:

const preset = require("@size-limit/preset-small-lib").default;

Basic Usage

The preset is automatically loaded by Size Limit when installed. Configure it in your package.json:

{
  "size-limit": [
    {
      "path": "index.js"
    }
  ],
  "scripts": {
    "size": "size-limit"
  }
}

Run the size check:

npm run size

When using this preset, Size Limit will automatically:

  1. Bundle your library using esbuild
  2. Calculate the actual file size including all dependencies and polyfills
  3. Support multiple compression methods (none, gzip, brotli)
  4. Provide accurate size measurements optimized for small libraries

Architecture

This preset is built on Size Limit's plugin architecture and combines two essential plugins:

  • @size-limit/esbuild: Handles JavaScript bundling using esbuild with optimized configurations
  • @size-limit/file: Calculates actual file sizes with compression support (gzip, brotli)

The preset integrates with Size Limit's step-based processing system where plugins execute in numbered phases (step20, step40, step60, step61) to build, measure, and adjust size calculations.

Capabilities

Preset Configuration

The main export that provides the combined plugin configuration for Size Limit.

/**
 * Default export containing the preset configuration
 * Combines @size-limit/esbuild and @size-limit/file plugins
 */
declare const preset: SizeLimitPlugin[];

export default preset;

Plugin Components

This preset internally combines the following Size Limit plugins:

The preset combines plugins that handle different phases of Size Limit's processing:

  • @size-limit/esbuild: Handles JavaScript bundling using esbuild with optimized configurations
  • @size-limit/file: Calculates actual file sizes with compression support (gzip, brotli)

Each plugin implements various processing steps (step20, step40, step60, step61) in Size Limit's execution pipeline.

Types

/**
 * The preset exports an array of Size Limit plugins
 */
type PresetExport = SizeLimitPlugin[];

interface SizeLimitPlugin {
  name: string;
  before?(config: object): Promise<void>;
  finally?(config: object, check: object): Promise<void>;
  step20?(config: object, check: object): Promise<void>;
  step40?(config: object, check: object): Promise<void>;
  step60?(config: object, check: object): Promise<void>;
  step61?(config: object, check: object): Promise<void>;
  wait40?: string;
}

Dependencies

This preset has the following dependencies:

Peer Dependencies:

  • size-limit: 11.2.0 (the core Size Limit framework)

Direct Dependencies:

  • @size-limit/esbuild: 11.2.0 (esbuild bundling functionality)
  • @size-limit/file: 11.2.0 (file size calculation)
  • size-limit: 11.2.0 (also included as direct dependency)

Use Cases

This preset is ideal for:

  • Small npm libraries that need accurate size tracking
  • Open source libraries requiring CI-based size monitoring
  • Performance-critical packages where bundle size matters for end-users
  • Libraries with dependencies that need comprehensive size calculation including polyfills
  • Projects using modern build tools that benefit from esbuild's fast bundling