{"id":25380,"library":"esbuild-plugin-output-reset","title":"esbuild-plugin-output-reset","description":"ESBuild plugin that automatically clears the output directory before each build, ensuring a clean build state by removing old files. Version 2.0.2 is the current stable release, with no recent updates. It is a lightweight, single-purpose plugin that integrates seamlessly with ESBuild's plugin system. Unlike manual cleanup scripts, it runs as part of the ESBuild build process and respects the configured outdir or outfile paths. Ships with TypeScript type definitions.","status":"active","version":"2.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/yamitsushi/esbuild-plugin-output-reset","tags":["javascript","ESBuild","esbuild","plugin","typescript"],"install":[{"cmd":"npm install esbuild-plugin-output-reset","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-output-reset","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-output-reset","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to function as an ESBuild plugin","package":"esbuild","optional":false}],"imports":[{"note":"This package uses a default export. Named import will result in undefined.","wrong":"import { clear } from 'esbuild-plugin-output-reset'","symbol":"clear","correct":"import clear from 'esbuild-plugin-output-reset'"},{"note":"In CommonJS, the default export is accessed via .default.","wrong":"const clear = require('esbuild-plugin-output-reset')","symbol":"esbuild-plugin-output-reset (CJS)","correct":"const clear = require('esbuild-plugin-output-reset').default"},{"note":"TypeScript users should use default import; star import will give a module namespace object.","wrong":"import * as clear from 'esbuild-plugin-output-reset'","symbol":"TypeScript (default import)","correct":"import clear from 'esbuild-plugin-output-reset'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport clear from 'esbuild-plugin-output-reset';\n\nawait esbuild.build({\n  entryPoints: ['./src/index.js'],\n  bundle: true,\n  outdir: './dist',\n  plugins: [clear],\n});","lang":"typescript","description":"Shows the minimal setup to use the plugin with ESBuild's build API, cleaning the dist folder before each build."},"warnings":[{"fix":"Ensure the output directory is dedicated solely to the build output.","message":"The plugin deletes the entire output directory specified by outdir or outfile's parent directory. If you have other important files in that directory, they will be removed.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always specify either outdir or outfile in your ESBuild options.","message":"The plugin will not work if both outdir and outfile are undefined; it will throw an error as there is no output path to reset.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If using older version, update the import and usage: the plugin is now used as import clear from 'esbuild-plugin-output-reset' and passed directly to plugins array.","message":"In version 2.0.0, the plugin changed to be an async function that returns a plugin object. Previously it was a direct plugin object.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Switch to default import: import clear from 'esbuild-plugin-output-reset'.","message":"Version 1.x used a named export 'clear'. In version 2.x it was replaced with a default export.","severity":"deprecated","affected_versions":">=1.0.0 <2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Change import { clear } from 'esbuild-plugin-output-reset' to import clear from 'esbuild-plugin-output-reset'.","cause":"Using named import instead of default import in ES module context.","error":"TypeError: clear is not a function"},{"fix":"Upgrade esbuild to version 0.17 or later.","cause":"In older ESBuild versions (<0.17), plugins needed to be objects. The plugin is a function that returns an object.","error":"Error: The plugin 'esbuild-plugin-output-reset' must be a function, object, or a promise resolving to one."},{"fix":"Run npm install esbuild-plugin-output-reset --save-dev (or your package manager equivalent).","cause":"Package not installed or not in node_modules.","error":"Error: Cannot find module 'esbuild-plugin-output-reset'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}