Registry / devops / rollup-plugin

rollup-plugin

JSON →
library1.0.0jsnpmunverified

A Rollup plugin that clears the output directory before each build, ensuring a clean state and preventing leftover files from previous builds. Version 1.0.0 is the current stable release. It is a lightweight plugin with a simple configuration, allowing users to specify target directories to clear. The release cadence is low; no recent updates. Key differentiators: dedicated solely to clearing directories, unlike other plugins that bundle multiple utilities. Use with Rollup for build automation.

npm install rollup-plugin
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN
R
rollup-plugin
devopsjavascriptv1.0.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

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

clearDirectory
✓ import clearDirectory from 'rollup-plugin-clear-directory';
✗ const clearDirectory = require('rollup-plugin-clear-directory');
The package exports a default function, so default import is correct. CommonJS require works but is not recommended for ESM projects.
default
✓ import clearDirectory from 'rollup-plugin-clear-directory';
✗ import { clearDirectory } from 'rollup-plugin-clear-directory';
Named import does not work because the package uses default export.
ClearOptions
✓ import type { ClearOptions } from 'rollup-plugin-clear-directory';
TypeScript users can import the type for configuration. This is optional.

Demonstrates basic usage of clearing the 'dist' directory before each Rollup build.

// rollup.config.js import clearDirectory from 'rollup-plugin-clear-directory'; export default { input: 'src/main.js', output: { dir: 'dist', format: 'esm' }, plugins: [ clearDirectory({ targets: ['dist'] }) ] };
Debug
Known issues
gotchaThe plugin clears directories synchronously before bundling starts. If you specify a non-empty target that does not exist, it may throw.
fix
Ensure all target directories exist or handle errors. Alternatively, use a plugin like 'rollup-plugin-delete' which creates directories if needed.
affects: >=1.0.0
gotchaIf you target the output directory configured in Rollup output, the plugin may interfere with Rollup's own directory creation. Use with caution.
fix
Clear before build, not during. The plugin clears before the build hook, so it should be safe, but test with your configuration.
affects: >=1.0.0
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, rmdir '...'
The target directory does not exist.
fix
Create the directory before running the plugin or ensure the path is correct.
TypeError: clearDirectory is not a function
Incorrect import statement, e.g., using named import instead of default import.
fix
Use 'import clearDirectory from 'rollup-plugin-clear-directory';'
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
rolluprequiredThis plugin is a Rollup plugin and requires Rollup to function.
Agent activity
29 hits · last 30 days
node
22
Anthropic
1
OpenAI (training)
1
Resources
rollup-plugin — npm install rollup-plugin · libregistry