LinuxCommandLibrary

rollup

TLDR

Bundle JavaScript

$ rollup [main.js] --file [bundle.js]
copy
Use configuration file
$ rollup -c
copy
Output format
$ rollup [main.js] -o [bundle.js] -f [es]
copy
Watch for changes
$ rollup -c --watch
copy
Generate sourcemap
$ rollup [main.js] -o [bundle.js] -m
copy
Specify multiple outputs
$ rollup -c -o [bundle.cjs.js] -o [bundle.esm.js]
copy

SYNOPSIS

rollup [options] input

DESCRIPTION

rollup is a JavaScript module bundler focused on ES modules. It compiles small pieces of code into larger bundles, with excellent tree-shaking to eliminate unused code.
The tool produces efficient bundles for libraries and applications, supporting multiple output formats.

PARAMETERS

-c file, --config file

Configuration file.
-o file, --file file
Output file.
-f fmt, --format fmt
Output format (es, cjs, umd, iife, amd).
-n name, --name name
UMD/IIFE global name.
-m, --sourcemap
Generate sourcemap.
-w, --watch
Watch mode.
-p plugin, --plugin plugin
Use plugin.
--no-treeshake
Disable tree shaking.

CAVEATS

Configuration needed for complex projects. Plugin ecosystem essential. CommonJS needs plugin. Build time can be slow for large projects.

HISTORY

Rollup was created by Rich Harris in 2015. It pioneered ES module bundling with tree-shaking, influencing later bundlers. Harris also created Svelte.

SEE ALSO

webpack(1), esbuild(1), vite(1), parcel(1)

Copied to clipboard