{"id":21207,"library":"eleventy-plugin-rollup","title":"eleventy-plugin-rollup","description":"An Eleventy plugin that integrates Rollup into the build pipeline, enabling per-page JavaScript bundling and code splitting. Version 1.3.0 is the current stable release, updated as needed. Unlike running Rollup separately, this plugin shares the Eleventy build context, reducing duplicate bundles and allowing shared modules across pages. It supports both explicit Rollup configuration via options or an external config file, and provides a Liquid/Nunjucks shortcode for including bundled scripts. Notable alternatives like eleventy-plugin-esbuild or manual PostCSS/Webpack setups require more manual wiring. Requires Rollup as a peer dependency; supports Eleventy 1.x and 2.x.","status":"active","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/Snapstromegon/eleventy-plugin-rollup","tags":["javascript","rollup","11ty","eleventy","bundle","ssg"],"install":[{"cmd":"npm install eleventy-plugin-rollup","lang":"bash","label":"npm"},{"cmd":"yarn add eleventy-plugin-rollup","lang":"bash","label":"yarn"},{"cmd":"pnpm add eleventy-plugin-rollup","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; required to perform actual bundling","package":"rollup","optional":false}],"imports":[{"note":"Package does not provide a named export; use default CommonJS require. ESM import may require .default.","wrong":"import rollupPlugin from 'eleventy-plugin-rollup';","symbol":"default","correct":"const rollupPlugin = require('eleventy-plugin-rollup');"},{"note":"If using ESM import, the default is wrapped; avoid .default chain. Use require for simplicity.","wrong":"eleventyConfig.addPlugin(rollupPlugin.default, ...);","symbol":"rollupPlugin","correct":"eleventyConfig.addPlugin(rollupPlugin, { rollupOptions: { /* ... */ } });"},{"note":"The shortcode defaults to 'rollup' and expects a relative path. Use the | url filter only if your template engine requires it (e.g., Liquid).","wrong":"{% rollup \"assets/js/main.js\" | url %} with no shortcode","symbol":"shortcode","correct":"{% rollup \"assets/js/main.js\" %}"}],"quickstart":{"code":"// .eleventy.js\nconst rollupPlugin = require('eleventy-plugin-rollup');\n\nmodule.exports = function (eleventyConfig) {\n  eleventyConfig.addPlugin(rollupPlugin, {\n    rollupOptions: {\n      output: {\n        format: 'es',\n        dir: '_site/js',\n      },\n    },\n  });\n\n  // ... other config\n};","lang":"javascript","description":"Shows how to add the plugin with explicit Rollup options in an Eleventy config file."},"warnings":[{"fix":"Set output.format to 'es' or 'system' in rollupOptions.output.","message":"Breaking: rollupOptions no longer accepts output.format as 'iife' when used with multiple entry points; use 'es' or 'system'.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Replace rollupOptions: 'rollup.config.js' with rollupOptions: require('./rollup.config.js') or inline the options.","message":"rollupOptions as a path string to a config file is deprecated; prefer passing options object directly","severity":"deprecated","affected_versions":"<1.3.0"},{"fix":"Use CommonJS-compatible Rollup plugins or ensure your config file is transpiled/required correctly.","message":"Shortcode uses require() internally; do not import rollup plugins that are ESM-only in the shortcode context","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Set importScriptsAbsoluteFrom to the absolute base URL path (e.g., '/subdir/') in the plugin options.","message":"If you use useAbsoluteScriptPaths: true, you must set importScriptsAbsoluteFrom to match your deployment path (defaults to eleventyConfig.dir.output)","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add rollupOptions object with valid Rollup config (e.g., { output: { format: 'es', dir: '_site/js' } }).","cause":"Missing or empty rollupOptions in plugin configuration.","error":"Error: The rollupOptions property is required."},{"fix":"Ensure eleventyConfig.addPlugin(rollupPlugin, ...) is called and the shortcode matches (default: 'rollup').","cause":"Using the shortcode without adding the plugin or misspelling the shortcode name.","error":"rollup is not defined (shortcode error)"},{"fix":"Add output configuration: { output: { dir: '_site/js', format: 'es' } }.","cause":"rollupOptions does not contain output.dir or output.file.","error":"TypeError: Cannot read properties of undefined (reading 'output')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}