Registry / devops / rollup-plugin-clear

rollup-plugin-clear

JSON →
library2.0.7jsnpmunverified

A Rollup plugin that clears specified directories before each build, useful for cleaning output folders before bundling. Current version: 2.0.7. Released under MIT. Lightweight, simple API with minimal configuration. Differentiators: no external dependencies, supports watch mode via option. Best for projects requiring a clean build output.

npm install rollup-plugin-clear
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-CLEA
R
rollup-plugin-clear
devopsjavascriptv2.0.7
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.

default (clear)
✓ import clear from 'rollup-plugin-clear'
✗ const { default: clear } = require('rollup-plugin-clear')
ESM default import is recommended. In CJS, use dynamic import or default extraction.
default (clear)
✓ const clear = require('rollup-plugin-clear').default;
✗ const clear = require('rollup-plugin-clear');
CJS require yields an object with default property; .default is needed.
TypeScript type
✓ import type { Options } from 'rollup-plugin-clear'
✗ import { Options } from 'rollup-plugin-clear'
Options type is available for TypeScript users; use type-only import for compile-time.

Configures rollup-plugin-clear to clean the 'dist' directory before each build.

// rollup.config.js import clear from 'rollup-plugin-clear'; export default { input: 'src/index.js', output: { dir: 'dist', format: 'esm' }, plugins: [ clear({ targets: ['dist'], watch: false }) ] };
Debug
Known issues
gotchatargets must be an array of strings, otherwise plugin may not work as expected.
fix
Ensure targets is an array, e.g., targets: ['dist'].
affects: >=0.0.0
gotchaPlugin only clears directories; it does not create them. Ensure the output directory exists or is created by Rollup.
fix
Use another plugin like rollup-plugin-mkdirp or rely on Rollup's output.entryFileNames etc.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: clear is not a function
Incorrect import: using require without .default
fix
Use `const clear = require('rollup-plugin-clear').default;`
Cannot find module 'rollup-plugin-clear'
Plugin not installed or not listed in package.json
fix
Run `npm install --save-dev rollup-plugin-clear`
Upgrade
Version history
2.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Resources
rollup-plugin-clear — npm install rollup-plugin-clear · libregistry