Registry / devops / esbuild-plugin-output-reset

esbuild-plugin-output-reset

JSON →
library2.0.2jsnpmunverified

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.

npm install esbuild-plugin-output-reset
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-OUT
E
esbuild-plugin-output-reset
devopsjavascriptv2.0.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

clear
import clear from 'esbuild-plugin-output-reset'
import { clear } from 'esbuild-plugin-output-reset'
This package uses a default export. Named import will result in undefined.
esbuild-plugin-output-reset (CJS)
const clear = require('esbuild-plugin-output-reset').default
const clear = require('esbuild-plugin-output-reset')
In CommonJS, the default export is accessed via .default.
TypeScript (default import)
import clear from 'esbuild-plugin-output-reset'
import * as clear from 'esbuild-plugin-output-reset'
TypeScript users should use default import; star import will give a module namespace object.

Shows the minimal setup to use the plugin with ESBuild's build API, cleaning the dist folder before each build.

import esbuild from 'esbuild'; import clear from 'esbuild-plugin-output-reset'; await esbuild.build({ entryPoints: ['./src/index.js'], bundle: true, outdir: './dist', plugins: [clear], });
Debug
Known issues
gotchaThe 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.
fix
Ensure the output directory is dedicated solely to the build output.
affects: >=0.0.0
gotchaThe plugin will not work if both outdir and outfile are undefined; it will throw an error as there is no output path to reset.
fix
Always specify either outdir or outfile in your ESBuild options.
affects: >=0.0.0
breakingIn version 2.0.0, the plugin changed to be an async function that returns a plugin object. Previously it was a direct plugin object.
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.
affects: <2.0.0
deprecatedVersion 1.x used a named export 'clear'. In version 2.x it was replaced with a default export.
fix
Switch to default import: import clear from 'esbuild-plugin-output-reset'.
affects: >=1.0.0 <2.0.0
Errors
Common errors & fixes
TypeError: clear is not a function
Using named import instead of default import in ES module context.
fix
Change import { clear } from 'esbuild-plugin-output-reset' to import clear from 'esbuild-plugin-output-reset'.
Error: The plugin 'esbuild-plugin-output-reset' must be a function, object, or a promise resolving to one.
In older ESBuild versions (<0.17), plugins needed to be objects. The plugin is a function that returns an object.
fix
Upgrade esbuild to version 0.17 or later.
Error: Cannot find module 'esbuild-plugin-output-reset'
Package not installed or not in node_modules.
fix
Run npm install esbuild-plugin-output-reset --save-dev (or your package manager equivalent).
Upgrade
Version history
2.0.2latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency required to function as an ESBuild plugin
Agent activity
2 hits · last 30 days
node
2
Resources
esbuild-plugin-output-reset — npm install esbuild-plugin-output-reset · libregistry