Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rollup

Package Overview
Dependencies
Maintainers
5
Versions
836
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup

Next-generation ES module bundler

  • 3.29.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29M
increased by7.95%
Maintainers
5
Weekly downloads
 
Created

What is rollup?

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. It is optimized for bundling JavaScript files to use in a browser, and it is also capable of transforming code using plugins.

What are rollup's main functionalities?

Bundling Modules

Rollup can bundle multiple JavaScript modules into a single file. The above code demonstrates how to create a bundle from an entry point file 'src/main.js' and output it as an immediately-invoked function expression (IIFE) to 'bundle.js'.

import rollup from 'rollup';

async function build() {
  const bundle = await rollup.rollup({
    input: 'src/main.js'
  });

  await bundle.write({
    file: 'bundle.js',
    format: 'iife',
    name: 'MyModule'
  });
}

build();

Tree-shaking

Rollup includes a feature called 'tree-shaking' which removes unused code from the final bundle. This helps in reducing the size of the bundle and improving load times.

import { rollup } from 'rollup';

rollup({
  input: 'src/index.js',
  treeshake: true // Tree-shaking is enabled by default
}).then(bundle => {
  // Code to write the bundle
});

Plugin System

Rollup supports a wide range of plugins that can transform the code, add functionality, or integrate with other build tools. The code sample shows how to use the JSON plugin to import JSON files as modules.

import { rollup } from 'rollup';
import json from '@rollup/plugin-json';

rollup({
  input: 'src/index.js',
  plugins: [json()]
}).then(bundle => {
  // Code to write the bundle
});

Other packages similar to rollup

Keywords

FAQs

Package last updated on 10 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc