Rollup.js | @ GitHub
The rollup CLI tool is the newest/simplest of all the module bundlers.
Bundle CommonJS (npm) app for browser
npm init
npm i
npm i -g rollup
# For Browsers (IIFE)
rollup 'main.js' --file 'bundle.js' --format 'iife'
# For Node.js (CommonJS)
rollup 'main.js' --file 'bundle.js' --format 'cjs'
# For Browsers & Node.js (UMD)
rollup 'main.js' --file 'bundle.js' --format 'umd' --name 'appBundle'
+ Convert modules from CommonJS to ES6
Rollup plugins to load CommonJS modules:
rollup-plugin-node-resolveInstall
npm i --save-dev 'rollup-plugin-commonjs' npm i --save-dev 'rollup-plugin-node-resolve'-
import resolve from 'rollup-plugin-node-resolve' import commonjs from 'rollup-plugin-commonjs'- Also, set "
exports: 'named'" atoutput.exportsto handle anyglobal(Window object); Node.js has no such object.
- Also, set "
Build declaratively (rollup.config.js)
rollup -c