esbuild-compress

2.0.2 • Public • Published

esbuild-compress

Plugin for esbuild that compresses embedded data, which will be decompressed at runtime, to reduce bundle size.

Usage

  • Configuration:
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:
import json from "./example.json"
import text0 from "./example.txt"

const text = await text0 // unnecessary if `lazy` is `false`

consumeJSON(json.key)
consumeText(text)

/esbuild-compress/

    Package Sidebar

    Install

    npm i esbuild-compress

    Weekly Downloads

    5

    Version

    2.0.2

    License

    MIT

    Unpacked Size

    6.67 kB

    Total Files

    4

    Last publish

    Collaborators

    • polyipseity