Registry / devops / rollup-plugin-by-output

rollup-plugin-by-output

JSON →
library1.0.1jsnpmunverified

A Rollup plugin (or plugin helper) that allows applying Rollup plugins conditionally based on output options (format, file, etc.). Version 1.0.1 is the latest stable release. It helps reduce duplicate config when Rollup has multiple outputs that need different plugins (e.g., minification only for UMD builds). Key differentiator: provides elegant helpers like `when`, `whenAll`, `prop`, `format`, and `file` to filter plugins per output. Unlike manual array configs, it keeps code DRY. Requires Node >=8.3.0.

npm install rollup-plugin-by-output
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-BY-O
R
rollup-plugin-by-output
devopsjavascriptv1.0.1
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18–223 runs
build_error
glibc
node 18–223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

plugins
✓ import plugins from 'rollup-plugin-by-output'
✗ const plugins = require('rollup-plugin-by-output')
ESM default import; CJS require works but not recommended for Rollup configs
when
✓ import { when } from 'rollup-plugin-by-output'
✗ const { when } = require('rollup-plugin-by-output')
Named export; also available via CJS destructuring
file
✓ import { file } from 'rollup-plugin-by-output'
Named export; commonly used to filter by output file path
format
✓ import { format } from 'rollup-plugin-by-output'
Named export; commonly used to filter by output format (e.g., 'umd', 'cjs')

Applies babel to all outputs and terser only to the minified output.

import babel from 'rollup-plugin-babel'; import terser from 'rollup-plugin-terser'; import plugins, { file } from 'rollup-plugin-by-output'; export default { input: 'src/index.js', output: [ { file: 'dist/bundle.js', format: 'cjs' }, { file: 'dist/bundle.min.js', format: 'cjs' }, ], plugins: plugins( babel(), [file('dist/bundle.min.js'), terser()] ) };
Debug
Known issues
gotchaThe 'file' helper compares exact string equality, not a suffix. To match by file extension, use a custom function.
fix
Use when(file.name => name.endsWith('.min.js'), plugin) or prop('file', f => f.endsWith('.min.js'))
affects: all
deprecatedThe package exports using default export for 'plugins' but named exports for helpers – mixing can cause confusion.
fix
Be explicit: import plugins, { when } from 'rollup-plugin-by-output'
affects: all
Errors
Common errors & fixes
TypeError: plugins is not a function
Using default import as an array or passing incorrect arguments to 'plugins'.
fix
Call plugins() with arguments: plugins(pluginA, [filter, pluginB]). Do not wrap in array brackets.
when is not a function
Importing 'when' incorrectly (e.g., import { when } from 'rollup-plugin-by-output' but package doesn't export it as named in CJS).
fix
Ensure your bundler supports ESM or use import { when } from 'rollup-plugin-by-output' with ES modules; in CJS, use const { when } = require('rollup-plugin-by-output').
Module not found: Error: Can't resolve 'rollup-plugin-by-output'
Package not installed or missing in node_modules.
fix
Run npm install --save-dev rollup-plugin-by-output
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
rolluprequiredpeer dependency - operates as a Rollup plugin
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-by-output — npm install rollup-plugin-by-output · libregistry