rollup-load-plugins

raw JSON →
0.4.0 verified Mon Apr 27 auth: no javascript

Utility to automatically load Rollup plugins listed in package.json, similar to gulp-load-plugins. Version 0.4.0 is the latest stable release, with slow development cadence. It reads dependencies, devDependencies, and peerDependencies matching a configurable pattern (default: rollup-plugin-*) and exposes them as camelCased properties on an object. Supports scoped packages, custom patterns, and configurable replacement strings. Unlike manual imports, it reduces boilerplate and enables dynamic plugin loading. No security incidents reported.

error Cannot find module 'rollup-plugin-*'
cause The plugin is not installed or not listed in package.json under dependencies/devDependencies/peerDependencies.
fix
Install the missing plugin: npm install --save-dev rollup-plugin-<name>
error TypeError: plugins.nodeResolve is not a function
cause CamelCase transformation may produce unexpected property names or the plugin was not loaded.
fix
Check the exact property name by logging plugins or verifying pattern and replaceString options.
gotcha Plugin names are camelCased by default; e.g., rollup-plugin-node-resolve becomes plugins.nodeResolve.
fix Use camelCase property names when accessing plugins.
gotcha Scoped packages like @mycompany/rollup-plugin-foo become plugins.mycompany.foo by default if maintainScope is true.
fix Set maintainScope to false if you prefer plugins.foo.
gotcha Only plugins matching the pattern (default: rollup-plugin-*) are loaded. Other dependencies are ignored.
fix Verify your plugin names match the pattern or adjust the pattern option.
gotcha Plugins are required at load time, not lazily. All matching packages are imported immediately.
fix Ensure all matching packages are valid Rollup plugins to avoid runtime errors.
npm install rollup-load-plugins
yarn add rollup-load-plugins
pnpm add rollup-load-plugins

Loads all rollup-plugin-* packages from package.json and uses them in a Rollup build.

import loadPlugins from 'rollup-load-plugins';
import { rollup } from 'rollup';

const plugins = loadPlugins();

async function build() {
  const bundle = await rollup({
    input: 'src/index.js',
    plugins: [
      plugins.nodeResolve({ jsnext: true, main: true }),
      plugins.commonjs({ include: 'node_modules/**' })
    ]
  });
  await bundle.write({ file: 'dist/bundle.js', format: 'cjs' });
}
build().catch(console.error);