{"id":22206,"library":"rollup-plugin-rm","title":"rollup-plugin-rm","description":"A Rollup plugin that executes the rm (remove) command during build hooks, specifically buildStart or buildEnd. Version 1.0.2 (current stable) has a low release cadence. It is a minimal alternative to rollup-plugin-delete or rollup-plugin-clean, offering no-config deletion via a simple string path argument. It ships TypeScript types and requires Rollup 3 or 4 as a peer dependency. Unlike alternatives, it does not support glob patterns or multiple directories—only a single path removal.","status":"active","version":"1.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/alex8088/rollup-plugin-rm","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-rm","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-rm","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-rm","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency – plugin hooks require Rollup's plugin system","package":"rollup","optional":true}],"imports":[{"note":"Plugin is ESM-only; require() will fail. Use dynamic import() if needed in CJS context.","wrong":"const rm = require('rollup-plugin-rm')","symbol":"default","correct":"import rm from 'rollup-plugin-rm'"},{"note":"Library exports a default export, not a named export. Named import will yield undefined.","wrong":"import { rm } from 'rollup-plugin-rm'","symbol":"rm","correct":"import rm from 'rollup-plugin-rm'"},{"note":"Type import only – no runtime value. Use import type for type checking.","wrong":"import { RollupPluginRmOptions } from 'rollup-plugin-rm'","symbol":"RollupPluginRmOptions","correct":"import type { RollupPluginRmOptions } from 'rollup-plugin-rm'"}],"quickstart":{"code":"import rm from 'rollup-plugin-rm';\nimport { defineConfig } from 'rollup';\n\nexport default defineConfig({\n  input: 'src/index.js',\n  output: { dir: 'output', format: 'cjs' },\n  plugins: [\n    rm('dist', 'buildStart'),\n    rm('dist/types', 'buildEnd')\n  ]\n});","lang":"typescript","description":"Shows removal of 'dist' folder at buildStart and 'dist/types' at buildEnd using the Rollup plugin."},"warnings":[{"fix":"Use multiple rm() calls for each directory, or switch to rollup-plugin-delete for glob support.","message":"Only supports string path argument, not an array of paths or glob patterns. Multiple directories require multiple plugin calls.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"For large directories, remove synchronously via buildStart/buildEnd hooks manually using fs.promises.rm.","message":"Plugin uses synchronous rimraf under the hood. It may block the build for large directories; consider using asynchronous alternatives if performance is critical.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor GitHub releases for potential breaking changes.","message":"No deprecation warnings yet. Keep an eye on future releases for possible switch to async deletion.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Check existence before calling rm plugin; the underlying rimraf version may throw on ENOENT.","message":"If the path does not exist, rimraf fails silently? Ensure the directory exists or wrap in try/catch? Documentation does not specify behavior for non-existent paths.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade Rollup to version 3 or 4, or use rollup-plugin-delete which supports Rollup 2.","message":"Rollup 3 or 4 is required as peer dependency. Older Rollup 2 is not supported and will cause runtime hook mismatches.","severity":"breaking","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `import rm from 'rollup-plugin-rm'`","cause":"Using named import 'rm' instead of default import","error":"TypeError: rollup_plugin_rm_default is not a function"},{"fix":"Migrate to ESM ('type':'module' in package.json) or use dynamic import: `const rm = (await import('rollup-plugin-rm')).default`","cause":"Using require() in a CommonJS context for an ESM-only package","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Run `npm install rollup --save-dev`","cause":"Rollup not installed as a dependency","error":"Error: Cannot find module 'rollup' (or peer dependency missing)"},{"fix":"Pass a single string path: `rm('dist', 'buildStart')`. Use multiple calls for multiple paths.","cause":"Passing an array or undefined as the path argument","error":"rollup-plugin-rm: Path must be a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}