{"id":21946,"library":"rollup-plugin-cleandir","title":"rollup-plugin-cleandir","description":"A Rollup plugin that automatically empties output directories before each build. Version 3.0.0 requires Rollup >=4.0.0 and runs on the `buildStart` hook with `order: 'pre'` by default, ensuring cleanup happens before any other plugin. The plugin forces an explicit `OUT_DIR` argument (optional in v2 but required in v3). It ships TypeScript definitions. Compared to similar plugins like `rollup-plugin-clean`, it is minimal and focused, with no extra features. Release cadence is low; major versions align with Rollup major upgrades.","status":"active","version":"3.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/mstssk/rollup-plugin-cleandir","tags":["javascript","clean","directory","rollup","plugin","typescript"],"install":[{"cmd":"npm install rollup-plugin-cleandir","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-cleandir","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-cleandir","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: plugin requires Rollup >=4.0.0","package":"rollup","optional":false}],"imports":[{"note":"Named export only. Default import does not work.","wrong":"import cleandir from 'rollup-plugin-cleandir'","symbol":"cleandir","correct":"import { cleandir } from 'rollup-plugin-cleandir'"},{"note":"CommonJS users must destructure the named export.","wrong":"const cleandir = require('rollup-plugin-cleandir').default","symbol":"cleandir (CommonJS)","correct":"const { cleandir } = require('rollup-plugin-cleandir')"},{"note":"TypeScript users can import the options type for better autocompletion.","wrong":null,"symbol":"type CleandirOptions","correct":"import type { CleandirOptions } from 'rollup-plugin-cleandir'"}],"quickstart":{"code":"// rollup.config.js\nimport { cleandir } from 'rollup-plugin-cleandir';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'es',\n  },\n  plugins: [cleandir('dist')],\n};","lang":"javascript","note":"OUT_DIR is required in v3.0.0+.","description":"Shows basic usage: import the named export and pass the output directory as the first argument."},"warnings":[{"fix":"Always pass the output directory path as the first argument to cleandir().","message":"OUT_DIR is now required in v3.0.0","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Upgrade Rollup to v2 or higher, or stay on v1.x of the plugin.","message":"v2.0.0 requires Rollup >=2.0.0","severity":"breaking","affected_versions":">=2.0.0 <3.0.0"},{"fix":"If you need a different ordering, use the options argument to specify a custom hook and/or order.","message":"Plugin uses `buildStart` hook with `order:'pre'`; may run before other plugins that also use the same hook with `order:'pre'`","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install the package: `npm install --save-dev rollup-plugin-cleandir` and use named import: `import { cleandir } from 'rollup-plugin-cleandir'`.","cause":"Missing installation or incorrect import style.","error":"Cannot find module 'rollup-plugin-cleandir'"},{"fix":"Use named import: `import { cleandir } from 'rollup-plugin-cleandir'`","cause":"Using default import or wrong import style.","error":"TypeError: cleandir is not a function"},{"fix":"Pass the output directory path as the first argument: `cleandir('dist')`.","cause":"cleandir() called without arguments in v3.0.0.","error":"Error: OUT_DIR is required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}