Rollup.js is a JavaScript bundling tool that combines multiple scripts into one script for use in browsers. It was developed to be easy to use and requires minimal configuration. Bundling tools are necessary because early browsers did not support modules, Node.js module mechanisms are not compatible with browsers, and bundling improves performance. Webpack is a popular bundling tool, but it has a complex configuration and high learning cost. Rollup.js is recommended for bundling ES modules, but not for CommonJS modules. To use Rollup.js, install it globally with npm or use it without installation with npx. The basic usage of Rollup.js involves bundling two simple scripts, add.js and main.js, with the command "rollup main.js". The bundling result can be saved to a specified file with the parameter --file. Rollup.js also supports multiple entry scripts, automatic execution function wrapping, code minimization, and configuration files. Finally, Rollup.js can convert ES modules to CommonJS modules with the parameter --format cjs.
dev.to
dev.to
Create attached notes ...
