{"id":21235,"library":"esbuild-plugin-clean","title":"esbuild-plugin-clean","description":"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.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/LinbuduLab/esbuild-plugins","tags":["javascript","esbuild","ESBuild","clean","plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-clean","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-clean","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-clean","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Plugin for ESBuild, required to run as a plugin inside ESBuild.","package":"esbuild","optional":false},{"reason":"Used under the hood for file deletion; the plugin accepts del options.","package":"del","optional":false}],"imports":[{"note":"Named export, not default.","wrong":"import clean from 'esbuild-plugin-clean'","symbol":"clean","correct":"import { clean } from 'esbuild-plugin-clean'"},{"note":"CleanOptions is a type, use 'import type' in TypeScript to avoid runtime issues.","wrong":"import { CleanOptions } from 'esbuild-plugin-clean'","symbol":"CleanOptions","correct":"import type { CleanOptions } from 'esbuild-plugin-clean'"},{"note":"CommonJS require with destructuring for named export.","wrong":"const clean = require('esbuild-plugin-clean')","symbol":"clean","correct":"const { clean } = require('esbuild-plugin-clean')"}],"quickstart":{"code":"import { build } from 'esbuild';\nimport { clean } from 'esbuild-plugin-clean';\n\n(async () => {\n  await build({\n    entryPoints: ['./src/index.ts'],\n    bundle: true,\n    outdir: './dist',\n    plugins: [\n      clean({\n        patterns: ['./dist/*'],\n        cleanOnStartPatterns: ['./prepare'],\n        cleanOnEndPatterns: ['./post'],\n        dryRun: false,\n        sync: true,\n        verbose: true,\n      }),\n    ],\n  });\n})();","lang":"typescript","description":"Shows how to use the clean plugin with ESBuild, including patterns for start and end, and configuration options."},"warnings":[{"fix":"Update esbuild to at least 0.14.0.","message":"The plugin requires esbuild >= 0.14.0. Using an older esbuild version will cause errors.","severity":"breaking","affected_versions":"<0.14.0"},{"fix":"Use absolute paths or cwd option to restrict deletion scope.","message":"The plugin uses 'del' which may delete files outside the working directory if patterns are not careful.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"It's intentional to match del's option naming.","message":"Option 'dryRun' is misspelled (should be 'dryRun' but del uses 'dryRun' as well).","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install esbuild >= 0.14.0: npm install esbuild@latest","cause":"Using an older version of esbuild (<0.14.0).","error":"Error: The plugin \"clean\" is not compatible with ESBuild version 0.12.x"},{"fix":"Use import { clean } from 'esbuild-plugin-clean'","cause":"Incorrect import: using default import instead of named import.","error":"TypeError: clean is not a function"},{"fix":"Install del: npm install del","cause":"Missing peer dependency 'del'.","error":"Cannot find module 'del'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}