{"id":22196,"library":"rollup-plugin-rename-files","title":"rollup-plugin-rename-files","description":"A Rollup plugin that renames output files, primarily used to fix extensions like .less.js to .css.js when bundling with preserveModules. Current version 2.0.0, based on rollup-plugin-rename-node-modules. Active maintenance. Differentiators: allows arbitrary filename transformations via a function, not limited to node_modules or extensions, unlike alternatives like rollup-plugin-rename-extensions or rollup-plugin-rename.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/cxsowo/rollup-plugin-rename-files","tags":["javascript","rollup","plugin","rollup-plugin","node_modules","rename","typescript"],"install":[{"cmd":"npm install rollup-plugin-rename-files","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-rename-files","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-rename-files","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for plugin API","package":"rollup","optional":false}],"imports":[{"note":"The plugin uses default export. ESM only; require() will not work in pure ESM context.","wrong":"const rename = require('rollup-plugin-rename-files')","symbol":"default","correct":"import rename from 'rollup-plugin-rename-files'"},{"note":"TypeScript type for options object, available since v2.0.0.","symbol":"RenameOptions","correct":"import type { RenameOptions } from 'rollup-plugin-rename-files'"},{"note":"The plugin is exported as a default function, not named export.","wrong":"import { rename } from 'rollup-plugin-rename-files'","symbol":"default (with type)","correct":"import rename from 'rollup-plugin-rename-files'"}],"quickstart":{"code":"// rollup.config.js\nimport rename from 'rollup-plugin-rename-files';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'cjs',\n    preserveModules: true,\n  },\n  plugins: [\n    rename({\n      includes: '',\n      moduleName: (filename) => filename.replace(/\\.less\\.js$/g, '.css.js'),\n    }),\n  ],\n};","lang":"javascript","description":"Shows how to use rollup-plugin-rename-files to rename .less.js output files to .css.js when using preserveModules."},"warnings":[{"fix":"Update plugin call to pass an options object: rename({ includes: '', moduleName: (f) => f })","message":"v2.0.0 changed default export from a function expecting a string to an object with 'includes' and 'moduleName' options.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use options object with moduleName property instead.","message":"Passing a string directly to rename() is deprecated since v2.0.0","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Ensure output files are generated with preserveModules or similar setting so filenames can be processed.","message":"Plugin only affects files output by Rollup; it does not transform source files or handle virtual modules.","severity":"gotcha","affected_versions":"*"},{"fix":"Leave includes empty for global rename, or use a glob pattern like '**/*.js'.","message":"If `includes` is not set (empty string), it applies to all files; specifying a pattern may cause some files to be missed.","severity":"gotcha","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use dynamic import: const rename = (await import('rollup-plugin-rename-files')).default;","cause":"Incorrect import or CJS require usage in ESM context","error":"TypeError: rename is not a function"},{"fix":"Set includes to a string (e.g., '') or a glob pattern.","cause":"Passing an array or other type for includes","error":"Error: The 'includes' option must be a string."},{"fix":"Provide a function like (filename) => filename.replace(...) or a string replacement pattern.","cause":"Passing a non-function non-string value for moduleName","error":"TypeError: moduleName must be a string or function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}