Rollup Worker
raw JSON → 2.0.1 verified Mon Apr 27 auth: no javascript
A CLI tool that wraps Rollup with built-in plugins for simplified, zero-config bundle management across multiple entry points. Version 2.0.1, with a next tag for latest releases. Key differentiators: plugin aliases (e.g., 'resolve', 'typescript', 'babel') that auto-configure, per-entry plugin overrides via functions, and a default config file (.fssrc.js). Targets Node >=7.10.1, and supports common formats (ESM, CJS, UMD, IIFE). Less flexible than raw Rollup but reduces boilerplate for multi-bundle workflows.
Common errors
error Error: Cannot find module '@rollup/plugin-node-resolve' ↓
cause rollup-worker does not bundle all Rollup plugins; they must be installed separately if not included by default.
fix
Install the missing plugin: npm install --save-dev @rollup/plugin-node-resolve
error Unexpected token: punc (.) ↓
cause Config file uses ESM syntax (e.g., import/export) but rollup-worker expects CJS.
fix
Convert to CommonJS: replace 'export default' with 'module.exports ='.
error Error: Could not resolve 'fs' (or other Node built-in) ↓
cause Rollup by default externalizes Node built-ins, but 'node-builtins' plugin must be enabled to shim them.
fix
Add 'node-builtins' to the plugins array.
Warnings
deprecated The 'next' install tag (npm i -g rollup-worker@next) is deprecated; use latest instead. ↓
fix Install with 'npm i -g rollup-worker@latest' or just 'npm i -g rollup-worker'.
gotcha Plugin alises may conflict with older Rollup plugin names; e.g., 'resolve' maps to @rollup/plugin-node-resolve but behavior differs. ↓
fix Check internal plugin mapping for each alias; override plugin config via function to control options.
gotcha Config file .fssrc.js must export via module.exports, not export default; failing silently yields no output. ↓
fix Use CommonJS export: module.exports = { ... }.
gotcha Plugin configuration functions receive { output, ... } , but some plugins expect different signature (e.g., typescript receives rollupCfg). ↓
fix Inspect plugin source or log the argument: plugins: { myPlugin: (cfg) => { console.log(cfg); return {}; } }.
Install
npm install rollup-worker yarn add rollup-worker pnpm add rollup-worker Imports
- cli usage wrong
require('rollup-worker')correctnpx rollup-worker -c .fssrc.js - config export wrong
export default { ... }correctmodule.exports = { ... } - plugin list wrong
const plugins = ['nodeResolve', 'ts'];correctconst plugins = ['resolve', 'typescript'];
Quickstart
// .fssrc.js
const { version, name, author, dependencies } = require('./package.json')
const banner = `/*! ${name} v${version} | MIT licensed. | by ${author} */`
module.exports = {
plugins: {
resolve: () => ({ preferBuiltins: false }),
commonjs: {},
babel: (cfg) => ({ comments: cfg.output.format !== 'iife' }),
replace: { __VERSION__: version }
},
entry: [
{
input: './src/main.js',
plugins: ['resolve', 'commonjs', 'babel'],
output: [
{ format: 'es', file: 'dist/bundle.esm.js' },
{ format: 'cjs', file: 'dist/bundle.cjs.js', banner }
]
}
]
}