{"library":"steal-rollup","title":"Rollup.js Module Bundler","type":"library","description":"Rollup is a highly optimized JavaScript module bundler that compiles small pieces of code into larger, more complex libraries or applications. It primarily leverages the standardized ES module format (ESM) for code, enabling advanced optimizations like tree-shaking to produce exceptionally small and efficient bundles. Rollup's current stable version is `4.60.2`, with frequent minor and patch releases (often weekly or bi-weekly) addressing bugs and adding features, while major versions introduce significant changes. Unlike bundlers focused on web applications, Rollup excels at bundling libraries and frameworks, offering a lean core with a powerful, flexible plugin API to handle various build scenarios, including CommonJS, AMD, UMD, and ES module outputs for different environments.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install steal-rollup"],"cli":{"name":"rollup","version":null}},"imports":["import { rollup } from 'rollup';","import type { InputOptions } from 'rollup';","import type { OutputOptions } from 'rollup';","import type { Plugin } from 'rollup';"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":"https://rollupjs.org","github":"https://github.com/rollup/rollup","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/steal-rollup","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"import { rollup } from 'rollup';\nimport type { InputOptions, OutputOptions, RollupBuild } from 'rollup';\nimport commonjs from '@rollup/plugin-commonjs';\nimport resolve from '@rollup/plugin-node-resolve';\n\nasync function buildBundle() {\n  // Define input options for your Rollup build\n  const inputOptions: InputOptions = {\n    input: 'src/main.js', // Your application's entry point\n    plugins: [\n      resolve(), // Locates modules using Node.js resolution algorithm\n      commonjs(), // Converts CommonJS modules to ES6, so they can be bundled by Rollup\n      // Add other plugins like @rollup/plugin-typescript, @rollup/plugin-babel here\n    ],\n  };\n\n  // Define output options for the generated bundle\n  const outputOptions: OutputOptions = {\n    file: 'dist/bundle.js',\n    format: 'es', // Output format: 'es' (ES Modules), 'cjs' (CommonJS), 'umd', 'iife', etc.\n    sourcemap: true, // Generate sourcemaps for debugging\n    name: 'myLibrary', // Required for IIFE/UMD formats\n  };\n\n  let bundle: RollupBuild | undefined;\n  try {\n    // 1. Call rollup to create a bundle\n    bundle = await rollup(inputOptions);\n\n    // 2. Generate and write the output file(s)\n    await bundle.write(outputOptions);\n\n    console.log('Rollup build completed successfully!');\n  } catch (error) {\n    console.error('Rollup build failed:', error);\n    process.exit(1);\n  } finally {\n    // 3. Close the bundle to release resources (e.g., file watchers)\n    if (bundle) {\n      await bundle.close();\n    }\n  }\n}\n\n// Example entry file (src/main.js):\n// export const greet = (name) => `Hello, ${name}!`;\n// console.log(greet('World'));\n\nbuildBundle();","lang":"typescript","description":"This quickstart demonstrates how to programmatically use Rollup with its JavaScript API to bundle a project, including common plugins for module resolution and CommonJS conversion, and outputs to an ES module format with sourcemaps.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}