{"id":21951,"library":"rollup-plugin-clear","title":"rollup-plugin-clear","description":"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.","status":"active","version":"2.0.7","language":"javascript","source_language":"en","source_url":"https://github.com/DongShelton/rollup-plugin-clear","tags":["javascript","rollup","rollup-plugin","clear","clean"],"install":[{"cmd":"npm install rollup-plugin-clear","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-clear","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-clear","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import is recommended. In CJS, use dynamic import or default extraction.","wrong":"const { default: clear } = require('rollup-plugin-clear')","symbol":"default (clear)","correct":"import clear from 'rollup-plugin-clear'"},{"note":"CJS require yields an object with default property; .default is needed.","wrong":"const clear = require('rollup-plugin-clear');","symbol":"default (clear)","correct":"const clear = require('rollup-plugin-clear').default;"},{"note":"Options type is available for TypeScript users; use type-only import for compile-time.","wrong":"import { Options } from 'rollup-plugin-clear'","symbol":"TypeScript type","correct":"import type { Options } from 'rollup-plugin-clear'"}],"quickstart":{"code":"// rollup.config.js\nimport clear from 'rollup-plugin-clear';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'esm'\n  },\n  plugins: [\n    clear({\n      targets: ['dist'],\n      watch: false\n    })\n  ]\n};","lang":"javascript","description":"Configures rollup-plugin-clear to clean the 'dist' directory before each build."},"warnings":[{"fix":"Ensure targets is an array, e.g., targets: ['dist'].","message":"targets must be an array of strings, otherwise plugin may not work as expected.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use another plugin like rollup-plugin-mkdirp or rely on Rollup's output.entryFileNames etc.","message":"Plugin only clears directories; it does not create them. Ensure the output directory exists or is created by Rollup.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `const clear = require('rollup-plugin-clear').default;`","cause":"Incorrect import: using require without .default","error":"TypeError: clear is not a function"},{"fix":"Run `npm install --save-dev rollup-plugin-clear`","cause":"Plugin not installed or not listed in package.json","error":"Cannot find module 'rollup-plugin-clear'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}