3 category: JavaScript libraries
13 [Rollup](https://rollupjs.org/) Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application.
35 | Command | Description |
37 | `rollup -c -o bundle.js` | bundle using config |
38 | `rollup main.js --o bundle.js --f cjs` | bundle |
39 | `rollup --watch` | bundle continuously |
41 You may need to use `./node_modules/.bin/rollup` as a command if you did not install rollup globally.
52 file: __dirname + '/public/main.js',
58 input: 'src/vendor.js',
60 file: __dirname + 'public/vendor.js',
68 This creates `main.js` and `vendor.js`.
77 npm install -D @rollup/plugin-json
83 import json from '@rollup/plugin-json'
100 npm install -D @rollup/plugin-node-resolve
103 #### rollup.config.js
105 import resolve from '@rollup/plugin-node-resolve'
108 input: 'src/main.js',
113 plugins: [ resolve() ]
117 When you run a npm run build, no warning is emitted and contains the imported modules.
119 ### Peer dependencies
124 npm install -D @rollup/plugin-node-resolve
127 #### rollup.config.js
130 import resolve from '@rollup/plugin-node-resolve'
133 input: 'src/main.js',
139 // pass custom options to the resolve plugin
140 customResolveOptions: {
141 moduleDirectory: 'node_modules'
144 // indicate which modules should be treated as external
154 npm install -D rollup-plugin-babel
157 #### rollup.config.js
160 import resolve from '@rollup/plugin-node-resolve'
161 import babel from 'rollup-plugin-babel'
164 input: 'src/main.js',
172 exclude: 'node_modules/**' // only transpile our source code
189 "plugins": ["external-helpers"]