Registry / devops / esbuild-plugin-clean

esbuild-plugin-clean

JSON →
library1.0.1jsnpmunverified

An ESBuild plugin for cleaning up output directories and assets before or after a build. Version 1.0.1 requires esbuild >= 0.14.0 and uses the 'del' library under the hood for file deletion. Supports patterns for cleaning on start, on end, or both. Offers dry-run and sync/async modes. Provides TypeScript types. Differentiators include granular control over cleaning phases and verbose logging.

npm install esbuild-plugin-clean
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-CLE
E
esbuild-plugin-clean
devopsjavascriptv1.0.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

clean
import { clean } from 'esbuild-plugin-clean'
import clean from 'esbuild-plugin-clean'
Named export, not default.
CleanOptions
import type { CleanOptions } from 'esbuild-plugin-clean'
import { CleanOptions } from 'esbuild-plugin-clean'
CleanOptions is a type, use 'import type' in TypeScript to avoid runtime issues.
clean
const { clean } = require('esbuild-plugin-clean')
const clean = require('esbuild-plugin-clean')
CommonJS require with destructuring for named export.

Shows how to use the clean plugin with ESBuild, including patterns for start and end, and configuration options.

import { build } from 'esbuild'; import { clean } from 'esbuild-plugin-clean'; (async () => { await build({ entryPoints: ['./src/index.ts'], bundle: true, outdir: './dist', plugins: [ clean({ patterns: ['./dist/*'], cleanOnStartPatterns: ['./prepare'], cleanOnEndPatterns: ['./post'], dryRun: false, sync: true, verbose: true, }), ], }); })();
Debug
Known issues
breakingThe plugin requires esbuild >= 0.14.0. Using an older esbuild version will cause errors.
fix
Update esbuild to at least 0.14.0.
affects: <0.14.0
gotchaThe plugin uses 'del' which may delete files outside the working directory if patterns are not careful.
fix
Use absolute paths or cwd option to restrict deletion scope.
affects: >=1.0.0
deprecatedOption 'dryRun' is misspelled (should be 'dryRun' but del uses 'dryRun' as well).
fix
It's intentional to match del's option naming.
affects: >=1.0.0
Errors
Common errors & fixes
Error: The plugin "clean" is not compatible with ESBuild version 0.12.x
Using an older version of esbuild (<0.14.0).
fix
Install esbuild >= 0.14.0: npm install esbuild@latest
TypeError: clean is not a function
Incorrect import: using default import instead of named import.
fix
Use import { clean } from 'esbuild-plugin-clean'
Cannot find module 'del'
Missing peer dependency 'del'.
fix
Install del: npm install del
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
esbuildrequiredPlugin for ESBuild, required to run as a plugin inside ESBuild.
delrequiredUsed under the hood for file deletion; the plugin accepts del options.
Agent activity
7 hits · last 30 days
node
6
Bingbot
1
Resources
esbuild-plugin-clean — npm install esbuild-plugin-clean · libregistry