# esbuild-compress

> Compression plugin for esbuild.

Latest version **2.2.0** (published 2026-02-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install esbuild-compress
pnpm add esbuild-compress
yarn add esbuild-compress
bun add esbuild-compress
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2026-02-16 |
| First published | 2023-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | polyipseity |
| Maintainers | polyipseity |
| Keywords | compress, compression, esbuild, esbuild-plugin, plugin |

## Links

- npm: https://www.npmjs.com/package/esbuild-compress
- Repository: https://github.com/polyipseity/esbuild-compress
- Homepage: https://github.com/polyipseity/esbuild-compress#readme
- Issues: https://github.com/polyipseity/esbuild-compress/issues
- Funding: https://buymeacoffee.com/polyipseity
- npm.io page: https://npm.io/package/esbuild-compress

## Dependencies (4)

- [p-lazy](https://npm.io/package/p-lazy.md) ^5.0.0
- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.21
- [lz-string](https://npm.io/package/lz-string.md) ^1.5.0
- [import-meta-resolve](https://npm.io/package/import-meta-resolve.md) ^4.1.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 2.2.0 (latest) — 2026-02-16
- 2.1.0 — 2026-02-07
- 2.0.2 — 2025-06-06
- 2.0.1 — 2025-03-18
- 2.0.0 — 2023-08-15
- 1.3.1 — 2023-08-13
- 1.3.0 — 2023-08-13
- 1.2.2 — 2023-07-13
- 1.2.1 — 2023-07-01

## README

# esbuild-compress

[esbuild]: https://esbuild.github.io

Plugin for [esbuild] that compresses embedded data, which will be decompressed at runtime, to reduce bundle size.

## Usage

- Configuration:

```JavaScript
import { build } from "esbuild"
import esbuildCompress from "esbuild-compress"
import myBuildOptions from "./my-build-options.mjs"

await build({
 ...myBuildOptions,
 plugins: [
  esbuildCompress({
   // see plugin options
   compressors: [
    {
     filter: /\.json$/u,
     loader: "json",
    },
    {
     filter: /\.txt$/u,
     lazy: true,
     loader: "text",
    },
   ],
  }),
 ],
})
```

- Usage:

```JavaScript
import json from "./example.json"
import text0 from "./example.txt"

const text = await text0 // unnecessary if `lazy` is `false`

consumeJSON(json.key)
consumeText(text)
```

---
_Source: https://npm.io/package/esbuild-compress · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
